delayed_job_groups_plugin 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6ebba61f2d0ba4a6ab2572a5648030c14b58ae99e4412fbd4a89257128f587a
4
- data.tar.gz: 5c1457109671e7ab379f32d3a5e52750de3fd775fa83c3a70723fec29b146d0b
3
+ metadata.gz: d9fb6a8ff3bc2cada4bb9a8f76382ca323eed8539188646efccd80a1b767acac
4
+ data.tar.gz: 90e5ea6437fc1485d8ca26a34062e3a30de989c7f8d8751643280d3830d12c79
5
5
  SHA512:
6
- metadata.gz: f25332bf31e68b50e1925dd77407caaf0e577f997804dadb24a9c1fce0045353431d48187d69582b3884217a928df2a91157d4ee9e7d8c7e45889860222b89ba
7
- data.tar.gz: ff86634ad4296c5c4f2e17cbc0acee72e1c9d97b567298565d2fa457ac69245f47348cc7551dbfe397a9fd8e552a1bd994e7f487cd5fe8cd7a0eaef3da75fd1c
6
+ metadata.gz: 943569571301edf9a43a3a73c967fb165fb5fcda2e9576a3d0ace3b2a5a3bf2a4fe46e73cc812d0498ec09b2bf2fa8ffc56bee70741f5e29d30aa4ca653ce822
7
+ data.tar.gz: 0f26bbf975f3d5c727aa639afe5ea1e974fd0c8623031e62fbec78467237c8b44ea31d28f977c8dd74fb15779f8cd951a530504a9e24181ae69579ccde29a7a8
data/.circleci/config.yml CHANGED
@@ -2,14 +2,14 @@ version: 2.1
2
2
  jobs:
3
3
  lint:
4
4
  docker:
5
- - image: salsify/ruby_ci:2.5.8
5
+ - image: salsify/ruby_ci:2.6.6
6
6
  working_directory: ~/delayed_job_groups
7
7
  steps:
8
8
  - checkout
9
9
  - restore_cache:
10
10
  keys:
11
- - v1-gems-ruby-2.5.8-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
12
- - v1-gems-ruby-2.5.8-
11
+ - v1-gems-ruby-2.6.6-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
12
+ - v1-gems-ruby-2.6.6-
13
13
  - run:
14
14
  name: Install Gems
15
15
  command: |
@@ -18,7 +18,7 @@ jobs:
18
18
  bundle clean
19
19
  fi
20
20
  - save_cache:
21
- key: v1-gems-ruby-2.5.8-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
21
+ key: v1-gems-ruby-2.6.6-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "Gemfile" }}
22
22
  paths:
23
23
  - "vendor/bundle"
24
24
  - "gemfiles/vendor/bundle"
@@ -29,8 +29,10 @@ jobs:
29
29
  parameters:
30
30
  gemfile:
31
31
  type: string
32
+ ruby_version:
33
+ type: string
32
34
  docker:
33
- - image: salsify/ruby_ci:2.5.8
35
+ - image: salsify/ruby_ci:<< parameters.ruby_version >>
34
36
  environment:
35
37
  CIRCLE_TEST_REPORTS: "test-results"
36
38
  BUNDLE_GEMFILE: << parameters.gemfile >>
@@ -39,8 +41,8 @@ jobs:
39
41
  - checkout
40
42
  - restore_cache:
41
43
  keys:
42
- - v1-gems-ruby-2.5.8-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
43
- - v1-gems-ruby-2.5.8-
44
+ - v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
45
+ - v1-gems-ruby-<< parameters.ruby_version >>-
44
46
  - run:
45
47
  name: Install Gems
46
48
  command: |
@@ -49,7 +51,7 @@ jobs:
49
51
  bundle clean
50
52
  fi
51
53
  - save_cache:
