Skip to content

Commit

Permalink
Speed-up on MoveWorker spec (mastodon#25528)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored and audiodude committed Oct 23, 2023
1 parent 34e6f0b commit 5b3b187
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions spec/workers/move_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,31 @@
end

shared_examples 'block and mute handling' do
it 'makes blocks carry over and add a note' do
it 'makes blocks and mutes carry over and adds a note' do
subject.perform(source_account.id, target_account.id)

expect(block_service).to have_received(:call).with(blocking_account, target_account)
expect(AccountNote.find_by(account: blocking_account, target_account: target_account).comment).to include(source_account.acct)
end

it 'makes mutes carry over and add a note' do
subject.perform(source_account.id, target_account.id)
expect(muting_account.muting?(target_account)).to be true
expect(AccountNote.find_by(account: muting_account, target_account: target_account).comment).to include(source_account.acct)
end
end

shared_examples 'followers count handling' do
it 'updates the source account followers count' do
it 'updates the source and target account followers counts' do
subject.perform(source_account.id, target_account.id)
expect(source_account.reload.followers_count).to eq(source_account.passive_relationships.count)
end

it 'updates the target account followers count' do
subject.perform(source_account.id, target_account.id)
expect(source_account.reload.followers_count).to eq(source_account.passive_relationships.count)
expect(target_account.reload.followers_count).to eq(target_account.passive_relationships.count)
end
end

shared_examples 'lists handling' do
it 'puts the new account on the list' do
it 'puts the new account on the list and makes valid lists', sidekiq: :inline do
subject.perform(source_account.id, target_account.id)
expect(list.accounts.include?(target_account)).to be true
end

it 'does not create invalid list memberships' do
subject.perform(source_account.id, target_account.id)
expect(list.accounts.include?(target_account)).to be true
expect(ListAccount.all).to all be_valid
end
end
Expand Down

0 comments on commit 5b3b187

Please sign in to comment.