diff --git a/app/workers/authorized_projects_worker.rb b/app/workers/authorized_projects_worker.rb index 0e20df506a371d5765c5ae83e17b204cf0b9de76..13207a8bc71b8284e2586a1c0a7c9bb282180f9f 100644 --- a/app/workers/authorized_projects_worker.rb +++ b/app/workers/authorized_projects_worker.rb @@ -10,7 +10,7 @@ class AuthorizedProjectsWorker end def self.bulk_perform_async(args_list) - Sidekiq::Client.push_bulk('class' => self, 'args' => args_list) + Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => args_list) end def perform(user_id) diff --git a/changelogs/unreleased/29137-bulk-perform-async-should-specify-queue.yml b/changelogs/unreleased/29137-bulk-perform-async-should-specify-queue.yml new file mode 100644 index 0000000000000000000000000000000000000000..0de7754badcd688c1505c55edeb898ecda166f7c --- /dev/null +++ b/changelogs/unreleased/29137-bulk-perform-async-should-specify-queue.yml @@ -0,0 +1,4 @@ +--- +title: Make authorized projects worker use a specific queue instead of the default one +merge_request: 9813 +author: diff --git a/spec/workers/authorized_projects_worker_spec.rb b/spec/workers/authorized_projects_worker_spec.rb index 97c4bfcd248729b8dc18213c1e36f735642dc638..bd5cc651c2b6a2acf2acf378272573d7ae57514a 100644 --- a/spec/workers/authorized_projects_worker_spec.rb +++ b/spec/workers/authorized_projects_worker_spec.rb @@ -1,12 +1,10 @@ require 'spec_helper' describe AuthorizedProjectsWorker do - let(:worker) { described_class.new } + let(:project) { create(:empty_project) } describe '.bulk_perform_and_wait' do it 'schedules the ids and waits for the jobs to complete' do - project = create(:project) - project.owner.project_authorizations.delete_all described_class.bulk_perform_and_wait([[project.owner.id]]) @@ -15,20 +13,37 @@ describe AuthorizedProjectsWorker do end end + describe '.bulk_perform_async' do + it "uses it's respective sidekiq queue" do + args = [[project.owner.id]] + push_bulk_args = { + 'class' => described_class, + 'queue' => described_class.sidekiq_options['queue'], + 'args' => args + } + + expect(Sidekiq::Client).to receive(:push_bulk).with(push_bulk_args).once + + described_class.bulk_perform_async(args) + end + end + describe '#perform' do + subject { described_class.new } + it "refreshes user's authorized projects" do user = create(:user) expect_any_instance_of(User).to receive(:refresh_authorized_projects) - worker.perform(user.id) + subject.perform(user.id) end context "when the user is not found" do it "does nothing" do expect_any_instance_of(User).not_to receive(:refresh_authorized_projects) - described_class.new.perform(-1) + subject.perform(-1) end end end