52
- key: v1-gems-ruby-2.5.8-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
54
+ key: v1-gems-ruby-<< parameters.ruby_version >>-{{ checksum "delayed_job_groups.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
53
55
  paths:
54
56
  - "vendor/bundle"
55
57
  - "gemfiles/vendor/bundle"
@@ -67,6 +69,13 @@ workflows:
67
69
  matrix:
68
70
  parameters:
69
71
  gemfile:
70
- - "gemfiles/rails_5.2.gemfile"
71
- - "gemfiles/rails_6.0.gemfile"
72
- - "gemfiles/rails_6.1.gemfile"
72
+ - "gemfiles/rails_5.2.gemfile"
73
+ - "gemfiles/rails_6.0.gemfile"
74
+ - "gemfiles/rails_6.1.gemfile"
75
+ ruby_version:
76
+ - "2.6.6"
77
+ - "2.7.2"
78
+ - "3.0.0"
79
+ exclude:
80
+ - gemfile: "gemfiles/rails_5.2.gemfile"
81
+ ruby_version: "3.0.0"
data/.rubocop.yml CHANGED
@@ -2,10 +2,10 @@ inherit_gem:
2
2
  salsify_rubocop: conf/rubocop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
5
+ TargetRubyVersion: 2.6
6
6
  Exclude:
7
7
  - 'vendor/**/*'
8
- - 'gemfiles/vendor/**/*'
8
+ - 'gemfiles/**/*'
9
9
 
10
10
  Style/FrozenStringLiteralComment:
11
11
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Changelog
2
+ ### 0.7.0
3
+ * Add support for ruby 3
4
+ * Drop support for ruby < 2.6
2
5
 
3
6
  ### 0.6.2
4
7
  * Defer including extension until delayed_job_active_record is loaded
@@ -1,7 +1,6 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
5
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
5
  require 'delayed/job_groups/version'
7
6
 
@@ -19,12 +18,13 @@ Gem::Specification.new do |spec|
19
18
  spec.test_files = Dir.glob('spec/**/*')
20
19
  spec.require_paths = ['lib']
21
20
 
22
- spec.required_ruby_version = '>= 2.5'
21
+ spec.required_ruby_version = '>= 2.6'
23
22
 
24
23
  spec.add_dependency 'delayed_job', '>= 4.1'
25
24
  spec.add_dependency 'delayed_job_active_record', '>= 4.1'
26
25
 
27
- spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation for upgrade/installation notes.'
26
+ spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation '\
27
+ 'for upgrade/installation notes.'
28
28
 
29
29
  spec.add_development_dependency 'appraisal'
30
30
  spec.add_dependency 'activerecord', '>= 5.2', '< 7'
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'rspec', '~> 3'
36
36
  spec.add_development_dependency 'rspec-its'
37
37
  spec.add_development_dependency 'rspec_junit_formatter'
38
- spec.add_development_dependency 'salsify_rubocop', '0.52.1.1'
38
+ spec.add_development_dependency 'salsify_rubocop', '~> 1.0.1'
39
39
  spec.add_development_dependency 'simplecov'
40
40
  spec.add_development_dependency 'sqlite3'
41
41
  spec.add_development_dependency 'timecop'
@@ -7,10 +7,6 @@ module Delayed
7
7
  module JobGroups
8
8
  module Compatibility
9
9
 
10
- def self.mass_assignment_security_enabled?
11
- defined?(::ActiveRecord::MassAssignmentSecurity)
12
- end
13
-
14
10
  end
15
11
  end
16
12
  end
@@ -11,10 +11,6 @@ module Delayed
11
11
  end
12
12
 
13
13
  included do
14
- if Delayed::JobGroups::Compatibility.mass_assignment_security_enabled?
15
- attr_accessible :job_group_id, :blocked
16
- end
17
-
18
14
  belongs_to :job_group, class_name: 'Delayed::JobGroups::JobGroup', required: false
19
15
 
20
16
  class << self
@@ -8,11 +8,6 @@ module Delayed
8
8
 
9
9
  self.table_name = "#{ActiveRecord::Base.table_name_prefix}delayed_job_groups"
10
10
 
11
- if Delayed::JobGroups::Compatibility.mass_assignment_security_enabled?
12
- attr_accessible :on_completion_job, :on_completion_job_options, :blocked, :on_cancellation_job,
13
- :on_cancellation_job_options, :failure_cancels_group
14
- end
15
-
16
11
  serialize :on_completion_job, Delayed::JobGroups::YamlLoader
17
12
  serialize :on_completion_job_options, Hash
18
13
  serialize :on_cancellation_job, Delayed::JobGroups::YamlLoader
@@ -30,6 +25,7 @@ module Delayed
30
25
  def mark_queueing_complete
31
26
  with_lock do
32
27
  raise 'JobGroup has already completed queueing' if queueing_complete?
28
+
33
29
  update_column(:queueing_complete, true)
34
30
  complete if ready_for_completion?
35
31
  end
@@ -66,13 +62,14 @@ module Delayed
66
62
  # zero will queue the job group's completion job and destroy the job group so
67
63
  # other jobs need to handle the job group having been destroyed already.
68
64
  job_group = where(id: job_group_id).lock(true).first
69
- job_group.send(:complete) if job_group && job_group.send(:ready_for_completion?)
65
+ job_group.send(:complete) if job_group&.send(:ready_for_completion?)
70
66
  end
71
67
  end
72
68
 
73
69
  def self.has_pending_jobs?(job_group_ids) # rubocop:disable Naming/PredicateName
74
70
  job_group_ids = Array(job_group_ids)
75
71
  return false if job_group_ids.empty?
72
+
76
73
  Delayed::Job.where(job_group_id: job_group_ids, failed_at: nil).exists?
77
74
  end
78
75
 
@@ -21,9 +21,7 @@ module Delayed
21
21
  # If a job in the job group fails, then cancel the whole job group.
22
22
  # Need to check that the job group is present since another
23
23
  # job may have concurrently cancelled it.
24
- if job.in_job_group? && job.job_group && job.job_group.failure_cancels_group?
25
- job.job_group.cancel
26
- end
24
+ job.job_group.cancel if job.in_job_group? && job.job_group&.failure_cancels_group?
27
25
  end
28
26
 
29
27
  lifecycle.after(:perform) do |_worker, job|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Delayed
4
4
  module JobGroups
5
- VERSION = '0.6.2'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
@@ -5,11 +5,13 @@ module Delayed
5
5
  module YamlLoader
6
6
  def self.load(yaml)
7
7
  return yaml unless yaml.is_a?(String) && /^---/.match(yaml)
8
+
8
9
  YAML.load_dj(yaml)
9
10
  end
10
11
 
11
12
  def self.dump(object)
12
13
  return if object.nil?
14
+
13
15
  YAML.dump(object)
14
16
  end
15
17
  end
@@ -50,6 +50,7 @@ describe Delayed::JobGroups::JobGroup do
50
50
  before { job_group.mark_queueing_complete }
51
51
 
52
52
  it { is_expected.to be_queueing_complete }
53
+
53
54
  it_behaves_like "the job group was completed"
54
55
  end
55
56
 
@@ -59,6 +60,7 @@ describe Delayed::JobGroups::JobGroup do
59
60
  before { job_group.mark_queueing_complete }
60
61
 
61
62
  it { is_expected.to be_queueing_complete }
63
+
62
64
  it_behaves_like "the job group was not completed"
63
65
  end
64
66
 
@@ -69,6 +71,7 @@ describe Delayed::JobGroups::JobGroup do
69
71
  end
70
72
 
71
73
  it { is_expected.to be_queueing_complete }
74
+
72
75
  it_behaves_like "the job group was not completed"
73
76
  end
74
77
  end
@@ -199,6 +202,7 @@ describe Delayed::JobGroups::JobGroup do
199
202
  end
200
203
 
201
204
  its(:blocked?) { is_expected.to be(false) }
205
+
202
206
  it_behaves_like "the job group was completed"
203
207
  end
204
208
  end
@@ -5,56 +5,56 @@ describe Delayed::JobGroups::Plugin do
5
5
  @old_max_attempts = Delayed::Worker.max_attempts
6
6
  Delayed::Worker.max_attempts = 2
7
7
 
8
- CompletionJob.invoked = false
9
- CancellationJob.invoked = false
8
+ TestJobs::CompletionJob.invoked = false
9
+ TestJobs::CancellationJob.invoked = false
10
10
  end
11
11
 
12
12
  after do
13
13
  Delayed::Worker.max_attempts = @old_max_attempts
14
14
  end
15
15
 
16
- let!(:job_group) { Delayed::JobGroups::JobGroup.create!(on_completion_job: CompletionJob.new) }
16
+ let!(:job_group) { Delayed::JobGroups::JobGroup.create!(on_completion_job: TestJobs::CompletionJob.new) }
17
17
 
18
18
  it "runs the completion job after completing other jobs" do
19
- job_group.enqueue(NoOpJob.new)
20
- job_group.enqueue(NoOpJob.new)
19
+ job_group.enqueue(TestJobs::NoOpJob.new)
20
+ job_group.enqueue(TestJobs::NoOpJob.new)
21
21
  job_group.mark_queueing_complete
22
22
  expect(job_group_count).to eq 1
23
23
  expect(queued_job_count).to eq 2
24
24
 
25
25
  # Run our first job
26
26
  Delayed::Worker.new.work_off(1)
27
- expect(CompletionJob.invoked).to be(false)
27
+ expect(TestJobs::CompletionJob.invoked).to be(false)
28
28
  expect(job_group_count).to eq 1
29
29
  expect(queued_job_count).to eq 1
30
30
 
31
31
  # Run our second job which should enqueue the completion job
32
32
  Delayed::Worker.new.work_off(1)
33
- expect(CompletionJob.invoked).to be(false)
33
+ expect(TestJobs::CompletionJob.invoked).to be(false)
34
34
  expect(job_group_count).to eq 0
35
35
  expect(queued_job_count).to eq 1
36
36
 
37
37
  # Now we should run the completion job
38
38
  Delayed::Worker.new.work_off(1)
39
- expect(CompletionJob.invoked).to be(true)
39
+ expect(TestJobs::CompletionJob.invoked).to be(true)
40
40
  expect(queued_job_count).to eq 0
41
41
  end
42
42
 
43
43
  it "only runs the completion job after queueing is completed" do
44
- job_group.enqueue(NoOpJob.new)
45
- job_group.enqueue(NoOpJob.new)
44
+ job_group.enqueue(TestJobs::NoOpJob.new)
45
+ job_group.enqueue(TestJobs::NoOpJob.new)
46
46
  expect(job_group_count).to eq 1
47
47
  expect(queued_job_count).to eq 2
48
48
 
49
49
  # Run our first job
50
50
  Delayed::Worker.new.work_off(1)
51
- expect(CompletionJob.invoked).to be(false)
51
+ expect(TestJobs::CompletionJob.invoked).to be(false)
52
52
  expect(job_group_count).to eq 1
53
53
  expect(queued_job_count).to eq 1
54
54
 
55
55
  # Run our second job
56
56
  Delayed::Worker.new.work_off(1)
57
- expect(CompletionJob.invoked).to be(false)
57
+ expect(TestJobs::CompletionJob.invoked).to be(false)
58
58
  expect(job_group_count).to eq 1
59
59
  expect(queued_job_count).to eq 0
60
60
 
@@ -65,7 +65,7 @@ describe Delayed::JobGroups::Plugin do
65
65
 
66
66
  # Now we should run the completion job
67
67
  Delayed::Worker.new.work_off(1)
68
- expect(CompletionJob.invoked).to be(true)
68
+ expect(TestJobs::CompletionJob.invoked).to be(true)
69
69
  expect(queued_job_count).to eq 0
70
70
  end
71
71
 
@@ -75,8 +75,8 @@ describe Delayed::JobGroups::Plugin do
75
75
  it "cancels the group" do
76
76
  Delayed::Worker.max_attempts = 1
77
77
 
78
- job_group.enqueue(FailingJob.new)
79
- job_group.enqueue(NoOpJob.new)
78
+ job_group.enqueue(TestJobs::FailingJob.new)
79
+ job_group.enqueue(TestJobs::NoOpJob.new)
80
80
  job_group.mark_queueing_complete
81
81
  expect(queued_job_count).to eq 2
82
82
  expect(job_group_count).to eq 1
@@ -84,7 +84,7 @@ describe Delayed::JobGroups::Plugin do
84
84
  # Run the job which should fail and cancel the JobGroup
85
85
  Delayed::Worker.new.work_off(1)
86
86
  # Completion job is not invoked
87
- expect(CompletionJob.invoked).to be(false)
87
+ expect(TestJobs::CompletionJob.invoked).to be(false)
88
88
  expect(failed_job_count).to eq 1
89
89
  expect(queued_job_count).to eq 0
90
90
  expect(job_group_count).to eq 0
@@ -98,15 +98,15 @@ describe Delayed::JobGroups::Plugin do
98
98
  it "does not cancel the group" do
99
99
  Delayed::Worker.max_attempts = 1
100
100
 
101
- job_group.enqueue(FailingJob.new)
102
- job_group.enqueue(NoOpJob.new)
101
+ job_group.enqueue(TestJobs::FailingJob.new)
102
+ job_group.enqueue(TestJobs::NoOpJob.new)
103
103
  job_group.mark_queueing_complete
104
104
  expect(queued_job_count).to eq 2
105
105
  expect(job_group_count).to eq 1
106
106
 
107
107
  # Run the job which should fail don't cancel the JobGroup
108
108
  Delayed::Worker.new.work_off(1)
109
- expect(CancellationJob.invoked).to be(false)
109
+ expect(TestJobs::CancellationJob.invoked).to be(false)
110
110
  expect(failed_job_count).to eq 1
111
111
  expect(queued_job_count).to eq 1
112
112
  expect(job_group_count).to eq 1
@@ -120,7 +120,7 @@ describe Delayed::JobGroups::Plugin do
120
120
  # Run the completion job
121
121
  Delayed::Worker.new.work_off(1)
122
122
  # Completion job is invoked
123
- expect(CompletionJob.invoked).to be(true)
123
+ expect(TestJobs::CompletionJob.invoked).to be(true)
124
124
  expect(failed_job_count).to eq 1
125
125
  expect(queued_job_count).to eq 0
126
126
  expect(job_group_count).to eq 0
@@ -129,8 +129,8 @@ describe Delayed::JobGroups::Plugin do
129
129
  it "runs completion job if last job failed" do
130
130
  Delayed::Worker.max_attempts = 2
131
131
 
132
- job_group.enqueue(NoOpJob.new)
133
- job_group.enqueue(FailingJob.new)
132
+ job_group.enqueue(TestJobs::NoOpJob.new)
133
+ job_group.enqueue(TestJobs::FailingJob.new)
134
134
  job_group.mark_queueing_complete
135
135
  expect(queued_job_count).to eq 2
136
136
  expect(job_group_count).to eq 1
@@ -144,7 +144,7 @@ describe Delayed::JobGroups::Plugin do
144
144
  # Run the job which should error
145
145
  Delayed::Worker.new.work_off(1)
146
146
  # Completion job is not invoked
147
- expect(CompletionJob.invoked).to be(false)
147
+ expect(TestJobs::CompletionJob.invoked).to be(false)
148
148
  expect(failed_job_count).to eq 0
149
149
  expect(queued_job_count).to eq 1
150
150
  expect(job_group_count).to eq 1
@@ -159,7 +159,7 @@ describe Delayed::JobGroups::Plugin do
159
159
  # Run the completion job
160
160
  Delayed::Worker.new.work_off(1)
161
161
  # Completion job is invoked
162
- expect(CompletionJob.invoked).to be(true)
162
+ expect(TestJobs::CompletionJob.invoked).to be(true)
163
163
  expect(failed_job_count).to eq 1
164
164
  expect(queued_job_count).to eq 0
165
165
  expect(job_group_count).to eq 0
@@ -169,7 +169,7 @@ describe Delayed::JobGroups::Plugin do
169
169
 
170
170
  it "doesn't retry failed jobs if the job group has been canceled" do
171
171
  job_group.cancel
172
- Delayed::Job.enqueue(FailingJob.new, job_group_id: job_group.id)
172
+ Delayed::Job.enqueue(TestJobs::FailingJob.new, job_group_id: job_group.id)
173
173
  expect(queued_job_count).to eq 1
174
174
 
175
175
  # Run the job which should fail and should not queue a retry
@@ -182,8 +182,8 @@ describe Delayed::JobGroups::Plugin do
182
182
  job_group.blocked = true
183
183
  job_group.save!
184
184
 
185
- job_group.enqueue(NoOpJob.new)
186
- job_group.enqueue(NoOpJob.new)
185
+ job_group.enqueue(TestJobs::NoOpJob.new)
186
+ job_group.enqueue(TestJobs::NoOpJob.new)
187
187
  job_group.mark_queueing_complete
188
188
  expect(Delayed::Job.count).to eq 2
189
189
 
@@ -197,41 +197,41 @@ describe Delayed::JobGroups::Plugin do
197
197
 
198
198
  # Run our first job
199
199
  Delayed::Worker.new.work_off(1)
200
- expect(CompletionJob.invoked).to be(false)
200
+ expect(TestJobs::CompletionJob.invoked).to be(false)
201
201
  expect(job_group_count).to eq 1
202
202
  expect(Delayed::Job.count).to eq 1
203
203
 
204
204
  # Run our second job which should enqueue the completion job
205
205
  Delayed::Worker.new.work_off(1)
206
- expect(CompletionJob.invoked).to be(false)
206
+ expect(TestJobs::CompletionJob.invoked).to be(false)
207
207
  expect(job_group_count).to eq 0
208
208
  expect(Delayed::Job.count).to eq 1
209
209
 
210
210
  # Now we should run the completion job
211
211
  Delayed::Worker.new.work_off(1)
212
- expect(CompletionJob.invoked).to be(true)
212
+ expect(TestJobs::CompletionJob.invoked).to be(true)
213
213
  expect(Delayed::Job.count).to eq 0
214
214
  end
215
215
 
216
216
  context "when a cancellation job is provided" do
217
217
  let!(:job_group) do
218
- Delayed::JobGroups::JobGroup.create!(on_completion_job: CompletionJob.new,
219
- on_cancellation_job: CancellationJob.new)
218
+ Delayed::JobGroups::JobGroup.create!(on_completion_job: TestJobs::CompletionJob.new,
219
+ on_cancellation_job: TestJobs::CancellationJob.new)
220
220
  end
221
221
 
222
222
  it "runs the cancellation job after a job error causes cancellation" do
223
223
  Delayed::Worker.max_attempts = 1
224
224
 
225
- job_group.enqueue(FailingJob.new)
226
- job_group.enqueue(NoOpJob.new)
225
+ job_group.enqueue(TestJobs::FailingJob.new)
226
+ job_group.enqueue(TestJobs::NoOpJob.new)
227
227
  job_group.mark_queueing_complete
228
228
  expect(queued_job_count).to eq 2
229
229
  expect(job_group_count).to eq 1
230
230
 
231
231
  # Run the job which should fail and cancel the JobGroup
232
232
  Delayed::Worker.new.work_off(1)
233
- expect(CompletionJob.invoked).to be(false)
234
- expect(CancellationJob.invoked).to be(false)
233
+ expect(TestJobs::CompletionJob.invoked).to be(false)
234
+ expect(TestJobs::CancellationJob.invoked).to be(false)
235
235
  expect(failed_job_count).to eq 1
236
236
 
237
237
  expect(queued_job_count).to eq 1
@@ -239,24 +239,24 @@ describe Delayed::JobGroups::Plugin do
239
239
 
240
240
  # Now we should run the cancellation job
241
241
  Delayed::Worker.new.work_off(1)
242
- expect(CompletionJob.invoked).to be(false)
243
- expect(CancellationJob.invoked).to be(true)
242
+ expect(TestJobs::CompletionJob.invoked).to be(false)
243
+ expect(TestJobs::CancellationJob.invoked).to be(true)
244
244
  expect(queued_job_count).to eq 0
245
245
  end
246
246
 
247
247
  it "runs the cancellation job after the job group is cancelled" do
248
- job_group.enqueue(NoOpJob.new)
249
- job_group.enqueue(FailingJob.new)
248
+ job_group.enqueue(TestJobs::NoOpJob.new)
249
+ job_group.enqueue(TestJobs::FailingJob.new)
250
250
  job_group.mark_queueing_complete
251
251
  job_group.cancel
252
252
 
253
253
  # cancellation job should be queued
254
254
  expect(queued_job_count).to eq 1
255
- expect(CancellationJob.invoked).to be(false)
255
+ expect(TestJobs::CancellationJob.invoked).to be(false)
256
256
 
257
257
  # Run the cancellation job
258
258
  Delayed::Worker.new.work_off(1)
259
- expect(CancellationJob.invoked).to be(true)
259
+ expect(TestJobs::CancellationJob.invoked).to be(true)
260
260
  expect(queued_job_count).to eq 0
261
261
  end
262
262
  end
@@ -265,8 +265,8 @@ describe Delayed::JobGroups::Plugin do
265
265
  let!(:job_group) { Delayed::JobGroups::JobGroup.create! }
266
266
 
267
267
  it "doesn't queue a non-existent completion job" do
268
- job_group.enqueue(NoOpJob.new)
269
- job_group.enqueue(NoOpJob.new)
268
+ job_group.enqueue(TestJobs::NoOpJob.new)
269
+ job_group.enqueue(TestJobs::NoOpJob.new)
270
270
  job_group.mark_queueing_complete
271
271
  expect(job_group_count).to eq 1
272
272
  expect(queued_job_count).to eq 2
@@ -286,37 +286,6 @@ describe Delayed::JobGroups::Plugin do
286
286
  end
287
287
  end
288
288
 
289
- class FailingJob
290
-
291
- def perform
292
- raise 'Test failure'
293
- end
294
-
295
- end
296
-
297
- class NoOpJob
298
-
299
- def perform
300
-
301
- end
302
- end
303
-
304
- class CompletionJob
305
- cattr_accessor :invoked
306
-
307
- def perform
308
- CompletionJob.invoked = true
309
- end
310
- end
311
-
312
- class CancellationJob
313
- cattr_accessor :invoked
314
-
315
- def perform
316
- CancellationJob.invoked = true
317
- end
318
- end
319
-
320
289
  def job_group_count
321
290
  Delayed::JobGroups::JobGroup.count
322
291
  end
@@ -1,14 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe Delayed::JobGroups::YamlLoader do
4
- class Foo; end
5
-
6
4
  describe "#load" do
7
5
  context "with a correct yaml object representation" do
8
- let(:yaml) { '--- !ruby/object:Foo {}' }
6
+ let(:yaml) { '--- !ruby/object:TestJobs::Foo {}' }
9
7
 
10
8
  it "deserializes from YAML properly" do
11
- expect(Delayed::JobGroups::YamlLoader.load(yaml)).to be_a(Foo)
9
+ expect(Delayed::JobGroups::YamlLoader.load(yaml)).to be_a(TestJobs::Foo)
12
10
  end
13
11
  end
14
12
 
@@ -25,10 +23,10 @@ describe Delayed::JobGroups::YamlLoader do
25
23
 
26
24
  describe "#dump" do
27
25
  context "with an object" do
28
- let(:object) { Foo.new }
26
+ let(:object) { TestJobs::Foo.new }
29
27
 
30
28
  it "serializes into YAML properly" do
31
- expect(Delayed::JobGroups::YamlLoader.dump(object)).to eq("--- !ruby/object:Foo {}\n")
29
+ expect(Delayed::JobGroups::YamlLoader.dump(object)).to eq("--- !ruby/object:TestJobs::Foo {}\n")
32
30
  end
33
31
  end
34
32
 
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TestJobs
4
+ class Foo; end
5
+
6
+ class FailingJob
7
+ def perform
8
+ raise 'Test failure'
9
+ end
10
+ end
11
+
12
+ class NoOpJob
13
+ def perform
14
+
15
+ end
16
+ end
17
+
18
+ class CompletionJob
19
+ cattr_accessor :invoked
20
+
21
+ def perform
22
+ CompletionJob.invoked = true
23
+ end
24
+ end
25
+
26
+ class CancellationJob
27
+ cattr_accessor :invoked
28
+
29
+ def perform
30
+ CancellationJob.invoked = true
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_job_groups_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Turkel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-29 00:00:00.000000000 Z
12
+ date: 2021-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: delayed_job
@@ -175,16 +175,16 @@ dependencies:
175
175
  name: salsify_rubocop
176
176
  requirement: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '='
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 0.52.1.1
180
+ version: 1.0.1
181
181
  type: :development
182
182
  prerelease: false
183
183
  version_requirements: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - '='
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: 0.52.1.1
187
+ version: 1.0.1
188
188
  - !ruby/object:Gem::Dependency
189
189
  name: simplecov
190
190
  requirement: !ruby/object:Gem::Requirement
@@ -268,6 +268,7 @@ files:
268
268
  - spec/delayed/job_groups/yaml_loader_spec.rb
269
269
  - spec/spec_helper.rb
270
270
  - spec/support/destroyed_model.rb
271
+ - spec/support/test_jobs.rb
271
272
  homepage: https://github.com/salsify/delayed_job_groups_plugin
272
273
  licenses:
273
274
  - MIT
@@ -281,20 +282,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
282
  requirements:
282
283
  - - ">="
283
284
  - !ruby/object:Gem::Version
284
- version: '2.5'
285
+ version: '2.6'
285
286
  required_rubygems_version: !ruby/object:Gem::Requirement
286
287
  requirements:
287
288
  - - ">="
288
289
  - !ruby/object:Gem::Version
289
290
  version: '0'
290
291
  requirements: []
291
- rubygems_version: 3.0.8
292
+ rubygems_version: 3.1.4
292
293
  signing_key:
293
294
  specification_version: 4
294
295
  summary: Delayed::Job job groups plugin
295
296
  test_files:
296
297
  - spec/spec_helper.rb
297
298
  - spec/support/destroyed_model.rb
299
+ - spec/support/test_jobs.rb
298
300
  - spec/delayed/job_groups/plugin_spec.rb
299
301
  - spec/delayed/job_groups/job_group_spec.rb
300
302
  - spec/delayed/job_groups/yaml_loader_spec.rb