-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e4ef46
commit dd8b8ba
Showing
11 changed files
with
190 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Delayed | ||
module JobGroups | ||
class CompleteStaleJobGroupsJob | ||
if defined?(Delayed::Extensions::SystemJobWithoutSecurityContext) | ||
include Delayed::Extensions::SystemJobWithoutSecurityContext | ||
end | ||
|
||
class << self | ||
def enqueue(**kwargs) | ||
Delayed::Job.enqueue(new, **kwargs) | ||
end | ||
end | ||
|
||
def perform | ||
Delayed::JobGroups::JobGroup.ready.find_each(&:check_for_completion) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
spec/delayed/job_groups/complete_stale_job_groups_job_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Delayed::JobGroups::CompleteStaleJobGroupsJob do | ||
describe "#perform" do | ||
let(:job) { described_class.new } | ||
|
||
let!(:blocked) { create(:job_group, blocked: true) } | ||
let!(:not_queueing_complete) { create(:job_group, queueing_complete: false) } | ||
let!(:ready) { create(:job_group, queueing_complete: true, blocked: false) } | ||
|
||
before do | ||
allow(Delayed::JobGroups::JobGroup).to receive(:check_for_completion) | ||
end | ||
|
||
it "checks all relevant job groups for completion" do | ||
job.perform | ||
|
||
expect(Delayed::JobGroups::JobGroup).to have_received(:check_for_completion) | ||
.once | ||
.with(ready.id) | ||
end | ||
end | ||
|
||
describe "#enqueue" do | ||
before do | ||
allow(Delayed::Job).to receive(:enqueue) | ||
end | ||
|
||
it "enqueues the job" do | ||
described_class.enqueue | ||
|
||
expect(Delayed::Job).to have_received(:enqueue).with(instance_of(described_class)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :job_group, class: 'Delayed::JobGroups::JobGroup' do | ||
blocked { false } | ||
queueing_complete { false } | ||
on_completion_job { nil } | ||
on_completion_job_options { nil } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters