scheduled_job 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scheduled_job/version.rb +1 -1
- data/lib/scheduled_job.rb +4 -2
- data/spec/lib/scheduled_job_spec.rb +32 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2590a66e0483fc860bcd72540f5c090252aa1db
|
4
|
+
data.tar.gz: dc50581bb5623d78cfea46c9ee52416b8a7b7d73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9ed8efc2da1119e73798b41c8f248c39e74c9ac01819da4ce06aa2387acb14c7ecc71b53f4f70be3fafd804079fcef7f6bb639bff17e764895b407b4f810e45
|
7
|
+
data.tar.gz: d780b20bf9795d9cc8bdb7525a40ade71f1a7c8d3c5f0e63b571d59f64dbccda01d40ef77ceedf26297e01b1d2744d503c75876e81f7298cd5ac69151b433ba6
|
data/lib/scheduled_job.rb
CHANGED
@@ -5,7 +5,10 @@ require 'delayed_job_active_record'
|
|
5
5
|
|
6
6
|
module ScheduledJob
|
7
7
|
class << self
|
8
|
-
|
8
|
+
attr_writer :config
|
9
|
+
def config
|
10
|
+
@config ||= Config.new
|
11
|
+
end
|
9
12
|
end
|
10
13
|
|
11
14
|
def self.logger
|
@@ -13,7 +16,6 @@ module ScheduledJob
|
|
13
16
|
end
|
14
17
|
|
15
18
|
def self.configure
|
16
|
-
self.config ||= Config.new
|
17
19
|
yield(config)
|
18
20
|
end
|
19
21
|
|
@@ -20,6 +20,20 @@ describe ScheduledJob do
|
|
20
20
|
|
21
21
|
let(:under_test) { UnderTest.new }
|
22
22
|
|
23
|
+
describe '.config' do
|
24
|
+
context 'without .configure call' do
|
25
|
+
before do
|
26
|
+
# Reload ScheduledJob class
|
27
|
+
Object.send :remove_const, :ScheduledJob if Object.const_defined? :ScheduledJob
|
28
|
+
load 'scheduled_job.rb'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'has default value' do
|
32
|
+
expect(ScheduledJob.config).not_to be_nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
23
37
|
describe 'fast mode' do
|
24
38
|
before { expect(Delayed::Job).to receive(:exists?).and_return(false) }
|
25
39
|
|
@@ -99,25 +113,25 @@ describe ScheduledJob do
|
|
99
113
|
under_test.error job, nil
|
100
114
|
end
|
101
115
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
116
|
+
it "wraps delayed job with scheduled_job" do
|
117
|
+
job = double("job")
|
118
|
+
allow(job).to receive(:id) { 4 }
|
119
|
+
instance = double("instance")
|
120
|
+
allow(UnderTest).to receive(:new) { instance }
|
121
|
+
expect(Delayed::Job).to receive(:exists?).and_return(false)
|
122
|
+
expect(Delayed::Job).to receive(:enqueue).with(instance, run_at: "time to recur", queue: "TESTING")
|
123
|
+
UnderTest.schedule_job job
|
124
|
+
end
|
111
125
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
126
|
+
it "scheduled a job even if there is total failure and an existing job" do
|
127
|
+
dummy_job = double("job")
|
128
|
+
allow(dummy_job).to receive(:id)
|
129
|
+
expect(dummy_job).to receive(:update_attributes!)
|
130
|
+
expect(Delayed::Job).to receive(:exists?).twice.and_return(false)
|
131
|
+
expect(Delayed::Job).to receive(:enqueue).exactly(2).times
|
132
|
+
UnderTest.schedule_job
|
133
|
+
under_test.failure(dummy_job)
|
134
|
+
end
|
121
135
|
|
122
136
|
describe '#random_minutes' do
|
123
137
|
it 'returns a random number with a base and delta' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scheduled_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CallumD
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-09
|
14
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: delayed_job
|