diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 13683e404e0..90e7e40578d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,12 +44,3 @@ def serialized_record_json(record, serializer, adapter: nil, options: {}) ).to_json ) end - -def expect_push_bulk_to_match(klass, matcher) - allow(Sidekiq::Client).to receive(:push_bulk) - yield - expect(Sidekiq::Client).to have_received(:push_bulk).with(hash_including({ - 'class' => klass, - 'args' => matcher, - })) -end diff --git a/spec/workers/activitypub/distribute_poll_update_worker_spec.rb b/spec/workers/activitypub/distribute_poll_update_worker_spec.rb index 9ff4731f96a..d04b2331a61 100644 --- a/spec/workers/activitypub/distribute_poll_update_worker_spec.rb +++ b/spec/workers/activitypub/distribute_poll_update_worker_spec.rb @@ -16,9 +16,10 @@ RSpec.describe ActivityPub::DistributePollUpdateWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), account.id, 'http://example.com']]) do - subject.perform(status.id) - end + subject.perform(status.id) + + expect(ActivityPub::DeliveryWorker) + .to have_enqueued_sidekiq_job(match_json_values(type: 'Update'), account.id, 'http://example.com') end end end diff --git a/spec/workers/activitypub/distribution_worker_spec.rb b/spec/workers/activitypub/distribution_worker_spec.rb index 1551ba63ba8..738ba44be62 100644 --- a/spec/workers/activitypub/distribution_worker_spec.rb +++ b/spec/workers/activitypub/distribution_worker_spec.rb @@ -19,9 +19,10 @@ RSpec.describe ActivityPub::DistributionWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do - subject.perform(status.id) - end + subject.perform(status.id) + + expect(ActivityPub::DeliveryWorker) + .to have_enqueued_sidekiq_job(match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything) end end @@ -31,9 +32,10 @@ RSpec.describe ActivityPub::DistributionWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do - subject.perform(status.id) - end + subject.perform(status.id) + + expect(ActivityPub::DeliveryWorker) + .to have_enqueued_sidekiq_job(match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything) end end @@ -46,9 +48,10 @@ RSpec.describe ActivityPub::DistributionWorker do end it 'delivers to mentioned accounts' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'https://foo.bar/inbox', anything]]) do - subject.perform(status.id) - end + subject.perform(status.id) + + expect(ActivityPub::DeliveryWorker) + .to have_enqueued_sidekiq_job(match_json_values(type: 'Create'), status.account.id, 'https://foo.bar/inbox', anything) end end @@ -67,9 +70,10 @@ RSpec.describe ActivityPub::DistributionWorker do object: ActivityPub::TagManager.instance.uri_for(status), } - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(expected_json), reblog.account.id, 'http://example.com', anything]]) do - subject.perform(reblog.id) - end + subject.perform(reblog.id) + + expect(ActivityPub::DeliveryWorker) + .to have_enqueued_sidekiq_job(match_json_values(expected_json), reblog.account.id, 'http://example.com', anything) end end @@ -86,9 +90,10 @@ RSpec.describe ActivityPub::DistributionWorker do }), } - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(expected_json), reblog.account.id, 'http://example.com', anything]]) do - subject.perform(reblog.id) - end + subject.perform(reblog.id) + + expect(ActivityPub::DeliveryWorker) + .to have_enqueued_sidekiq_job(match_json_values(expected_json), reblog.account.id, 'http://example.com', anything) end end end diff --git a/spec/workers/activitypub/move_distribution_worker_spec.rb b/spec/workers/activitypub/move_distribution_worker_spec.rb index 63396834de0..bde0449186f 100644 --- a/spec/workers/activitypub/move_distribution_worker_spec.rb +++ b/spec/workers/activitypub/move_distribution_worker_spec.rb @@ -16,16 +16,11 @@ RSpec.describe ActivityPub::MoveDistributionWorker do end it 'delivers to followers and known blockers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, expected_migration_deliveries) do - subject.perform(migration.id) - end - end + subject.perform(migration.id) - def expected_migration_deliveries - [ - [match_json_values(type: 'Move'), migration.account.id, 'http://example.com'], - [match_json_values(type: 'Move'), migration.account.id, 'http://example2.com'], - ] + expect(ActivityPub::DeliveryWorker) + .to have_enqueued_sidekiq_job(match_json_values(type: 'Move'), migration.account.id, 'http://example.com') + .and have_enqueued_sidekiq_job(match_json_values(type: 'Move'), migration.account.id, 'http://example2.com') end end end diff --git a/spec/workers/activitypub/update_distribution_worker_spec.rb b/spec/workers/activitypub/update_distribution_worker_spec.rb index 7d786063988..b156c329e84 100644 --- a/spec/workers/activitypub/update_distribution_worker_spec.rb +++ b/spec/workers/activitypub/update_distribution_worker_spec.rb @@ -14,9 +14,10 @@ RSpec.describe ActivityPub::UpdateDistributionWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), account.id, 'http://example.com', anything]]) do - subject.perform(account.id) - end + subject.perform(account.id) + + expect(ActivityPub::DeliveryWorker) + .to have_enqueued_sidekiq_job(match_json_values(type: 'Update'), account.id, 'http://example.com', anything) end end end