From 49e2772064ce6e3df52a6c0ef498e6b10f6cd819 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 7 Nov 2023 04:46:28 -0500 Subject: [PATCH] Fix `RSpec/MessageSpies` cop (#27751) --- .rubocop_todo.yml | 18 ----------- .../admin/accounts_controller_spec.rb | 29 ++++++++--------- .../account_moderation_notes_helper_spec.rb | 8 +++-- spec/lib/webfinger_resource_spec.rb | 6 +++- spec/models/admin/account_action_spec.rb | 6 ++-- spec/models/concerns/remotable_spec.rb | 32 +++++++++++++------ spec/models/follow_request_spec.rb | 11 +++++-- spec/models/identity_spec.rb | 5 ++- spec/models/session_activation_spec.rb | 8 +++-- spec/models/setting_spec.rb | 15 +++++++-- .../activitypub/fetch_replies_service_spec.rb | 30 +++++++++++++---- .../process_collection_service_spec.rb | 32 +++++++++++++------ spec/spec_helper.rb | 4 ++- .../status_length_validator_spec.rb | 10 ++++-- .../distribute_poll_update_worker_spec.rb | 5 +-- .../activitypub/distribution_worker_spec.rb | 15 +++++---- .../move_distribution_worker_spec.rb | 5 +-- .../status_update_distribution_worker_spec.rb | 12 +++---- .../update_distribution_worker_spec.rb | 5 +-- 19 files changed, 162 insertions(+), 94 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2d191b9f3..7ab81f090 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -147,24 +147,6 @@ RSpec/MessageChain: - 'spec/models/session_activation_spec.rb' - 'spec/models/setting_spec.rb' -# Configuration parameters: EnforcedStyle. -# SupportedStyles: have_received, receive -RSpec/MessageSpies: - Exclude: - - 'spec/controllers/admin/accounts_controller_spec.rb' - - 'spec/helpers/admin/account_moderation_notes_helper_spec.rb' - - 'spec/lib/webfinger_resource_spec.rb' - - 'spec/models/admin/account_action_spec.rb' - - 'spec/models/concerns/remotable_spec.rb' - - 'spec/models/follow_request_spec.rb' - - 'spec/models/identity_spec.rb' - - 'spec/models/session_activation_spec.rb' - - 'spec/models/setting_spec.rb' - - 'spec/services/activitypub/fetch_replies_service_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/validators/status_length_validator_spec.rb' - RSpec/MultipleExpectations: Max: 8 diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index b57ec6714..ba03ec85a 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -18,21 +18,8 @@ RSpec.describe Admin::AccountsController do end it 'filters with parameters' do - new = AccountFilter.method(:new) - - expect(AccountFilter).to receive(:new) do |params| - h = params.to_h - - expect(h[:origin]).to eq 'local' - expect(h[:by_domain]).to eq 'domain' - expect(h[:status]).to eq 'active' - expect(h[:username]).to eq 'username' - expect(h[:display_name]).to eq 'display name' - expect(h[:email]).to eq 'local-part@domain' - expect(h[:ip]).to eq '0.0.0.42' - - new.call({}) - end + account_filter = instance_double(AccountFilter, results: Account.all) + allow(AccountFilter).to receive(:new).and_return(account_filter) get :index, params: { origin: 'local', @@ -43,6 +30,18 @@ RSpec.describe Admin::AccountsController do email: 'local-part@domain', ip: '0.0.0.42', } + + expect(AccountFilter).to have_received(:new) do |params| + h = params.to_h + + expect(h[:origin]).to eq 'local' + expect(h[:by_domain]).to eq 'domain' + expect(h[:status]).to eq 'active' + expect(h[:username]).to eq 'username' + expect(h[:display_name]).to eq 'display name' + expect(h[:email]).to eq 'local-part@domain' + expect(h[:ip]).to eq '0.0.0.42' + end end it 'paginates accounts' do diff --git a/spec/helpers/admin/account_moderation_notes_helper_spec.rb b/spec/helpers/admin/account_moderation_notes_helper_spec.rb index 6386f07ac..91bf4ab6f 100644 --- a/spec/helpers/admin/account_moderation_notes_helper_spec.rb +++ b/spec/helpers/admin/account_moderation_notes_helper_spec.rb @@ -18,13 +18,15 @@ RSpec.describe Admin::AccountModerationNotesHelper do let(:account) { Fabricate(:account) } it 'calls #link_to' do - expect(helper).to receive(:link_to).with( + allow(helper).to receive(:link_to) + + helper.admin_account_link_to(account) + + expect(helper).to have_received(:link_to).with( admin_account_path(account.id), class: name_tag_classes(account), title: account.acct ) - - helper.admin_account_link_to(account) end end end diff --git a/spec/lib/webfinger_resource_spec.rb b/spec/lib/webfinger_resource_spec.rb index 558a31892..0e2bdcb71 100644 --- a/spec/lib/webfinger_resource_spec.rb +++ b/spec/lib/webfinger_resource_spec.rb @@ -29,12 +29,16 @@ describe WebfingerResource do allow(recognized).to receive(:[]).with(:username).and_return('alice') allow(recognized).to receive(:[]).with(:action).and_return('create') - expect(Rails.application.routes).to receive(:recognize_path).with(resource).and_return(recognized).at_least(:once) + allow(Rails.application.routes).to receive(:recognize_path).with(resource).and_return(recognized) expect do described_class.new(resource).username end.to raise_error(ActiveRecord::RecordNotFound) expect(recognized).to have_received(:[]).exactly(3).times + + expect(Rails.application.routes).to have_received(:recognize_path) + .with(resource) + .at_least(:once) end it 'raises with a string that doesnt start with URL' do diff --git a/spec/models/admin/account_action_spec.rb b/spec/models/admin/account_action_spec.rb index b47561dd4..604fe7318 100644 --- a/spec/models/admin/account_action_spec.rb +++ b/spec/models/admin/account_action_spec.rb @@ -78,13 +78,15 @@ RSpec.describe Admin::AccountAction do end it 'calls process_email!' do - expect(account_action).to receive(:process_email!) + allow(account_action).to receive(:process_email!) subject + expect(account_action).to have_received(:process_email!) end it 'calls process_reports!' do - expect(account_action).to receive(:process_reports!) + allow(account_action).to receive(:process_reports!) subject + expect(account_action).to have_received(:process_reports!) end end diff --git a/spec/models/concerns/remotable_spec.rb b/spec/models/concerns/remotable_spec.rb index b2aa56a70..6413b6f46 100644 --- a/spec/models/concerns/remotable_spec.rb +++ b/spec/models/concerns/remotable_spec.rb @@ -120,8 +120,11 @@ RSpec.describe Remotable do end it 'does not try to write attribute' do - expect(foo).to_not receive('[]=').with(attribute_name, url) + allow(foo).to receive('[]=').with(attribute_name, url) + foo.hoge_remote_url = url + + expect(foo).to_not have_received('[]=').with(attribute_name, url) end end @@ -131,8 +134,11 @@ RSpec.describe Remotable do end it 'does not try to write attribute' do - expect(foo).to receive('[]=').with(attribute_name, url) + allow(foo).to receive('[]=').with(attribute_name, url) + foo.hoge_remote_url = url + + expect(foo).to have_received('[]=').with(attribute_name, url) end end @@ -146,10 +152,13 @@ RSpec.describe Remotable do let(:code) { 500 } it 'does not assign file' do - expect(foo).to_not receive(:public_send).with("#{hoge}=", any_args) - expect(foo).to_not receive(:public_send).with("#{hoge}_file_name=", any_args) + allow(foo).to receive(:public_send) + allow(foo).to receive(:public_send) foo.hoge_remote_url = url + + expect(foo).to_not have_received(:public_send).with("#{hoge}=", any_args) + expect(foo).to_not have_received(:public_send).with("#{hoge}_file_name=", any_args) end end @@ -165,13 +174,13 @@ RSpec.describe Remotable do allow(ResponseWithLimit).to receive(:new).with(anything, anything).and_return(response_with_limit) - expect(foo).to receive(:public_send).with("download_#{hoge}!", url) - + allow(foo).to receive(:public_send) foo.hoge_remote_url = url + expect(foo).to have_received(:public_send).with("download_#{hoge}!", url) - expect(foo).to receive(:public_send).with("#{hoge}=", response_with_limit) - + allow(foo).to receive(:public_send) foo.download_hoge!(url) + expect(foo).to have_received(:public_send).with("#{hoge}=", response_with_limit) end end end @@ -193,10 +202,13 @@ RSpec.describe Remotable do let(:error_class) { error_class } it 'calls Rails.logger.debug' do - expect(Rails.logger).to receive(:debug) do |&block| + allow(Rails.logger).to receive(:debug) + + foo.hoge_remote_url = url + + expect(Rails.logger).to have_received(:debug) do |&block| expect(block.call).to match(/^Error fetching remote #{hoge}: /) end - foo.hoge_remote_url = url end end end diff --git a/spec/models/follow_request_spec.rb b/spec/models/follow_request_spec.rb index e41374785..9cccb8290 100644 --- a/spec/models/follow_request_spec.rb +++ b/spec/models/follow_request_spec.rb @@ -21,12 +21,17 @@ RSpec.describe FollowRequest do end it 'calls Account#follow!, MergeWorker.perform_async, and #destroy!' do - expect(account).to receive(:follow!).with(target_account, reblogs: true, notify: false, uri: follow_request.uri, languages: nil, bypass_limit: true) do + allow(account).to receive(:follow!) do account.active_relationships.create!(target_account: target_account) end - expect(MergeWorker).to receive(:perform_async).with(target_account.id, account.id) - expect(follow_request).to receive(:destroy!) + allow(MergeWorker).to receive(:perform_async) + allow(follow_request).to receive(:destroy!) + follow_request.authorize! + + expect(account).to have_received(:follow!).with(target_account, reblogs: true, notify: false, uri: follow_request.uri, languages: nil, bypass_limit: true) + expect(MergeWorker).to have_received(:perform_async).with(target_account.id, account.id) + expect(follow_request).to have_received(:destroy!) end it 'correctly passes show_reblogs when true' do diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb index 2fca1e1c1..702245444 100644 --- a/spec/models/identity_spec.rb +++ b/spec/models/identity_spec.rb @@ -7,8 +7,11 @@ RSpec.describe Identity do let(:auth) { Fabricate(:identity, user: Fabricate(:user)) } it 'calls .find_or_create_by' do - expect(described_class).to receive(:find_or_create_by).with(uid: auth.uid, provider: auth.provider) + allow(described_class).to receive(:find_or_create_by) + described_class.find_for_oauth(auth) + + expect(described_class).to have_received(:find_or_create_by).with(uid: auth.uid, provider: auth.provider) end it 'returns an instance of Identity' do diff --git a/spec/models/session_activation_spec.rb b/spec/models/session_activation_spec.rb index 75842e25b..4012d46fd 100644 --- a/spec/models/session_activation_spec.rb +++ b/spec/models/session_activation_spec.rb @@ -74,9 +74,13 @@ RSpec.describe SessionActivation do let(:options) { { user: Fabricate(:user), session_id: '1' } } it 'calls create! and purge_old' do - expect(described_class).to receive(:create!).with(**options) - expect(described_class).to receive(:purge_old) + allow(described_class).to receive(:create!).with(**options) + allow(described_class).to receive(:purge_old) + described_class.activate(**options) + + expect(described_class).to have_received(:create!).with(**options) + expect(described_class).to have_received(:purge_old) end it 'returns an instance of SessionActivation' do diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 5ed5c5d76..5f53ee563 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -23,8 +23,11 @@ RSpec.describe Setting do let(:rails_initialized) { false } it 'calls RailsSettings::Base#[]' do - expect(RailsSettings::Base).to receive(:[]).with(key) + allow(RailsSettings::Base).to receive(:[]).with(key) + described_class[key] + + expect(RailsSettings::Base).to have_received(:[]).with(key) end end @@ -38,8 +41,11 @@ RSpec.describe Setting do let(:cache_value) { 'cache-value' } it 'calls not RailsSettings::Base#[]' do - expect(RailsSettings::Base).to_not receive(:[]).with(key) + allow(RailsSettings::Base).to receive(:[]).with(key) + described_class[key] + + expect(RailsSettings::Base).to_not have_received(:[]).with(key) end context 'when Rails.cache does not exists' do @@ -56,8 +62,11 @@ RSpec.describe Setting do let(:records) { [Fabricate(:setting, var: key, value: nil)] } it 'calls RailsSettings::Settings.object' do - expect(RailsSettings::Settings).to receive(:object).with(key) + allow(RailsSettings::Settings).to receive(:object).with(key) + described_class[key] + + expect(RailsSettings::Settings).to have_received(:object).with(key) end context 'when RailsSettings::Settings.object returns truthy' do diff --git a/spec/services/activitypub/fetch_replies_service_spec.rb b/spec/services/activitypub/fetch_replies_service_spec.rb index bf8e29676..d7716dd4e 100644 --- a/spec/services/activitypub/fetch_replies_service_spec.rb +++ b/spec/services/activitypub/fetch_replies_service_spec.rb @@ -36,8 +36,11 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do context 'when the payload is a Collection with inlined replies' do context 'when passing the collection itself' do it 'spawns workers for up to 5 replies on the same server' do - expect(FetchReplyWorker).to receive(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) + allow(FetchReplyWorker).to receive(:push_bulk) + subject.call(status, payload) + + expect(FetchReplyWorker).to have_received(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) end end @@ -47,8 +50,11 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do end it 'spawns workers for up to 5 replies on the same server' do - expect(FetchReplyWorker).to receive(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) + allow(FetchReplyWorker).to receive(:push_bulk) + subject.call(status, collection_uri) + + expect(FetchReplyWorker).to have_received(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) end end end @@ -65,8 +71,11 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do context 'when passing the collection itself' do it 'spawns workers for up to 5 replies on the same server' do - expect(FetchReplyWorker).to receive(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) + allow(FetchReplyWorker).to receive(:push_bulk) + subject.call(status, payload) + + expect(FetchReplyWorker).to have_received(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) end end @@ -76,8 +85,11 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do end it 'spawns workers for up to 5 replies on the same server' do - expect(FetchReplyWorker).to receive(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) + allow(FetchReplyWorker).to receive(:push_bulk) + subject.call(status, collection_uri) + + expect(FetchReplyWorker).to have_received(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) end end end @@ -98,8 +110,11 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do context 'when passing the collection itself' do it 'spawns workers for up to 5 replies on the same server' do - expect(FetchReplyWorker).to receive(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) + allow(FetchReplyWorker).to receive(:push_bulk) + subject.call(status, payload) + + expect(FetchReplyWorker).to have_received(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) end end @@ -109,8 +124,11 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do end it 'spawns workers for up to 5 replies on the same server' do - expect(FetchReplyWorker).to receive(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) + allow(FetchReplyWorker).to receive(:push_bulk) + subject.call(status, collection_uri) + + expect(FetchReplyWorker).to have_received(:push_bulk).with(['http://example.com/self-reply-1', 'http://example.com/self-reply-2', 'http://example.com/self-reply-3', 'http://example.com/self-reply-4', 'http://example.com/self-reply-5']) end end end diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index 02011afea..ede9f5c04 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -41,8 +41,11 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do end it 'does not process payload' do - expect(ActivityPub::Activity).to_not receive(:factory) + allow(ActivityPub::Activity).to receive(:factory) + subject.call(json, actor) + + expect(ActivityPub::Activity).to_not have_received(:factory) end end end @@ -59,8 +62,11 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do end it 'processes the payload' do - expect(ActivityPub::Activity).to receive(:factory) + allow(ActivityPub::Activity).to receive(:factory) + subject.call(json, actor) + + expect(ActivityPub::Activity).to have_received(:factory) end end end @@ -71,27 +77,33 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do it 'does not process payload if no signature exists' do allow_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil) - expect(ActivityPub::Activity).to_not receive(:factory) + allow(ActivityPub::Activity).to receive(:factory) subject.call(json, forwarder) + + expect(ActivityPub::Activity).to_not have_received(:factory) end it 'processes payload with actor if valid signature exists' do payload['signature'] = { 'type' => 'RsaSignature2017' } allow_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(actor) - expect(ActivityPub::Activity).to receive(:factory).with(instance_of(Hash), actor, instance_of(Hash)) + allow(ActivityPub::Activity).to receive(:factory).with(instance_of(Hash), actor, instance_of(Hash)) subject.call(json, forwarder) + + expect(ActivityPub::Activity).to have_received(:factory).with(instance_of(Hash), actor, instance_of(Hash)) end it 'does not process payload if invalid signature exists' do payload['signature'] = { 'type' => 'RsaSignature2017' } allow_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil) - expect(ActivityPub::Activity).to_not receive(:factory) + allow(ActivityPub::Activity).to receive(:factory) subject.call(json, forwarder) + + expect(ActivityPub::Activity).to_not have_received(:factory) end context 'when receiving a fabricated status' do @@ -225,7 +237,11 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do end it 'does not process forged payload' do - expect(ActivityPub::Activity).to_not receive(:factory).with( + allow(ActivityPub::Activity).to receive(:factory) + + subject.call(json, forwarder) + + expect(ActivityPub::Activity).to_not have_received(:factory).with( hash_including( 'object' => hash_including( 'id' => 'https://example.com/users/bob/fake-status' @@ -235,7 +251,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do anything ) - expect(ActivityPub::Activity).to_not receive(:factory).with( + expect(ActivityPub::Activity).to_not have_received(:factory).with( hash_including( 'object' => hash_including( 'content' => '

puck was here

' @@ -245,8 +261,6 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do anything ) - subject.call(json, forwarder) - expect(Status.where(uri: 'https://example.com/users/bob/fake-status').exists?).to be false end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6ff0a8f84..4c4e31dd2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -53,7 +53,9 @@ def json_str_to_hash(str) end def expect_push_bulk_to_match(klass, matcher) - expect(Sidekiq::Client).to receive(:push_bulk).with(hash_including({ + allow(Sidekiq::Client).to receive(:push_bulk) + yield + expect(Sidekiq::Client).to have_received(:push_bulk).with(hash_including({ 'class' => klass, 'args' => matcher, })) diff --git a/spec/validators/status_length_validator_spec.rb b/spec/validators/status_length_validator_spec.rb index 98ea15e03..06625917b 100644 --- a/spec/validators/status_length_validator_spec.rb +++ b/spec/validators/status_length_validator_spec.rb @@ -6,14 +6,20 @@ describe StatusLengthValidator do describe '#validate' do it 'does not add errors onto remote statuses' do status = instance_double(Status, local?: false) + allow(status).to receive(:errors) + subject.validate(status) - expect(status).to_not receive(:errors) + + expect(status).to_not have_received(:errors) end it 'does not add errors onto local reblogs' do status = instance_double(Status, local?: false, reblog?: true) + allow(status).to receive(:errors) + subject.validate(status) - expect(status).to_not receive(:errors) + + expect(status).to_not have_received(:errors) end it 'adds an error when content warning is over 500 characters' do diff --git a/spec/workers/activitypub/distribute_poll_update_worker_spec.rb b/spec/workers/activitypub/distribute_poll_update_worker_spec.rb index 0bdbf6390..afe2b291f 100644 --- a/spec/workers/activitypub/distribute_poll_update_worker_spec.rb +++ b/spec/workers/activitypub/distribute_poll_update_worker_spec.rb @@ -16,8 +16,9 @@ describe ActivityPub::DistributePollUpdateWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), account.id, 'http://example.com']]) - subject.perform(status.id) + expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), account.id, 'http://example.com']]) do + subject.perform(status.id) + end end end end diff --git a/spec/workers/activitypub/distribution_worker_spec.rb b/spec/workers/activitypub/distribution_worker_spec.rb index d8803f6b8..2706967fc 100644 --- a/spec/workers/activitypub/distribution_worker_spec.rb +++ b/spec/workers/activitypub/distribution_worker_spec.rb @@ -19,8 +19,9 @@ describe ActivityPub::DistributionWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) - subject.perform(status.id) + expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do + subject.perform(status.id) + end end end @@ -30,8 +31,9 @@ describe ActivityPub::DistributionWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) - subject.perform(status.id) + expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do + subject.perform(status.id) + end end end @@ -44,8 +46,9 @@ describe ActivityPub::DistributionWorker do end it 'delivers to mentioned accounts' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'https://foo.bar/inbox', anything]]) - subject.perform(status.id) + expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'https://foo.bar/inbox', anything]]) do + subject.perform(status.id) + end end end end diff --git a/spec/workers/activitypub/move_distribution_worker_spec.rb b/spec/workers/activitypub/move_distribution_worker_spec.rb index b8601f78c..75ca21733 100644 --- a/spec/workers/activitypub/move_distribution_worker_spec.rb +++ b/spec/workers/activitypub/move_distribution_worker_spec.rb @@ -19,8 +19,9 @@ describe ActivityPub::MoveDistributionWorker do expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [ [kind_of(String), migration.account.id, 'http://example.com'], [kind_of(String), migration.account.id, 'http://example2.com'], - ]) - subject.perform(migration.id) + ]) do + subject.perform(migration.id) + end end end end diff --git a/spec/workers/activitypub/status_update_distribution_worker_spec.rb b/spec/workers/activitypub/status_update_distribution_worker_spec.rb index c500bac95..a4fd246e5 100644 --- a/spec/workers/activitypub/status_update_distribution_worker_spec.rb +++ b/spec/workers/activitypub/status_update_distribution_worker_spec.rb @@ -25,9 +25,9 @@ describe ActivityPub::StatusUpdateDistributionWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) - - subject.perform(status.id) + expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do + subject.perform(status.id) + end end end @@ -37,9 +37,9 @@ describe ActivityPub::StatusUpdateDistributionWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) - - subject.perform(status.id) + expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), status.account.id, 'http://example.com', anything]]) do + subject.perform(status.id) + end end end end diff --git a/spec/workers/activitypub/update_distribution_worker_spec.rb b/spec/workers/activitypub/update_distribution_worker_spec.rb index d0eeda43b..4a0ed050b 100644 --- a/spec/workers/activitypub/update_distribution_worker_spec.rb +++ b/spec/workers/activitypub/update_distribution_worker_spec.rb @@ -14,8 +14,9 @@ describe ActivityPub::UpdateDistributionWorker do end it 'delivers to followers' do - expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), account.id, 'http://example.com', anything]]) - subject.perform(account.id) + expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[kind_of(String), account.id, 'http://example.com', anything]]) do + subject.perform(account.id) + end end end end