Consolidate configuration of Sidekiq::Testing.fake!
setup (#28046)
This commit is contained in:
parent
c810b197ad
commit
973597c6f1
@ -9,13 +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' do
|
context 'with an oauth token', :sidekiq_fake do
|
||||||
around do |example|
|
|
||||||
Sidekiq::Testing.fake! do
|
|
||||||
example.run
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(controller).to receive(:doorkeeper_token) { token }
|
allow(controller).to receive(:doorkeeper_token) { token }
|
||||||
end
|
end
|
||||||
|
@ -38,12 +38,10 @@ 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' do
|
it 'queues BackupWorker job by 1', :sidekiq_fake do
|
||||||
Sidekiq::Testing.fake! 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)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -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' do
|
describe 'processing posts received out of order', :sidekiq_fake do
|
||||||
let(:follower) { Fabricate(:account, username: 'bob') }
|
let(:follower) { Fabricate(:account, username: 'bob') }
|
||||||
|
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
@ -77,13 +77,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||||||
follower.follow!(sender)
|
follower.follow!(sender)
|
||||||
end
|
end
|
||||||
|
|
||||||
around do |example|
|
|
||||||
Sidekiq::Testing.fake! do
|
|
||||||
example.run
|
|
||||||
Sidekiq::Worker.clear_all
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'correctly processes posts and inserts them in timelines', :aggregate_failures do
|
it 'correctly processes posts and inserts them in timelines', :aggregate_failures do
|
||||||
# Simulate a temporary failure preventing from fetching the parent post
|
# Simulate a temporary failure preventing from fetching the parent post
|
||||||
stub_request(:get, object_json[:id]).to_return(status: 500)
|
stub_request(:get, object_json[:id]).to_return(status: 500)
|
||||||
|
@ -46,12 +46,10 @@ 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' do
|
it 'queues Admin::SuspensionWorker by 1', :sidekiq_fake do
|
||||||
Sidekiq::Testing.fake! 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
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -95,6 +95,13 @@ RSpec.configure do |config|
|
|||||||
self.use_transactional_tests = true
|
self.use_transactional_tests = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.around(:each, :sidekiq_fake) do |example|
|
||||||
|
Sidekiq::Testing.fake! do
|
||||||
|
example.run
|
||||||
|
Sidekiq::Worker.clear_all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
config.before :each, type: :cli do
|
config.before :each, type: :cli do
|
||||||
stub_stdout
|
stub_stdout
|
||||||
stub_reset_connection_pools
|
stub_reset_connection_pools
|
||||||
|
@ -70,19 +70,13 @@ RSpec.describe 'Favourites' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST /api/v1/statuses/:status_id/unfavourite' do
|
describe 'POST /api/v1/statuses/:status_id/unfavourite', :sidekiq_fake 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
|
||||||
|
|
||||||
let(:status) { Fabricate(:status) }
|
let(:status) { Fabricate(:status) }
|
||||||
|
|
||||||
around do |example|
|
|
||||||
Sidekiq::Testing.fake! do
|
|
||||||
example.run
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like 'forbidden for wrong scope', 'read read:favourites'
|
it_behaves_like 'forbidden for wrong scope', 'read read:favourites'
|
||||||
|
|
||||||
context 'with public status' do
|
context 'with public status' do
|
||||||
|
@ -12,14 +12,7 @@ RSpec.describe BulkImportService do
|
|||||||
import.update(total_items: import.rows.count)
|
import.update(total_items: import.rows.count)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#call' do
|
describe '#call', :sidekiq_fake do
|
||||||
around do |example|
|
|
||||||
Sidekiq::Testing.fake! do
|
|
||||||
example.run
|
|
||||||
Sidekiq::Worker.clear_all
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when importing follows' do
|
context 'when importing follows' do
|
||||||
let(:import_type) { 'following' }
|
let(:import_type) { 'following' }
|
||||||
let(:overwrite) { false }
|
let(:overwrite) { false }
|
||||||
|
@ -111,7 +111,7 @@ RSpec.describe UpdateStatusService, type: :service do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when poll changes' do
|
context 'when poll changes', :sidekiq_fake 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 }
|
||||||
@ -120,9 +120,7 @@ RSpec.describe UpdateStatusService, type: :service do
|
|||||||
before do
|
before do
|
||||||
status.update(poll: poll)
|
status.update(poll: poll)
|
||||||
VoteService.new.call(voter, poll, [0])
|
VoteService.new.call(voter, poll, [0])
|
||||||
Sidekiq::Testing.fake! do
|
subject.call(status, status.account_id, text: 'Foo', poll: { options: %w(Bar Baz Foo), expires_in: 5.days.to_i })
|
||||||
subject.call(status, status.account_id, text: 'Foo', poll: { options: %w(Bar Baz Foo), expires_in: 5.days.to_i })
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates poll' do
|
it 'updates poll' do
|
||||||
|
@ -159,12 +159,9 @@ 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' do
|
it 'calls UnfollowFollowWorker', :sidekiq_fake do
|
||||||
Sidekiq::Testing.fake! 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)
|
|
||||||
Sidekiq::Worker.drain_all
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
include_examples 'common tests'
|
include_examples 'common tests'
|
||||||
@ -173,12 +170,9 @@ 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' do
|
it 'calls UnfollowFollowWorker', :sidekiq_fake do
|
||||||
Sidekiq::Testing.fake! 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)
|
|
||||||
Sidekiq::Worker.clear_all
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
include_examples 'common tests'
|
include_examples 'common tests'
|
||||||
|
@ -10,13 +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' do
|
describe '#perform', :sidekiq_fake do
|
||||||
around do |example|
|
|
||||||
Sidekiq::Testing.fake! do
|
|
||||||
example.run
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user