Use Sidekiq fake! instead of inline! in specs (#25369)

This commit is contained in:
Matt Jankowski 2024-01-10 06:06:58 -05:00 committed by GitHub
parent ea1c0feb86
commit 00341c70ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 66 additions and 76 deletions

View file

@ -225,7 +225,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
end
end
context 'with statuses referencing other statuses' do
context 'with statuses referencing other statuses', :sidekiq_inline do
before do
stub_const 'ActivityPub::FetchRemoteStatusService::DISCOVERIES_PER_REQUEST', 5
end

View file

@ -193,7 +193,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
end
end
it 'creates accounts without exceeding rate limit' do
it 'creates accounts without exceeding rate limit', :sidekiq_inline do
expect { subject.call('user1', 'foo.test', payload) }
.to create_some_remote_accounts
.and create_fewer_than_rate_limit_accounts

View file

@ -41,7 +41,7 @@ RSpec.describe AuthorizeFollowService, type: :service do
expect(bob.following?(sender)).to be true
end
it 'sends an accept activity' do
it 'sends an accept activity', :sidekiq_inline do
expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe BatchedRemoveStatusService, type: :service do
RSpec.describe BatchedRemoveStatusService, :sidekiq_inline, type: :service do
subject { described_class.new }
let!(:alice) { Fabricate(:account) }

View file

@ -68,7 +68,7 @@ RSpec.describe BlockDomainService, type: :service do
expect(already_banned_account.reload.silenced_at).to_not eq DomainBlock.find_by(domain: 'evil.org').created_at
end
it 'leaves the domains status and attachments, but clears media' do
it 'leaves the domains status and attachments, but clears media', :sidekiq_inline do
expect { bad_status_plain.reload }.to_not raise_error
expect { bad_status_with_attachment.reload }.to_not raise_error
expect { bad_attachment.reload }.to_not raise_error

View file

@ -31,7 +31,7 @@ RSpec.describe BlockService, type: :service do
expect(sender.blocking?(bob)).to be true
end
it 'sends a block activity' do
it 'sends a block activity', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

View file

@ -12,7 +12,7 @@ RSpec.describe BulkImportService do
import.update(total_items: import.rows.count)
end
describe '#call', :sidekiq_fake do
describe '#call' do
context 'when importing follows' do
let(:import_type) { 'following' }
let(:overwrite) { false }

View file

@ -62,7 +62,7 @@ RSpec.describe DeleteAccountService, type: :service do
end
end
describe '#call on local account' do
describe '#call on local account', :sidekiq_inline do
before do
stub_request(:post, remote_alice.inbox_url).to_return(status: 201)
stub_request(:post, remote_bob.inbox_url).to_return(status: 201)
@ -83,7 +83,7 @@ RSpec.describe DeleteAccountService, type: :service do
end
end
describe '#call on remote account' do
describe '#call on remote account', :sidekiq_inline do
before do
stub_request(:post, account.inbox_url).to_return(status: 201)
end

View file

@ -38,7 +38,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of a follower' do
it 'is added to the home feed of a follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id
end
@ -62,7 +62,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of the mentioned follower' do
it 'is added to the home feed of the mentioned follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
end
@ -83,7 +83,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of a follower' do
it 'is added to the home feed of a follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id
end
@ -101,7 +101,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(home_feed_of(alice)).to include status.id
end
it 'is added to the home feed of the mentioned follower' do
it 'is added to the home feed of the mentioned follower', :sidekiq_inline do
expect(home_feed_of(bob)).to include status.id
end
@ -114,7 +114,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end
context 'when handling status updates', :sidekiq_fake do
context 'when handling status updates' do
before do
subject.call(status)
@ -123,8 +123,6 @@ RSpec.describe FanOutOnWriteService, type: :service do
status.snapshot!(account_id: status.account_id)
redis.set("subscribed:timeline:#{eve.id}:notifications", '1')
Sidekiq::Worker.clear_all
end
it 'pushes the update to mentioned users through the notifications streaming channel' do

View file

@ -33,7 +33,7 @@ RSpec.describe FavouriteService, type: :service do
expect(status.favourites.first).to_not be_nil
end
it 'sends a like activity' do
it 'sends a like activity', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

View file

@ -150,7 +150,7 @@ RSpec.describe FollowService, type: :service do
expect(FollowRequest.find_by(account: sender, target_account: bob)).to_not be_nil
end
it 'sends a follow activity to the inbox' do
it 'sends a follow activity to the inbox', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ImportService, type: :service do
RSpec.describe ImportService, :sidekiq_inline, type: :service do
include RoutingHelper
let!(:account) { Fabricate(:account, locked: false) }

View file

@ -17,7 +17,7 @@ RSpec.describe MuteService, type: :service do
redis.del(home_timeline_key)
end
it "clears account's statuses" do
it "clears account's statuses", :sidekiq_inline do
FeedManager.instance.push_to_home(account, status)
FeedManager.instance.push_to_home(account, other_account_status)

View file

@ -166,7 +166,7 @@ RSpec.describe NotifyService, type: :service do
context 'when email notification is enabled' do
let(:enabled) { true }
it 'sends email' do
it 'sends email', :sidekiq_inline do
expect { subject }.to change(ActionMailer::Base.deliveries, :count).by(1)
end
end

View file

@ -87,7 +87,7 @@ RSpec.describe ReblogService, type: :service do
expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
end
it 'sends an announce activity to the author' do
it 'sends an announce activity to the author', :sidekiq_inline do
expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end
end

View file

@ -41,7 +41,7 @@ RSpec.describe RejectFollowService, type: :service do
expect(bob.following?(sender)).to be false
end
it 'sends a reject activity' do
it 'sends a reject activity', :sidekiq_inline do
expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end
end

View file

@ -33,7 +33,7 @@ RSpec.describe RemoveFromFollowersService, type: :service do
expect(bob.followed_by?(sender)).to be false
end
it 'sends a reject activity' do
it 'sends a reject activity', :sidekiq_inline do
expect(a_request(:post, sender.inbox_url)).to have_been_made.once
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe RemoveStatusService, type: :service do
RSpec.describe RemoveStatusService, :sidekiq_inline, type: :service do
subject { described_class.new }
let!(:alice) { Fabricate(:account) }

View file

@ -23,7 +23,7 @@ RSpec.describe ReportService, type: :service do
stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
end
context 'when forward is true' do
context 'when forward is true', :sidekiq_inline do
let(:forward) { true }
it 'sends ActivityPub payload when forward is true' do

View file

@ -195,7 +195,7 @@ RSpec.describe ResolveAccountService, type: :service do
expect(account.uri).to eq 'https://ap.example.com/users/foo'
end
it 'merges accounts' do
it 'merges accounts', :sidekiq_inline do
account = subject.call('foo@ap.example.com')
expect(status.reload.account_id).to eq account.id

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe SuspendAccountService, type: :service do
RSpec.describe SuspendAccountService, :sidekiq_inline, type: :service do
shared_examples 'common behavior' do
subject { described_class.new.call(account) }

View file

@ -12,7 +12,7 @@ RSpec.describe UnallowDomainService, type: :service do
let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) }
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') }
context 'with limited federation mode' do
context 'with limited federation mode', :sidekiq_inline do
before do
allow(Rails.configuration.x).to receive(:limited_federation_mode).and_return(true)
end

