scheduled_job 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/lib/scheduled_job/version.rb +1 -1
- data/scheduled_job.gemspec +2 -2
- data/spec/lib/scheduled_job_spec.rb +14 -16
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc50c93ff5bc74fac03fa21b0b801965b61d5ff
|
4
|
+
data.tar.gz: fdd37637012521cfa3210e3ef5f67c2150b63bf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09ea727564792be7b830bef05c9ff0cedebb375d7f801e7be3d646c19016e207944b8285c974bd5384f00771bfd8ef3ce512e5b31e7346f233b1650bf3af1ac1
|
7
|
+
data.tar.gz: 61ddd588eb11ca8d9607f3d89511447065cb1abedd753ae26c32162984359178c999cd20c099130b811767d4ab6d591565b0e98b96dd6a66cb9549133c0c5fdd
|
data/README.md
CHANGED
@@ -118,7 +118,7 @@ end
|
|
118
118
|
|
119
119
|
The before_callback is executed before the perform method is called on the scheduled job. This is passed the delayed job object and the scheduled job instance.
|
120
120
|
|
121
|
-
```ruby
|
121
|
+
```ruby
|
122
122
|
config.before_callback = -> (job, scheduled_job) do
|
123
123
|
JobRunLogger.update_attributes!(job_name: scheduled_job.class.name, started_at: Time.now.utc)
|
124
124
|
end
|
@@ -142,8 +142,15 @@ end
|
|
142
142
|
|
143
143
|
## Contributing
|
144
144
|
|
145
|
-
1. Fork it (
|
145
|
+
1. Fork it ( https://github.com/rightscale/scheduled_job/fork )
|
146
146
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
147
147
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
148
148
|
4. Push to the branch (`git push origin my-new-feature`)
|
149
149
|
5. Create new Pull Request
|
150
|
+
|
151
|
+
## Maintained by
|
152
|
+
|
153
|
+
- [Callum Dryden](https://github.com/CallumD)
|
154
|
+
- [Alistair Scott](https://github.com/aliscott)
|
155
|
+
- [Sean McGivern](https://github.com/smcgivern)
|
156
|
+
- [Ali Khajeh-Hosseini](https://github.com/alikhajeh1)
|
data/scheduled_job.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "delayed_job", "
|
22
|
-
spec.add_runtime_dependency "delayed_job_active_record", "
|
21
|
+
spec.add_runtime_dependency "delayed_job", "< 4.1"
|
22
|
+
spec.add_runtime_dependency "delayed_job_active_record", "< 4.1"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.5"
|
25
25
|
spec.add_development_dependency "rake", "~> 0.9"
|
@@ -25,7 +25,7 @@ describe ScheduledJob do
|
|
25
25
|
|
26
26
|
context 'when the job is not in run fast mode' do
|
27
27
|
it 'uses the value from time to recur' do
|
28
|
-
Delayed::Job.
|
28
|
+
expect(Delayed::Job).to receive(:enqueue).with(anything, {
|
29
29
|
:run_at => UnderTest.time_to_recur(nil),
|
30
30
|
:queue => UnderTest.queue_name
|
31
31
|
})
|
@@ -36,16 +36,14 @@ describe ScheduledJob do
|
|
36
36
|
context 'when the job is in run fast mode' do
|
37
37
|
before do
|
38
38
|
ScheduledJob.configure do |config|
|
39
|
-
config.fast_mode =
|
40
|
-
true
|
41
|
-
end
|
39
|
+
config.fast_mode = lambda { |_| true }
|
42
40
|
end
|
43
41
|
end
|
44
42
|
it 'uses the current time' do
|
45
43
|
time = Time.now.utc
|
46
|
-
Time.
|
44
|
+
allow(Time).to receive_message_chain(:now, :utc) { time }
|
47
45
|
|
48
|
-
Delayed::Job.
|
46
|
+
expect(Delayed::Job).to receive(:enqueue).with(anything, {
|
49
47
|
:run_at => time,
|
50
48
|
:queue => UnderTest.queue_name
|
51
49
|
})
|
@@ -67,10 +65,10 @@ describe ScheduledJob do
|
|
67
65
|
|
68
66
|
it "schedules a new job on success" do
|
69
67
|
expect(UnderTest).to receive(:schedule_job)
|
70
|
-
Delayed::Job.
|
68
|
+
allow(Delayed::Job).to receive(:enqueue)
|
71
69
|
underTestJob = double("UnderTestJob");
|
72
|
-
underTestJob.
|
73
|
-
underTestJob.
|
70
|
+
allow(underTestJob).to receive(:run_at) { DateTime.now.utc }
|
71
|
+
allow(underTestJob).to receive(:id) { 1 }
|
74
72
|
under_test.before underTestJob
|
75
73
|
under_test.success underTestJob
|
76
74
|
end
|
@@ -81,11 +79,11 @@ describe ScheduledJob do
|
|
81
79
|
|
82
80
|
it "logs the error and schedules a job on failure" do
|
83
81
|
dummy_job = double("job")
|
84
|
-
dummy_job.
|
82
|
+
allow(dummy_job).to receive(:id)
|
85
83
|
expect(dummy_job).to receive(:update_attributes!)
|
86
84
|
expect(ScheduledJob.logger).to receive(:error)
|
87
85
|
expect(UnderTest).to receive(:schedule_job)
|
88
|
-
Delayed::Job.
|
86
|
+
allow(Delayed::Job).to receive(:enqueue)
|
89
87
|
under_test.failure(dummy_job)
|
90
88
|
end
|
91
89
|
|
@@ -95,17 +93,17 @@ describe ScheduledJob do
|
|
95
93
|
|
96
94
|
it "logs on error" do
|
97
95
|
job = double("job")
|
98
|
-
job.
|
96
|
+
allow(job).to receive(:id) { 4 }
|
99
97
|
expect(ScheduledJob.logger).to receive(:warn)
|
100
|
-
UnderTest.
|
98
|
+
allow(UnderTest).to receive(:schedule_job)
|
101
99
|
under_test.error job, nil
|
102
100
|
end
|
103
101
|
|
104
102
|
it "wraps delayed job with scheduled_job" do
|
105
103
|
job = double("job")
|
106
|
-
job.
|
104
|
+
allow(job).to receive(:id) { 4 }
|
107
105
|
instance = double("instance")
|
108
|
-
UnderTest.
|
106
|
+
allow(UnderTest).to receive(:new) { instance }
|
109
107
|
expect(Delayed::Job).to receive(:exists?).and_return(false)
|
110
108
|
expect(Delayed::Job).to receive(:enqueue).with(instance, run_at: "time to recur", queue: "TESTING")
|
111
109
|
UnderTest.schedule_job job
|
@@ -113,7 +111,7 @@ describe ScheduledJob do
|
|
113
111
|
|
114
112
|
it "scheduled a job even if there is total failure and an existing job" do
|
115
113
|
dummy_job = double("job")
|
116
|
-
dummy_job.
|
114
|
+
allow(dummy_job).to receive(:id)
|
117
115
|
expect(dummy_job).to receive(:update_attributes!)
|
118
116
|
expect(Delayed::Job).to receive(:exists?).twice.and_return(false)
|
119
117
|
expect(Delayed::Job).to receive(:enqueue).exactly(2).times
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CallumD
|
@@ -11,36 +11,36 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: delayed_job
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
|
-
- -
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: '4.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - "<"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '4.1'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: delayed_job_active_record
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: '4.1'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - "<"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: '4.1'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: bundler
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|