Combine examples to reduce factories in specs (#33841)
This commit is contained in:
parent
aff2b11394
commit
23a0d91126
7 changed files with 10 additions and 42 deletions
|
@ -33,15 +33,11 @@ RSpec.describe PollExpirationNotifyWorker do
|
|||
end
|
||||
|
||||
context 'when poll is local' do
|
||||
it 'notifies voters' do
|
||||
it 'notifies voters, owner, and local voters' do
|
||||
expect(ActivityPub::DistributePollUpdateWorker).to have_enqueued_sidekiq_job(poll.status.id)
|
||||
end
|
||||
|
||||
it 'notifies owner' do
|
||||
expect(LocalNotificationWorker).to have_enqueued_sidekiq_job(poll.account.id, poll.id, 'Poll', 'poll')
|
||||
end
|
||||
|
||||
it 'notifies local voters' do
|
||||
expect(LocalNotificationWorker).to have_enqueued_sidekiq_job(poll_vote.account.id, poll.id, 'Poll', 'poll')
|
||||
end
|
||||
end
|
||||
|
@ -49,15 +45,11 @@ RSpec.describe PollExpirationNotifyWorker do
|
|||
context 'when poll is remote' do
|
||||
let(:remote?) { true }
|
||||
|
||||
it 'does not notify remote voters' do
|
||||
it 'does not notify remote voters or owner, does notify local voters' do
|
||||
expect(ActivityPub::DistributePollUpdateWorker).to_not have_enqueued_sidekiq_job(poll.status.id)
|
||||
end
|
||||
|
||||
it 'does not notify owner' do
|
||||
expect(LocalNotificationWorker).to_not have_enqueued_sidekiq_job(poll.account.id, poll.id, 'Poll', 'poll')
|
||||
end
|
||||
|
||||
it 'notifies local voters' do
|
||||
expect(LocalNotificationWorker).to have_enqueued_sidekiq_job(poll_vote.account.id, poll.id, 'Poll', 'poll')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,11 +13,9 @@ RSpec.describe PublishScheduledStatusWorker do
|
|||
end
|
||||
|
||||
context 'when the account is not disabled' do
|
||||
it 'creates a status' do
|
||||
it 'creates a status and removes scheduled record' do
|
||||
expect(scheduled_status.account.statuses.first.text).to eq 'Hello world, future!'
|
||||
end
|
||||
|
||||
it 'removes the scheduled status' do
|
||||
expect(ScheduledStatus.find_by(id: scheduled_status.id)).to be_nil
|
||||
end
|
||||
end
|
||||
|
@ -25,11 +23,9 @@ RSpec.describe PublishScheduledStatusWorker do
|
|||
context 'when the account is disabled' do
|
||||
let(:scheduled_status) { Fabricate(:scheduled_status, account: Fabricate(:account, user: Fabricate(:user, disabled: true))) }
|
||||
|
||||
it 'does not create a status' do
|
||||
it 'does not create a status and removes scheduled record' do
|
||||
expect(Status.count).to eq 0
|
||||
end
|
||||
|
||||
it 'removes the scheduled status' do
|
||||
expect(ScheduledStatus.find_by(id: scheduled_status.id)).to be_nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,14 +18,11 @@ RSpec.describe UnfollowFollowWorker do
|
|||
let(:show_reblogs) { true }
|
||||
|
||||
describe 'perform' do
|
||||
it 'unfollows source account and follows target account' do
|
||||
it 'unfollows source account and follows target account and preserves show_reblogs' do
|
||||
subject.perform(local_follower.id, source_account.id, target_account.id)
|
||||
expect(local_follower.following?(source_account)).to be false
|
||||
expect(local_follower.following?(target_account)).to be true
|
||||
end
|
||||
|
||||
it 'preserves show_reblogs' do
|
||||
subject.perform(local_follower.id, source_account.id, target_account.id)
|
||||
expect(Follow.find_by(account: local_follower, target_account: target_account).show_reblogs?).to be show_reblogs
|
||||
end
|
||||
end
|
||||
|
@ -35,14 +32,11 @@ RSpec.describe UnfollowFollowWorker do
|
|||
let(:show_reblogs) { false }
|
||||
|
||||
describe 'perform' do
|
||||
it 'unfollows source account and follows target account' do
|
||||
it 'unfollows source account and follows target account and preserves show_reblogs' do
|
||||
subject.perform(local_follower.id, source_account.id, target_account.id)
|
||||
expect(local_follower.following?(source_account)).to be false
|
||||
expect(local_follower.following?(target_account)).to be true
|
||||
end
|
||||
|
||||
it 'preserves show_reblogs' do
|
||||
subject.perform(local_follower.id, source_account.id, target_account.id)
|
||||
expect(Follow.find_by(account: local_follower, target_account: target_account).show_reblogs?).to be show_reblogs
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue