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

master
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

@ -44,7 +44,7 @@ RSpec.describe Admin::Disputes::AppealsController do
expect(response).to redirect_to(disputes_strike_path(appeal.strike)) expect(response).to redirect_to(disputes_strike_path(appeal.strike))
end end
it 'notifies target account about approved appeal' do it 'notifies target account about approved appeal', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1) expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email) expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at))) expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at)))
@ -62,7 +62,7 @@ RSpec.describe Admin::Disputes::AppealsController do
expect(response).to redirect_to(disputes_strike_path(appeal.strike)) expect(response).to redirect_to(disputes_strike_path(appeal.strike))
end end
it 'notifies target account about rejected appeal' do it 'notifies target account about rejected appeal', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1) expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email) expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at))) expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at)))

View File

@ -176,7 +176,7 @@ RSpec.describe Admin::DomainBlocksController do
end end
end end
describe 'PUT #update' do describe 'PUT #update', :sidekiq_inline do
subject do subject do
post :update, params: { :id => domain_block.id, :domain_block => { domain: 'example.com', severity: new_severity }, 'confirm' => '' } post :update, params: { :id => domain_block.id, :domain_block => { domain: 'example.com', severity: new_severity }, 'confirm' => '' }
end end

View File

@ -11,7 +11,7 @@ describe Admin::ResetsController do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
end end
describe 'POST #create' do describe 'POST #create', :sidekiq_inline do
it 'redirects to admin accounts page' do it 'redirects to admin accounts page' do
expect do expect do
post :create, params: { account_id: account.id } post :create, params: { account_id: account.id }

View File

@ -13,7 +13,7 @@ RSpec.describe Api::V1::ConversationsController do
allow(controller).to receive(:doorkeeper_token) { token } allow(controller).to receive(:doorkeeper_token) { token }
end end
describe 'GET #index' do describe 'GET #index', :sidekiq_inline do
let(:scopes) { 'read:statuses' } let(:scopes) { 'read:statuses' }
before do before do

View File

@ -9,7 +9,7 @@ describe Api::V1::Statuses::ReblogsController do
let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') } let(:app) { Fabricate(:application, name: 'Test app', website: 'http://testapp.com') }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write:statuses', application: app) } let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'write:statuses', application: app) }
context 'with an oauth token', :sidekiq_fake do context 'with an oauth token' do
before do before do
allow(controller).to receive(:doorkeeper_token) { token } allow(controller).to receive(:doorkeeper_token) { token }
end end
@ -46,7 +46,7 @@ describe Api::V1::Statuses::ReblogsController do
end end
end end
describe 'POST #destroy' do describe 'POST #destroy', :sidekiq_inline do
context 'with public status' do context 'with public status' do
let(:status) { Fabricate(:status, account: user.account) } let(:status) { Fabricate(:status, account: user.account) }

View File

@ -138,7 +138,7 @@ RSpec.describe Auth::SessionsController do
expect(controller.current_user).to eq user expect(controller.current_user).to eq user
end end
it 'sends a suspicious sign-in mail' do it 'sends a suspicious sign-in mail', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1) expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(user.email) expect(UserMailer.deliveries.first.to.first).to eq(user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.suspicious_sign_in.subject')) expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.suspicious_sign_in.subject'))

View File

@ -75,7 +75,7 @@ describe UserTrackingConcern do
expect(redis.ttl("account:#{user.account_id}:regeneration")).to be >= 0 expect(redis.ttl("account:#{user.account_id}:regeneration")).to be >= 0
end end
it 'regenerates feed when sign in is older than two weeks' do it 'regenerates feed when sign in is older than two weeks', :sidekiq_inline do
get :show get :show
expect_updated_sign_in_at(user) expect_updated_sign_in_at(user)

View File

@ -17,7 +17,7 @@ RSpec.describe Disputes::AppealsController do
post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } } post :create, params: { strike_id: strike.id, appeal: { text: 'Foo' } }
end end
it 'notifies staff about new appeal' do it 'notifies staff about new appeal', :sidekiq_inline do
expect(ActionMailer::Base.deliveries.first.to).to eq([admin.email]) expect(ActionMailer::Base.deliveries.first.to).to eq([admin.email])
end end

View File

