Merge tag 'v2.6.0rc1' into instance_only_statuses
This commit is contained in:
72
spec/models/account_conversation_spec.rb
Normal file
72
spec/models/account_conversation_spec.rb
Normal file
@ -0,0 +1,72 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountConversation, type: :model do
|
||||
let!(:alice) { Fabricate(:account, username: 'alice') }
|
||||
let!(:bob) { Fabricate(:account, username: 'bob') }
|
||||
let!(:mark) { Fabricate(:account, username: 'mark') }
|
||||
|
||||
describe '.add_status' do
|
||||
it 'creates new record when no others exist' do
|
||||
status = Fabricate(:status, account: alice, visibility: :direct)
|
||||
status.mentions.create(account: bob)
|
||||
|
||||
conversation = AccountConversation.add_status(alice, status)
|
||||
|
||||
expect(conversation.participant_accounts).to include(bob)
|
||||
expect(conversation.last_status).to eq status
|
||||
expect(conversation.status_ids).to eq [status.id]
|
||||
end
|
||||
|
||||
it 'appends to old record when there is a match' do
|
||||
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
||||
conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
||||
|
||||
status = Fabricate(:status, account: bob, visibility: :direct, thread: last_status)
|
||||
status.mentions.create(account: alice)
|
||||
|
||||
new_conversation = AccountConversation.add_status(alice, status)
|
||||
|
||||
expect(new_conversation.id).to eq conversation.id
|
||||
expect(new_conversation.participant_accounts).to include(bob)
|
||||
expect(new_conversation.last_status).to eq status
|
||||
expect(new_conversation.status_ids).to eq [last_status.id, status.id]
|
||||
end
|
||||
|
||||
it 'creates new record when new participants are added' do
|
||||
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
||||
conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
||||
|
||||
status = Fabricate(:status, account: bob, visibility: :direct, thread: last_status)
|
||||
status.mentions.create(account: alice)
|
||||
status.mentions.create(account: mark)
|
||||
|
||||
new_conversation = AccountConversation.add_status(alice, status)
|
||||
|
||||
expect(new_conversation.id).to_not eq conversation.id
|
||||
expect(new_conversation.participant_accounts).to include(bob, mark)
|
||||
expect(new_conversation.last_status).to eq status
|
||||
expect(new_conversation.status_ids).to eq [status.id]
|
||||
end
|
||||
end
|
||||
|
||||
describe '.remove_status' do
|
||||
it 'updates last status to a previous value' do
|
||||
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
||||
status = Fabricate(:status, account: alice, visibility: :direct)
|
||||
conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [status.id, last_status.id])
|
||||
last_status.mentions.create(account: bob)
|
||||
last_status.destroy!
|
||||
conversation.reload
|
||||
expect(conversation.last_status).to eq status
|
||||
expect(conversation.status_ids).to eq [status.id]
|
||||
end
|
||||
|
||||
it 'removes the record if no other statuses are referenced' do
|
||||
last_status = Fabricate(:status, account: alice, visibility: :direct)
|
||||
conversation = AccountConversation.create!(account: alice, conversation: last_status.conversation, participant_account_ids: [bob.id], status_ids: [last_status.id])
|
||||
last_status.mentions.create(account: bob)
|
||||
last_status.destroy!
|
||||
expect(AccountConversation.where(id: conversation.id).count).to eq 0
|
||||
end
|
||||
end
|
||||
end
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
||||
|
||||
describe AccountFilter do
|
||||
describe 'with empty params' do
|
||||
it 'defaults to alphabetic account list' do
|
||||
it 'defaults to recent account list' do
|
||||
filter = described_class.new({})
|
||||
|
||||
expect(filter.results).to eq Account.alphabetic
|
||||
expect(filter.results).to eq Account.recent
|
||||
end
|
||||
end
|
||||
|
||||
@ -60,7 +60,7 @@ describe AccountFilter do
|
||||
end
|
||||
|
||||
describe 'that call account methods' do
|
||||
%i(local remote silenced recent suspended).each do |option|
|
||||
%i(local remote silenced alphabetic suspended).each do |option|
|
||||
it "delegates the #{option} option" do
|
||||
allow(Account).to receive(option).and_return(Account.none)
|
||||
filter = described_class.new({ option => true })
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountModerationNote, type: :model do
|
||||
|
||||
end
|
||||
|
@ -275,7 +275,7 @@ RSpec.describe Account, type: :model do
|
||||
|
||||
subject { Fabricate(:account) }
|
||||
|
||||
context 'when the status is a reblog of another status'do
|
||||
context 'when the status is a reblog of another status' do
|
||||
let(:original_reblog) do
|
||||
author = Fabricate(:account, username: 'original_reblogger')
|
||||
Fabricate(:status, reblog: original_status, account: author)
|
||||
@ -559,7 +559,7 @@ RSpec.describe Account, type: :model do
|
||||
end
|
||||
|
||||
context 'when is local' do
|
||||
it 'is invalid if the username is not unique in case-insensitive comparsion among local accounts' do
|
||||
it 'is invalid if the username is not unique in case-insensitive comparison among local accounts' do
|
||||
account_1 = Fabricate(:account, username: 'the_doctor')
|
||||
account_2 = Fabricate.build(:account, username: 'the_Doctor')
|
||||
account_2.valid?
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::ActionLog, type: :model do
|
||||
|
||||
end
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Backup, type: :model do
|
||||
|
||||
end
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ConversationMute, type: :model do
|
||||
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ RSpec.describe CustomEmoji, type: :model do
|
||||
describe '#search' do
|
||||
let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) }
|
||||
|
||||
subject { described_class.search(search_term) }
|
||||
subject { described_class.search(search_term) }
|
||||
|
||||
context 'shortcode is exact' do
|
||||
let(:shortcode) { 'blobpats' }
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CustomFilter, type: :model do
|
||||
|
||||
end
|
||||
|
@ -23,6 +23,20 @@ RSpec.describe Follow, type: :model do
|
||||
follow.valid?
|
||||
expect(follow).to model_have_error_on_field(:target_account)
|
||||
end
|
||||
|
||||
it 'is invalid if account already follows too many people' do
|
||||
alice.update(following_count: FollowLimitValidator::LIMIT)
|
||||
|
||||
expect(subject).to_not be_valid
|
||||
expect(subject).to model_have_error_on_field(:base)
|
||||
end
|
||||
|
||||
it 'is valid if account is only on the brink of following too many people' do
|
||||
alice.update(following_count: FollowLimitValidator::LIMIT - 1)
|
||||
|
||||
expect(subject).to be_valid
|
||||
expect(subject).to_not model_have_error_on_field(:base)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'recent' do
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ListAccount, type: :model do
|
||||
|
||||
end
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe List, type: :model do
|
||||
|
||||
end
|
||||
|
@ -131,7 +131,7 @@ RSpec.describe MediaAttachment, type: :model do
|
||||
expect(media.file.meta["original"]["aspect"]).to eq 1.5
|
||||
expect(media.file.meta["small"]["width"]).to eq 490
|
||||
expect(media.file.meta["small"]["height"]).to eq 327
|
||||
expect(media.file.meta["small"]["aspect"]).to eq 490.0/327
|
||||
expect(media.file.meta["small"]["aspect"]).to eq 490.0 / 327
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Mute, type: :model do
|
||||
|
||||
end
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PreviewCard, type: :model do
|
||||
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ RSpec.describe RemoteFollow do
|
||||
subject { remote_follow.valid? }
|
||||
|
||||
context 'attrs with acct' do
|
||||
let(:attrs) { { acct: 'gargron@quitter.no' }}
|
||||
let(:attrs) { { acct: 'gargron@quitter.no' } }
|
||||
|
||||
it do
|
||||
is_expected.to be true
|
||||
@ -42,7 +42,7 @@ RSpec.describe RemoteFollow do
|
||||
end
|
||||
|
||||
context 'attrs without acct' do
|
||||
let(:attrs) { { } }
|
||||
let(:attrs) { {} }
|
||||
|
||||
it do
|
||||
is_expected.to be false
|
||||
|
@ -154,7 +154,7 @@ RSpec.describe Status, type: :model do
|
||||
|
||||
describe '#target' do
|
||||
it 'returns nil if the status is self-contained' do
|
||||
expect(subject.target).to be_nil
|
||||
expect(subject.target).to be_nil
|
||||
end
|
||||
|
||||
it 'returns nil if the status is a reply' do
|
||||
|
@ -18,7 +18,7 @@ RSpec.describe Subscription, type: :model do
|
||||
end
|
||||
|
||||
describe 'lease_seconds' do
|
||||
it 'returns the time remaing until expiration' do
|
||||
it 'returns the time remaining until expiration' do
|
||||
datetime = 1.day.from_now
|
||||
subscription = Subscription.new(expires_at: datetime)
|
||||
travel_to(datetime - 12.hours) do
|
||||
|
@ -67,7 +67,7 @@ RSpec.describe User, type: :model do
|
||||
describe 'confirmed' do
|
||||
it 'returns an array of users who are confirmed' do
|
||||
user_1 = Fabricate(:user, confirmed_at: nil)
|
||||
user_2 = Fabricate(:user, confirmed_at: Time.now)
|
||||
user_2 = Fabricate(:user, confirmed_at: Time.zone.now)
|
||||
expect(User.confirmed).to match_array([user_2])
|
||||
end
|
||||
end
|
||||
@ -254,7 +254,7 @@ RSpec.describe User, type: :model do
|
||||
|
||||
it_behaves_like 'Settings-extended' do
|
||||
def create!
|
||||
User.create!(account: Fabricate(:account), email: 'foo@mastodon.space', password: 'abcd1234' )
|
||||
User.create!(account: Fabricate(:account), email: 'foo@mastodon.space', password: 'abcd1234')
|
||||
end
|
||||
|
||||
def fabricate
|
||||
|
@ -1,5 +1,4 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Web::Setting, type: :model do
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user