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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cef8e199094465991dc7440af386fa97eff33749
4
- data.tar.gz: 8ec852dd635846475f9e35ded1e1a38acda824f6
3
+ metadata.gz: e2590a66e0483fc860bcd72540f5c090252aa1db
4
+ data.tar.gz: dc50581bb5623d78cfea46c9ee52416b8a7b7d73
5
5
  SHA512:
6
- metadata.gz: 0f096a356f01808cc56d45607a3202295537cc588f00d5703d5817b7d864e3e5c51ab680b710663f2f1112f8d30b755a0d8d3599782bc546428b5585e6013206
7
- data.tar.gz: 4f26d8733595ab7262014a5e431d184fbe6a9ccd5642bd02dc929b760cd50e7c365bc9042fcec652fcd251fd100e8b78f3df5570df8c895cf37b710dc91208d7
6
+ metadata.gz: e9ed8efc2da1119e73798b41c8f248c39e74c9ac01819da4ce06aa2387acb14c7ecc71b53f4f70be3fafd804079fcef7f6bb639bff17e764895b407b4f810e45
7
+ data.tar.gz: d780b20bf9795d9cc8bdb7525a40ade71f1a7c8d3c5f0e63b571d59f64dbccda01d40ef77ceedf26297e01b1d2744d503c75876e81f7298cd5ac69151b433ba6
@@ -1,3 +1,3 @@
1
1
  module ScheduledJob
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
- attr_accessor :config
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
- it "wraps delayed job with scheduled_job" do
103
- job = double("job")
104
- allow(job).to receive(:id) { 4 }
105
- instance = double("instance")
106
- allow(UnderTest).to receive(:new) { instance }
107
- expect(Delayed::Job).to receive(:exists?).and_return(false)
108
- expect(Delayed::Job).to receive(:enqueue).with(instance, run_at: "time to recur", queue: "TESTING")
109
- UnderTest.schedule_job job
110
- end
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
- it "scheduled a job even if there is total failure and an existing job" do
113
- dummy_job = double("job")
114
- allow(dummy_job).to receive(:id)
115
- expect(dummy_job).to receive(:update_attributes!)
116
- expect(Delayed::Job).to receive(:exists?).twice.and_return(false)
117
- expect(Delayed::Job).to receive(:enqueue).exactly(2).times
118
- UnderTest.schedule_job
119
- under_test.failure(dummy_job)
120
- end
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
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-22 00:00:00.000000000 Z
14
+ date: 2014-10-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: delayed_job