@ -50,7 +50,7 @@ describe Settings::DeletesController do
delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } } delete :destroy, params: { form_delete_confirmation: { password: 'petsmoldoggos' } }
end end
it 'removes user record and redirects', :aggregate_failures do it 'removes user record and redirects', :aggregate_failures, :sidekiq_inline do
expect(response).to redirect_to '/auth/sign_in' expect(response).to redirect_to '/auth/sign_in'
expect(User.find_by(id: user.id)).to be_nil expect(User.find_by(id: user.id)).to be_nil
expect(user.account.reload).to be_suspended expect(user.account.reload).to be_suspended

View File

@ -38,7 +38,7 @@ describe Settings::ExportsController do
expect(response).to redirect_to(settings_export_path) expect(response).to redirect_to(settings_export_path)
end end
it 'queues BackupWorker job by 1', :sidekiq_fake do it 'queues BackupWorker job by 1' do
expect do expect do
post :create post :create
end.to change(BackupWorker.jobs, :size).by(1) end.to change(BackupWorker.jobs, :size).by(1)

View File

@ -48,7 +48,7 @@ describe 'Admin::Accounts' do
end end
end end
context 'with action of `reject`' do context 'with action of `reject`', :sidekiq_inline do
it 'rejects and removes the account' do it 'rejects and removes the account' do
batch_checkbox_for(unapproved_user_account).check batch_checkbox_for(unapproved_user_account).check

View File

@ -23,7 +23,7 @@ RSpec.describe ActivityPub::Activity::Create do
stub_request(:get, 'http://example.com/emojib.png').to_return(body: attachment_fixture('emojo.png'), headers: { 'Content-Type' => 'application/octet-stream' }) stub_request(:get, 'http://example.com/emojib.png').to_return(body: attachment_fixture('emojo.png'), headers: { 'Content-Type' => 'application/octet-stream' })
end end
describe 'processing posts received out of order', :sidekiq_fake do describe 'processing posts received out of order' do
let(:follower) { Fabricate(:account, username: 'bob') } let(:follower) { Fabricate(:account, username: 'bob') }
let(:object_json) do let(:object_json) do

View File

@ -47,7 +47,7 @@ RSpec.describe ActivityPub::Activity::Delete do
expect(Status.find_by(id: status.id)).to be_nil expect(Status.find_by(id: status.id)).to be_nil
end end
it 'sends delete activity to followers of rebloggers' do it 'sends delete activity to followers of rebloggers', :sidekiq_inline do
expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end end

View File

@ -38,7 +38,7 @@ RSpec.describe ActivityPub::Activity::Move do
subject.perform subject.perform
end end
context 'when all conditions are met' do context 'when all conditions are met', :sidekiq_inline do
it 'sets moved account on old account' do it 'sets moved account on old account' do
expect(old_account.reload.moved_to_account_id).to eq new_account.id expect(old_account.reload.moved_to_account_id).to eq new_account.id
end end

View File

@ -46,7 +46,7 @@ RSpec.describe Admin::AccountAction do
expect(target_account).to be_suspended expect(target_account).to be_suspended
end end
it 'queues Admin::SuspensionWorker by 1', :sidekiq_fake do it 'queues Admin::SuspensionWorker by 1' do
expect do expect do
subject subject
end.to change { Admin::SuspensionWorker.jobs.size }.by 1 end.to change { Admin::SuspensionWorker.jobs.size }.by 1

View File

@ -58,7 +58,7 @@ RSpec.describe User do
end end
end end
describe 'scopes' do describe 'scopes', :sidekiq_inline do
describe 'recent' do describe 'recent' do
it 'returns an array of recent users ordered by id' do it 'returns an array of recent users ordered by id' do
first_user = Fabricate(:user) first_user = Fabricate(:user)
@ -452,7 +452,7 @@ RSpec.describe User do
expect(user.confirmed_at).to be_present expect(user.confirmed_at).to be_present
end end
it 'delivers mails' do it 'delivers mails', :sidekiq_inline do
expect(ActionMailer::Base.deliveries.count).to eq 2 expect(ActionMailer::Base.deliveries.count).to eq 2
end end
end end

View File

@ -26,7 +26,6 @@ Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema! ActiveRecord::Migration.maintain_test_schema!
WebMock.disable_net_connect!(allow: Chewy.settings[:host], allow_localhost: RUN_SYSTEM_SPECS) WebMock.disable_net_connect!(allow: Chewy.settings[:host], allow_localhost: RUN_SYSTEM_SPECS)
Sidekiq::Testing.inline!
Sidekiq.logger = nil Sidekiq.logger = nil
# System tests config # System tests config
@ -96,11 +95,8 @@ RSpec.configure do |config|
self.use_transactional_tests = true self.use_transactional_tests = true
end end
config.around(:each, :sidekiq_fake) do |example| config.around(:each, :sidekiq_inline) do |example|
Sidekiq::Testing.fake! do Sidekiq::Testing.inline!(&example)
example.run
Sidekiq::Worker.clear_all
end
end end
config.before :each, type: :cli do config.before :each, type: :cli do

View File

@ -147,7 +147,7 @@ RSpec.describe 'FeaturedTags' do
expect(body).to be_empty expect(body).to be_empty
end end
it 'deletes the featured tag' do it 'deletes the featured tag', :sidekiq_inline do
delete "/api/v1/featured_tags/#{id}", headers: headers delete "/api/v1/featured_tags/#{id}", headers: headers
featured_tag = FeaturedTag.find_by(id: id) featured_tag = FeaturedTag.find_by(id: id)

View File

@ -8,7 +8,7 @@ RSpec.describe 'Notifications' do
let(:scopes) { 'read:notifications write:notifications' } let(:scopes) { 'read:notifications write:notifications' }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } } let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
describe 'GET /api/v1/notifications' do describe 'GET /api/v1/notifications', :sidekiq_inline do
subject do subject do
get '/api/v1/notifications', headers: headers, params: params get '/api/v1/notifications', headers: headers, params: params
end end

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Favourites' do RSpec.describe 'Favourites', :sidekiq_inline do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let(:scopes) { 'write:favourites' } let(:scopes) { 'write:favourites' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
@ -70,7 +70,7 @@ RSpec.describe 'Favourites' do
end end
end end
describe 'POST /api/v1/statuses/:status_id/unfavourite', :sidekiq_fake do describe 'POST /api/v1/statuses/:status_id/unfavourite' do
subject do subject do
post "/api/v1/statuses/#{status.id}/unfavourite", headers: headers post "/api/v1/statuses/#{status.id}/unfavourite", headers: headers
end end
@ -88,9 +88,7 @@ RSpec.describe 'Favourites' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be true
UnfavouriteWorker.drain
expect(user.account.favourited?(status)).to be false expect(user.account.favourited?(status)).to be false
end end
@ -113,9 +111,7 @@ RSpec.describe 'Favourites' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(user.account.favourited?(status)).to be true
UnfavouriteWorker.drain
expect(user.account.favourited?(status)).to be false expect(user.account.favourited?(status)).to be false
end end

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
describe 'Home' do describe 'Home', :sidekiq_inline do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let(:scopes) { 'read:statuses' } let(:scopes) { 'read:statuses' }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
describe Account::StatusesSearch do describe Account::StatusesSearch, :sidekiq_inline do
describe 'a non-indexable account becoming indexable' do describe 'a non-indexable account becoming indexable' do
let(:account) { Account.find_by(username: 'search_test_account_1') } let(:account) { Account.find_by(username: 'search_test_account_1') }

View File

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

View File

@ -193,7 +193,7 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
end end
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) } expect { subject.call('user1', 'foo.test', payload) }
.to create_some_remote_accounts .to create_some_remote_accounts
.and create_fewer_than_rate_limit_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 expect(bob.following?(sender)).to be true
end 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 expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end end
end end

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe BatchedRemoveStatusService, type: :service do RSpec.describe BatchedRemoveStatusService, :sidekiq_inline, type: :service do
subject { described_class.new } subject { described_class.new }
let!(:alice) { Fabricate(:account) } 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 expect(already_banned_account.reload.silenced_at).to_not eq DomainBlock.find_by(domain: 'evil.org').created_at
end 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_plain.reload }.to_not raise_error
expect { bad_status_with_attachment.reload }.to_not raise_error expect { bad_status_with_attachment.reload }.to_not raise_error
expect { bad_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 expect(sender.blocking?(bob)).to be true
end 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 expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end end
end end

View File

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

View File

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

View File

@ -38,7 +38,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(home_feed_of(alice)).to include status.id expect(home_feed_of(alice)).to include status.id
end 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(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id expect(home_feed_of(tom)).to include status.id
end end
@ -62,7 +62,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(home_feed_of(alice)).to include status.id expect(home_feed_of(alice)).to include status.id
end 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 expect(home_feed_of(bob)).to include status.id
end end
@ -83,7 +83,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(home_feed_of(alice)).to include status.id expect(home_feed_of(alice)).to include status.id
end 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(bob)).to include status.id
expect(home_feed_of(tom)).to include status.id expect(home_feed_of(tom)).to include status.id
end end
@ -101,7 +101,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(home_feed_of(alice)).to include status.id expect(home_feed_of(alice)).to include status.id
end 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 expect(home_feed_of(bob)).to include status.id
end end
@ -114,7 +114,7 @@ RSpec.describe FanOutOnWriteService, type: :service do
expect(redis).to_not have_received(:publish).with('timeline:public', anything) expect(redis).to_not have_received(:publish).with('timeline:public', anything)
end end
context 'when handling status updates', :sidekiq_fake do context 'when handling status updates' do
before do before do
subject.call(status) subject.call(status)
@ -123,8 +123,6 @@ RSpec.describe FanOutOnWriteService, type: :service do
status.snapshot!(account_id: status.account_id) status.snapshot!(account_id: status.account_id)
redis.set("subscribed:timeline:#{eve.id}:notifications", '1') redis.set("subscribed:timeline:#{eve.id}:notifications", '1')
Sidekiq::Worker.clear_all
end end
it 'pushes the update to mentioned users through the notifications streaming channel' do 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 expect(status.favourites.first).to_not be_nil
end 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 expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end end
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 expect(FollowRequest.find_by(account: sender, target_account: bob)).to_not be_nil
end 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 expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end end
end end

View File

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

View File

@ -17,7 +17,7 @@ RSpec.describe MuteService, type: :service do
redis.del(home_timeline_key) redis.del(home_timeline_key)
end 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, status)
FeedManager.instance.push_to_home(account, other_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 context 'when email notification is enabled' do
let(:enabled) { true } let(:enabled) { true }
it 'sends email' do it 'sends email', :sidekiq_inline do
expect { subject }.to change(ActionMailer::Base.deliveries, :count).by(1) expect { subject }.to change(ActionMailer::Base.deliveries, :count).by(1)
end end
end end

View File

@ -87,7 +87,7 @@ RSpec.describe ReblogService, type: :service do
expect(ActivityPub::DistributionWorker).to have_received(:perform_async) expect(ActivityPub::DistributionWorker).to have_received(:perform_async)
end 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 expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end end
end end

View File

@ -41,7 +41,7 @@ RSpec.describe RejectFollowService, type: :service do
expect(bob.following?(sender)).to be false expect(bob.following?(sender)).to be false
end 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 expect(a_request(:post, bob.inbox_url)).to have_been_made.once
end end
end end

View File

@ -33,7 +33,7 @@ RSpec.describe RemoveFromFollowersService, type: :service do
expect(bob.followed_by?(sender)).to be false expect(bob.followed_by?(sender)).to be false
end 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 expect(a_request(:post, sender.inbox_url)).to have_been_made.once
end end
end end

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe RemoveStatusService, type: :service do RSpec.describe RemoveStatusService, :sidekiq_inline, type: :service do
subject { described_class.new } subject { described_class.new }
let!(:alice) { Fabricate(:account) } 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) stub_request(:post, 'http://example.com/inbox').to_return(status: 200)
end end
context 'when forward is true' do context 'when forward is true', :sidekiq_inline do
let(:forward) { true } let(:forward) { true }
it 'sends ActivityPub payload when forward is true' do 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' expect(account.uri).to eq 'https://ap.example.com/users/foo'
end end
it 'merges accounts' do it 'merges accounts', :sidekiq_inline do
account = subject.call('foo@ap.example.com') account = subject.call('foo@ap.example.com')
expect(status.reload.account_id).to eq account.id expect(status.reload.account_id).to eq account.id

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe SuspendAccountService, type: :service do RSpec.describe SuspendAccountService, :sidekiq_inline, type: :service do
shared_examples 'common behavior' do shared_examples 'common behavior' do
subject { described_class.new.call(account) } 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!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) }
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') } 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 before do
allow(Rails.configuration.x).to receive(:limited_federation_mode).and_return(true) allow(Rails.configuration.x).to receive(:limited_federation_mode).and_return(true)
end end

View File

@ -33,7 +33,7 @@ RSpec.describe UnblockService, type: :service do
expect(sender.blocking?(bob)).to be false expect(sender.blocking?(bob)).to be false
end 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 expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.once
end end
end end

View File

@ -20,7 +20,7 @@ RSpec.describe UnfollowService, type: :service do
end end
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') } let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
before do before do
@ -38,7 +38,7 @@ RSpec.describe UnfollowService, type: :service do
end end
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') } let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
before do before do

View File

@ -45,7 +45,7 @@ RSpec.describe UnsuspendAccountService, type: :service do
remote_follower.follow!(account) remote_follower.follow!(account)
end 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 subject
expect_feeds_merged expect_feeds_merged

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe UpdateAccountService, type: :service do RSpec.describe UpdateAccountService, type: :service do
subject { described_class.new } 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(:account) { Fabricate(:account, locked: true) }
let(:alice) { Fabricate(:account) } let(:alice) { Fabricate(:account) }
let(:bob) { Fabricate(:account) } let(:bob) { Fabricate(:account) }

View File

@ -111,7 +111,7 @@ RSpec.describe UpdateStatusService, type: :service do
end end
end end
context 'when poll changes', :sidekiq_fake do context 'when poll changes' do
let(:account) { Fabricate(:account) } 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!(: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 } let!(:poll) { status.poll }

View File

@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
describe 'NewStatuses' do describe 'NewStatuses', :sidekiq_inline do
include ProfileStories include ProfileStories
subject { page } subject { page }

View File

@ -14,7 +14,7 @@ describe BackupWorker do
let(:backup) { Fabricate(:backup) } let(:backup) { Fabricate(:backup) }
let!(:other_backup) { Fabricate(:backup, user: backup.user) } let!(:other_backup) { Fabricate(:backup, user: backup.user) }
it 'sends the backup to the service and removes other backups' do it 'sends the backup to the service and removes other backups', :sidekiq_inline do
expect do expect do
worker.perform(backup.id) worker.perform(backup.id)
end.to change(UserMailer.deliveries, :size).by(1) end.to change(UserMailer.deliveries, :size).by(1)

View File

@ -104,7 +104,7 @@ describe MoveWorker do
end end
shared_examples 'lists handling' do shared_examples 'lists handling' do
it 'puts the new account on the list and makes valid lists', sidekiq: :inline do it 'puts the new account on the list and makes valid lists', :sidekiq_inline do
subject.perform(source_account.id, target_account.id) subject.perform(source_account.id, target_account.id)
expect(list.accounts.include?(target_account)).to be true expect(list.accounts.include?(target_account)).to be true
@ -159,7 +159,7 @@ describe MoveWorker do
describe '#perform' do describe '#perform' do
context 'when both accounts are distant' do context 'when both accounts are distant' do
it 'calls UnfollowFollowWorker', :sidekiq_fake do it 'calls UnfollowFollowWorker' do
subject.perform(source_account.id, target_account.id) subject.perform(source_account.id, target_account.id)
expect(UnfollowFollowWorker).to have_enqueued_sidekiq_job(local_follower.id, source_account.id, target_account.id, false) expect(UnfollowFollowWorker).to have_enqueued_sidekiq_job(local_follower.id, source_account.id, target_account.id, false)
end end
@ -170,7 +170,7 @@ describe MoveWorker do
context 'when target account is local' do context 'when target account is local' do
let(:target_account) { Fabricate(:account) } let(:target_account) { Fabricate(:account) }
it 'calls UnfollowFollowWorker', :sidekiq_fake do it 'calls UnfollowFollowWorker' do
subject.perform(source_account.id, target_account.id) subject.perform(source_account.id, target_account.id)
expect(UnfollowFollowWorker).to have_enqueued_sidekiq_job(local_follower.id, source_account.id, target_account.id, true) expect(UnfollowFollowWorker).to have_enqueued_sidekiq_job(local_follower.id, source_account.id, target_account.id, true)
end end

View File

@ -10,7 +10,7 @@ describe PollExpirationNotifyWorker do
let(:remote?) { false } let(:remote?) { false }
let(:poll_vote) { Fabricate(:poll_vote, poll: poll) } let(:poll_vote) { Fabricate(:poll_vote, poll: poll) }
describe '#perform', :sidekiq_fake do describe '#perform' do
it 'runs without error for missing record' do it 'runs without error for missing record' do
expect { worker.perform(nil) }.to_not raise_error expect { worker.perform(nil) }.to_not raise_error
end end