scheduled_job 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/scheduled_job.rb +2 -4
- data/spec/lib/scheduled_job_spec.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e74d081e54d0af0a05929b690768698275473078
|
4
|
+
data.tar.gz: e4a12cc9089271971a3359a21cb056cc51c8e8fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8a132116ecb9bf0a9be607a99a548abcea5e968579fc0ea0da10c61c5ab8913e5c06d390be4843aa205abd684b91fe822c21a6c3d61f9243ee3a436ee61b0db
|
7
|
+
data.tar.gz: eb0a87986ee873ce1aafc619f66a23a52af25e0e62f0b77040ea243b93a1426f37ea369a07fb951e51461e63d02f8dc2d4c1b380d1ae1519267f9119735b3efb
|
data/lib/scheduled_job.rb
CHANGED
@@ -98,10 +98,8 @@ module ScheduledJob
|
|
98
98
|
|
99
99
|
def can_schedule_job?(job = nil)
|
100
100
|
conditions = 'failed_at IS NULL'
|
101
|
-
unless job.blank?
|
102
|
-
|
103
|
-
conditions << job.id
|
104
|
-
end
|
101
|
+
conditions << " AND id != #{job.id}" unless job.blank?
|
102
|
+
|
105
103
|
jobs = Delayed::Job.where(conditions).find_all do |dj|
|
106
104
|
dj.handler.split[1][/(?<=:)[A-Z][A-z0-9:]+/] == self.name
|
107
105
|
end
|
@@ -16,6 +16,12 @@ class UnderTest
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
class Job
|
20
|
+
def id
|
21
|
+
12
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
19
25
|
class Test < UnderTest
|
20
26
|
end
|
21
27
|
|
@@ -220,6 +226,10 @@ describe ScheduledJob do
|
|
220
226
|
under_test.failure(dummy_job)
|
221
227
|
end
|
222
228
|
|
229
|
+
it "can scheduled additional instances of a given job" do
|
230
|
+
expect { UnderTest.schedule_job(Job.new) }.not_to raise_error
|
231
|
+
end
|
232
|
+
|
223
233
|
describe '#random_minutes' do
|
224
234
|
it 'returns a random number with a base and delta' do
|
225
235
|
expect(UnderTest.random_minutes(60, 10)).to be_within(10 * 60).of(60 * 60)
|