Skip to content

Commit

Permalink
Merge pull request #962 from scientist-softserv/make-groups-for-cdl-only
Browse files Browse the repository at this point in the history
🐛 Call `CreateGroupAndAddMembersJob` only for CDL
  • Loading branch information
Kirk Wang authored Jan 22, 2024
2 parents 9bc5bd9 + a08d152 commit 1aaf0b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/jobs/iiif_print/create_relationships_job_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def perform(parent_id:, parent_model:, child_model:, retries: 0, **)
end

# OVERRIDE begin
CreateGroupAndAddMembersJob.set(wait: 2.minutes).perform_later(parent_id)
CreateGroupAndAddMembersJob.set(wait: 2.minutes).perform_later(parent_id) if parent_model == 'Cdl'
# OVERRIDE end
else
# if we aren't ready yet, reschedule the job and end this one normally
Expand Down
18 changes: 15 additions & 3 deletions spec/jobs/iiif_print/create_relationships_job_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@
let(:parent) { FactoryBot.create(:cdl) }
let(:child) { FactoryBot.create(:generic_work) }

it 'calls CreateGroupAndAddMembersJob' do
expect(CreateGroupAndAddMembersJob).to receive(:set).with(wait: 2.minutes).and_return(CreateGroupAndAddMembersJob)

after do
job.perform(parent_id: parent.id, parent_model: parent.class.to_s, child_model: child.class)
end

context 'when parent_model is Cdl' do
it 'calls CreateGroupAndAddMembersJob' do
expect(CreateGroupAndAddMembersJob).to receive(:set).with(wait: 2.minutes).and_return(CreateGroupAndAddMembersJob)
end
end

context 'when parent_model is not Cdl' do
let(:parent) { FactoryBot.create(:generic_work) }

it 'does not call CreateGroupAndAddMembersJob' do
expect(CreateGroupAndAddMembersJob).not_to receive(:set)
end
end
end
end
# rubocop:enable RSpec/FilePath

0 comments on commit 1aaf0b8

Please sign in to comment.