View file

@ -33,7 +33,7 @@ RSpec.describe UnblockService, type: :service do
expect(sender.blocking?(bob)).to be false
end
it 'sends an unblock activity' do
it 'sends an unblock activity', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end
end

View file

@ -20,7 +20,7 @@ RSpec.describe UnfollowService, type: :service do
end
end
describe 'remote ActivityPub' do
describe 'remote ActivityPub', :sidekiq_inline do
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
before do
@ -38,7 +38,7 @@ RSpec.describe UnfollowService, type: :service do
end
end
describe 'remote ActivityPub (reverse)' do
describe 'remote ActivityPub (reverse)', :sidekiq_inline do
let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
before do

View file

@ -45,7 +45,7 @@ RSpec.describe UnsuspendAccountService, type: :service do
remote_follower.follow!(account)
end
it 'merges back into feeds of local followers and sends update' do
it 'merges back into feeds of local followers and sends update', :sidekiq_inline do
subject
expect_feeds_merged

View file

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe UpdateAccountService, type: :service do
subject { described_class.new }
describe 'switching form locked to unlocked accounts' do
describe 'switching form locked to unlocked accounts', :sidekiq_inline do
let(:account) { Fabricate(:account, locked: true) }
let(:alice) { Fabricate(:account) }
let(:bob) { Fabricate(:account) }

View file

@ -111,7 +111,7 @@ RSpec.describe UpdateStatusService, type: :service do
end
end
context 'when poll changes', :sidekiq_fake do
context 'when poll changes' do
let(:account) { Fabricate(:account) }
let!(:status) { Fabricate(:status, text: 'Foo', account: account, poll_attributes: { options: %w(Foo Bar), account: account, multiple: false, hide_totals: false, expires_at: 7.days.from_now }) }
let!(:poll) { status.poll }