rocketjob 1.3.0 → 2.0.0.rc1

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +201 -0
  3. data/README.md +15 -10
  4. data/bin/rocketjob +3 -1
  5. data/bin/rocketjob_perf +92 -0
  6. data/lib/rocket_job/cli.rb +71 -31
  7. data/lib/rocket_job/config.rb +21 -23
  8. data/lib/rocket_job/dirmon_entry.rb +63 -45
  9. data/lib/rocket_job/extensions/aasm.rb +56 -0
  10. data/lib/rocket_job/extensions/mongo.rb +23 -0
  11. data/lib/rocket_job/job.rb +9 -433
  12. data/lib/rocket_job/jobs/dirmon_job.rb +20 -20
  13. data/lib/rocket_job/jobs/simple_job.rb +12 -0
  14. data/lib/rocket_job/plugins/document.rb +69 -0
  15. data/lib/rocket_job/plugins/job/callbacks.rb +92 -0
  16. data/lib/rocket_job/plugins/job/defaults.rb +40 -0
  17. data/lib/rocket_job/plugins/job/logger.rb +36 -0
  18. data/lib/rocket_job/plugins/job/model.rb +288 -0
  19. data/lib/rocket_job/plugins/job/persistence.rb +167 -0
  20. data/lib/rocket_job/plugins/job/state_machine.rb +166 -0
  21. data/lib/rocket_job/plugins/job/worker.rb +167 -0
  22. data/lib/rocket_job/plugins/restart.rb +54 -0
  23. data/lib/rocket_job/plugins/singleton.rb +26 -0
  24. data/lib/rocket_job/plugins/state_machine.rb +105 -0
  25. data/lib/rocket_job/version.rb +1 -1
  26. data/lib/rocket_job/worker.rb +150 -119
  27. data/lib/rocketjob.rb +43 -21
  28. data/test/config_test.rb +12 -0
  29. data/test/dirmon_entry_test.rb +81 -85
  30. data/test/dirmon_job_test.rb +40 -28
  31. data/test/job_test.rb +14 -257
  32. data/test/plugins/job/callbacks_test.rb +163 -0
  33. data/test/plugins/job/defaults_test.rb +52 -0
  34. data/test/plugins/job/logger_test.rb +58 -0
  35. data/test/plugins/job/model_test.rb +97 -0
  36. data/test/plugins/job/persistence_test.rb +81 -0
  37. data/test/plugins/job/state_machine_test.rb +118 -0
  38. data/test/plugins/job/worker_test.rb +183 -0
  39. data/test/plugins/restart_test.rb +185 -0
  40. data/test/plugins/singleton_test.rb +94 -0
  41. data/test/plugins/state_machine_event_callbacks_test.rb +101 -0
  42. data/test/plugins/state_machine_test.rb +64 -0
  43. data/test/test_helper.rb +3 -36
  44. metadata +64 -19
  45. data/lib/rocket_job/concerns/singleton.rb +0 -33
  46. data/lib/rocket_job/concerns/worker.rb +0 -214
  47. data/test/files/_archive/archived.txt +0 -3
  48. data/test/job_worker_test.rb +0 -86
  49. data/test/jobs/test_job.rb +0 -46
  50. data/test/worker_test.rb +0 -97
data/test/job_test.rb CHANGED
@@ -1,25 +1,18 @@
1
1
  require_relative 'test_helper'
2
- require_relative 'jobs/test_job'
3
2
 
4
3
  # Unit Test for RocketJob::Job
5
4
  class JobTest < Minitest::Test
5
+
6
+ class SimpleJob < RocketJob::Job
7
+ def perform
8
+ end
9
+ end
10
+
6
11
  describe RocketJob::Job do
7
12
  before do
8
- @worker = RocketJob::Worker.new
9
- @worker.started
10
13
  @description = 'Hello World'
11
- @arguments = [1]
12
- @job = Jobs::TestJob.new(
13
- description: @description,
14
- arguments: @arguments,
15
- destroy_on_complete: false
16
- )
17
- @job2 = Jobs::TestJob.new(
18
- description: "#{@description} 2",
19
- arguments: @arguments,
20
- destroy_on_complete: false,
21
- priority: 52
22
- )
14
+ @job = SimpleJob.new(description: @description)
15
+ @job2 = SimpleJob.new(description: @description, priority: 52)
23
16
  end
24
17
 
25
18
  after do
@@ -27,52 +20,6 @@ class JobTest < Minitest::Test
27
20
  @job2.destroy if @job2 && !@job2.new_record?
28
21
  end
29
22
 
30
- describe '.config' do
31
- it 'support multiple databases' do
32
- assert_equal 'test_rocketjob', RocketJob::Job.collection.db.name
33
- end
34
- end
35
-
36
- describe '#reload' do
37
- it 'handle hash' do
38
- @job = Jobs::TestJob.new(
39
- description: @description,
40
- arguments: [{key: 'value'}],
41
- destroy_on_complete: false,
42
- worker_name: 'worker:123'
43
- )
44
-
45
- assert_equal 'value', @job.arguments.first[:key]
46
- @job.worker_name = nil
47
- @job.save!
48
- @job.worker_name = '123'
49
- @job.reload
50
- assert @job.arguments.first.is_a?(ActiveSupport::HashWithIndifferentAccess), @job.arguments.first.class.inspect
51
- assert_equal 'value', @job.arguments.first['key']
52
- assert_equal 'value', @job.arguments.first[:key]
53
- assert_equal nil, @job.worker_name
54
- end
55
- end
56
-
57
- describe '#save!' do
58
- it 'save a blank job' do
59
- @job.save!
60
- assert_nil @job.worker_name
61
- assert_nil @job.completed_at
62
- assert @job.created_at
63
- assert_equal @description, @job.description
64
- assert_equal false, @job.destroy_on_complete
65
- assert_nil @job.expires_at
66
- assert_equal @arguments, @job.arguments
67
- assert_equal 0, @job.percent_complete
68
- assert_equal 51, @job.priority
69
- assert_equal 0, @job.failure_count
70
- assert_nil @job.run_at
71
- assert_nil @job.started_at
72
- assert_equal :queued, @job.state
73
- end
74
- end
75
-
76
23
  describe '#status' do
77
24
  it 'return status for a queued job' do
78
25
  assert_equal true, @job.queued?
@@ -91,182 +38,6 @@ class JobTest < Minitest::Test
91
38
  assert_equal 'RocketJob::JobException', h['exception']['class_name'], h
92
39
  assert_equal 'oh no', h['exception']['message'], h
93
40
  end
94
-
95
- it 'mark user as reason for failure when not supplied' do
96
- @job.start!
97
- @job.fail!
98
- assert_equal true, @job.failed?
99
- assert_equal @description, @job.description
100
- assert_equal 'RocketJob::JobException', @job.exception.class_name
101
- assert_equal 'Job failed through user action', @job.exception.message
102
- assert_equal 'user', @job.exception.worker_name
103
- end
104
- end
105
-
106
- describe '#fail_with_exception!' do
107
- it 'fail with message' do
108
- @job.start!
109
- @job.fail!('myworker:2323', 'oh no')
110
- assert_equal true, @job.failed?
111
- h = @job.status
112
- assert_equal :failed, h['state']
113
- assert_equal @description, h['description']
114
- assert_equal 'RocketJob::JobException', h['exception']['class_name'], h
115
- assert_equal 'oh no', h['exception']['message'], h
116
- end
117
-
118
- it 'fail with exception' do
119
- @job.start!
120
- exception = nil
121
- begin
122
- blah
123
- rescue Exception => exc
124
- exception = exc
125
- end
126
- @job.fail!('myworker:2323', exception)
127
- assert_equal true, @job.failed?
128
- h = @job.status
129
- assert_equal :failed, h['state']
130
- assert_equal @description, h['description']
131
- assert_equal exception.class.name.to_s, h['exception']['class_name'], h
132
- assert h['exception']['message'].include?('undefined local variable or method'), h
133
- end
134
- end
135
-
136
- describe '#work' do
137
- it 'call default perform method' do
138
- @job.start!
139
- assert_equal false, @job.work(@worker)
140
- assert_equal true, @job.completed?, @job.state
141
- assert_equal 2, Jobs::TestJob.result
142
- end
143
-
144
- it 'call specific method' do
145
- @job.perform_method = :sum
146
- @job.arguments = [23, 45]
147
- @job.start!
148
- assert_equal false, @job.work(@worker)
149
- assert_equal true, @job.completed?
150
- assert_equal 68, Jobs::TestJob.result
151
- end
152
-
153
- it 'destroy on complete' do
154
- @job.destroy_on_complete = true
155
- @job.start!
156
- assert_equal false, @job.work(@worker)
157
- assert @job.completed?, @job.state
158
- assert_equal 0, RocketJob::Job.where(id: @job.id).count
159
- end
160
-
161
- it 'silence logging when log_level is set' do
162
- @job.destroy_on_complete = true
163
- @job.log_level = :warn
164
- @job.perform_method = :noisy_logger
165
- @job.arguments = []
166
- @job.start!
167
- logged = false
168
- Jobs::TestJob.logger.stub(:log_internal, -> level, index, message, payload, exception { logged = true if message.include?('some very noisy logging') }) do
169
- assert_equal false, @job.work(@worker), @job.inspect
170
- end
171
- assert_equal false, logged
172
- end
173
-
174
- it 'raise logging when log_level is set' do
175
- @job.destroy_on_complete = true
176
- @job.log_level = :trace
177
- @job.perform_method = :debug_logging
178
- @job.arguments = []
179
- @job.start!
180
- logged = false
181
- # Raise global log level to :info
182
- SemanticLogger.stub(:default_level_index, 3) do
183
- Jobs::TestJob.logger.stub(:log_internal, -> { logged = true }) do
184
- assert_equal false, @job.work(@worker)
185
- end
186
- end
187
- assert_equal false, logged
188
- end
189
-
190
- it 'call before and after' do
191
- named_parameters = {'counter' => 23}
192
- @job.perform_method = :event
193
- @job.arguments = [named_parameters]
194
- @job.start!
195
- assert_equal false, @job.work(@worker), @job.inspect
196
- assert_equal true, @job.completed?
197
- assert_equal named_parameters.merge('before_event' => true, 'after_event' => true), @job.arguments.first
198
- end
199
-
200
- end
201
-
202
- describe '.next_job' do
203
- before do
204
- RocketJob::Job.destroy_all
205
- end
206
-
207
- it 'return nil when no jobs available' do
208
- assert_equal nil, RocketJob::Job.next_job(@worker.name)
209
- end
210
-
211
- it 'return the first job' do
212
- @job.save!
213
- assert job = RocketJob::Job.next_job(@worker.name), 'Failed to find job'
214
- assert_equal @job.id, job.id
215
- end
216
-
217
- it 'Ignore future dated jobs' do
218
- @job.run_at = Time.now + 1.hour
219
- @job.save!
220
- assert_equal nil, RocketJob::Job.next_job(@worker.name)
221
- end
222
-
223
- it 'Process future dated jobs when time is now' do
224
- @job.run_at = Time.now
225
- @job.save!
226
- assert job = RocketJob::Job.next_job(@worker.name), 'Failed to find future job'
227
- assert_equal @job.id, job.id
228
- end
229
-
230
- it 'Skip expired jobs' do
231
- count = RocketJob::Job.count
232
- @job.expires_at = Time.now - 100
233
- @job.save!
234
- assert_equal nil, RocketJob::Job.next_job(@worker.name)
235
- assert_equal count, RocketJob::Job.count
236
- end
237
- end
238
-
239
- describe '#requeue!' do
240
- it 'requeue jobs from dead workers' do
241
- worker_name = 'server:12345'
242
- @job.worker_name = worker_name
243
- @job.start!
244
- assert @job.running?
245
-
246
- @job.requeue!
247
- @job.reload
248
-
249
- assert @job.queued?
250
- assert_equal nil, @job.worker_name
251
- end
252
- end
253
-
254
- describe '#requeue' do
255
- it 'requeue jobs from dead workers' do
256
- worker_name = 'server:12345'
257
- @job.worker_name = worker_name
258
- assert @job.valid?, @job.errors.messages
259
- @job.start!
260
- assert @job.running?, @job.state
261
-
262
- @job.requeue
263
- assert @job.queued?
264
- assert_equal nil, @job.worker_name
265
-
266
- @job.reload
267
- assert @job.running?
268
- assert_equal worker_name, @job.worker_name
269
- end
270
41
  end
271
42
 
272
43
  describe '.requeue_dead_worker' do
@@ -280,6 +51,9 @@ class JobTest < Minitest::Test
280
51
  worker_name2 = 'server:76467'
281
52
  @job2.worker_name = worker_name2
282
53
  @job2.start!
54
+ assert_equal true, @job2.valid?
55
+ assert @job2.running?, @job2.state
56
+ @job2.save!
283
57
 
284
58
  RocketJob::Job.requeue_dead_worker(worker_name)
285
59
  @job.reload
@@ -287,28 +61,11 @@ class JobTest < Minitest::Test
287
61
  assert @job.queued?
288
62
  assert_equal nil, @job.worker_name
289
63
 
64
+ assert_equal worker_name2, @job2.worker_name
290
65
  @job2.reload
291
- assert @job2.running?
292
66
  assert_equal worker_name2, @job2.worker_name
293
- end
294
- end
295
-
296
- describe '#retry!' do
297
- it 'retry failed jobs' do
298
- worker_name = 'server:12345'
299
- @job.worker_name = worker_name
300
- @job.start!
301
- assert @job.running?
302
- assert_equal worker_name, @job.worker_name
303
-
304
- @job.fail!(worker_name, 'oh no')
305
- assert @job.failed?
306
- assert_equal 'oh no', @job.exception.message
307
-
308
- @job.retry!
309
- assert @job.queued?
310
- assert_equal nil, @job.worker_name
311
- assert_equal nil, @job.exception
67
+ assert @job2.running?, @job2.state
68
+ assert_equal worker_name2, @job2.worker_name
312
69
  end
313
70
  end
314
71
 
@@ -0,0 +1,163 @@
1
+ require_relative '../../test_helper'
2
+
3
+ module Plugins
4
+ module Job
5
+ # Unit Test for RocketJob::Job
6
+ class CallbacksTest < Minitest::Test
7
+ # This job adds each callback as they run into an array
8
+ class BeforePerformJob < RocketJob::Job
9
+ before_perform do
10
+ arguments.first << 'before_perform_block'
11
+ end
12
+
13
+ before_perform :before_perform_method
14
+
15
+ def perform(list)
16
+ list << 'perform'
17
+ end
18
+
19
+ private
20
+
21
+ def before_perform_method
22
+ arguments.first << 'before_perform_method'
23
+ end
24
+
25
+ end
26
+
27
+ # This job adds each callback as they run into an array
28
+ class AfterPerformJob < RocketJob::Job
29
+ after_perform do
30
+ arguments.first << 'after_perform_block'
31
+ end
32
+
33
+ after_perform :after_perform_method
34
+
35
+ def perform(list)
36
+ list << 'perform'
37
+ end
38
+
39
+ private
40
+
41
+ def after_perform_method
42
+ arguments.first << 'after_perform_method'
43
+ end
44
+
45
+ end
46
+
47
+ # This job adds each callback as they run into an array
48
+ class AroundPerformJob < RocketJob::Job
49
+ around_perform do |job, block|
50
+ arguments.first << 'around_perform_block_before'
51
+ block.call
52
+ arguments.first << 'around_perform_block_after'
53
+ end
54
+
55
+ around_perform :around_perform_method
56
+
57
+ def perform(list)
58
+ list << 'perform'
59
+ end
60
+
61
+ private
62
+
63
+ def around_perform_method
64
+ arguments.first << 'around_perform_method_before'
65
+ yield
66
+ arguments.first << 'around_perform_method_after'
67
+ end
68
+
69
+ end
70
+
71
+ # This job adds each callback as they run into an array
72
+ class CombinedPerformJob < RocketJob::Job
73
+ before_perform do
74
+ arguments.first << 'before_perform_block'
75
+ end
76
+
77
+ after_perform do
78
+ arguments.first << 'after_perform_block'
79
+ end
80
+
81
+ around_perform do |job, block|
82
+ arguments.first << 'around_perform_block_before'
83
+ block.call
84
+ arguments.first << 'around_perform_block_after'
85
+ end
86
+
87
+ before_perform :before_perform_method
88
+
89
+ around_perform :around_perform_method
90
+
91
+ after_perform :after_perform_method
92
+
93
+ def perform(list)
94
+ list << 'perform'
95
+ end
96
+
97
+ private
98
+
99
+ def before_perform_method
100
+ arguments.first << 'before_perform_method'
101
+ end
102
+
103
+ def around_perform_method(&block)
104
+ arguments.first << 'around_perform_method_before'
105
+ block.call
106
+ arguments.first << 'around_perform_method_after'
107
+ end
108
+
109
+ def after_perform_method
110
+ arguments.first << 'after_perform_method'
111
+ end
112
+
113
+ end
114
+
115
+ describe RocketJob::Plugins::Job::Callbacks do
116
+ after do
117
+ @job.destroy if @job && !@job.new_record?
118
+ end
119
+
120
+ describe '#before_perform' do
121
+ it 'runs blocks and functions' do
122
+ @job = BeforePerformJob.new(arguments: [[]])
123
+ @job.perform_now
124
+ assert @job.completed?, @job.attributes.ai
125
+ expected = %w(before_perform_block before_perform_method perform)
126
+ assert_equal expected, @job.arguments.first, 'Sequence of before_perform callbacks is incorrect'
127
+ end
128
+ end
129
+
130
+ describe '#after_perform' do
131
+ it 'runs blocks and functions' do
132
+ @job = AfterPerformJob.new(arguments: [[]])
133
+ @job.perform_now
134
+ assert @job.completed?, @job.attributes.ai
135
+ expected = %w(perform after_perform_method after_perform_block)
136
+ assert_equal expected, @job.arguments.first, 'Sequence of after_perform callbacks is incorrect'
137
+ end
138
+ end
139
+
140
+ describe '#around_perform' do
141
+ it 'runs blocks and functions' do
142
+ @job = AroundPerformJob.new(arguments: [[]])
143
+ @job.perform_now
144
+ assert @job.completed?, @job.attributes.ai
145
+ expected = %w(around_perform_block_before around_perform_method_before perform around_perform_method_after around_perform_block_after)
146
+ assert_equal expected, @job.arguments.first, 'Sequence of around_perform callbacks is incorrect'
147
+ end
148
+ end
149
+
150
+ describe 'all callbacks' do
151
+ it 'runs them in the right order' do
152
+ @job = CombinedPerformJob.new(arguments: [[]])
153
+ @job.perform_now
154
+ assert @job.completed?, @job.attributes.ai
155
+ expected = %w(before_perform_block around_perform_block_before before_perform_method around_perform_method_before perform after_perform_method around_perform_method_after around_perform_block_after after_perform_block)
156
+ assert_equal expected, @job.arguments.first, 'Sequence of around_perform callbacks is incorrect'
157
+ end
158
+ end
159
+
160
+ end
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,52 @@
1
+ require_relative '../../test_helper'
2
+
3
+ module Plugins
4
+ module Job
5
+ # Unit Test for RocketJob::Job
6
+ class DefaultsTest < Minitest::Test
7
+
8
+ class ParentJob < RocketJob::Job
9
+ rocket_job do |job|
10
+ job.priority = 53
11
+ job.description = 'Hello'
12
+ end
13
+
14
+ def perform
15
+ end
16
+ end
17
+
18
+ class ChildJob < ParentJob
19
+ rocket_job do |job|
20
+ job.priority = 72
21
+ end
22
+
23
+ def perform
24
+ end
25
+ end
26
+
27
+ describe RocketJob::Plugins::Job::Defaults do
28
+ after do
29
+ @job.destroy if @job && !@job.new_record?
30
+ end
31
+
32
+ describe '.rocket_job' do
33
+ it 'sets defaults after initialize' do
34
+ @job = ParentJob.new
35
+ assert_equal 53, @job.priority
36
+ assert_equal 'Hello', @job.description
37
+ end
38
+
39
+ it 'allows a child to override parent defaults' do
40
+ @job = ChildJob.new
41
+ assert_equal 72, @job.priority
42
+ end
43
+
44
+ it 'passes down parent defaults' do
45
+ @job = ChildJob.new
46
+ assert_equal 'Hello', @job.description
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,58 @@
1
+ require_relative '../../test_helper'
2
+
3
+ # Unit Test for RocketJob::Job
4
+ module Plugins
5
+ module Job
6
+ class LoggerTest < Minitest::Test
7
+
8
+ class LoggerJob < RocketJob::Job
9
+ def perform
10
+ logger.debug('DONE', value: 123, other_value: 'HI')
11
+ end
12
+ end
13
+
14
+ describe RocketJob::Plugins::Job::Logger do
15
+ before do
16
+ LoggerJob.delete_all
17
+ end
18
+
19
+ after do
20
+ @job.destroy if @job && !@job.new_record?
21
+ SemanticLogger.flush
22
+ end
23
+
24
+ describe '#logger' do
25
+ it 'uses semantic logger' do
26
+ @job = LoggerJob.new
27
+ assert_kind_of SemanticLogger::Logger, @job.logger, @job.logger.ai
28
+ assert_equal @job.class.name, @job.logger.name, @job.logger.ai
29
+ end
30
+
31
+ it 'allows perform to log its own data' do
32
+ @job = LoggerJob.new
33
+ @job.perform_now
34
+ end
35
+
36
+ it 'adds start logging' do
37
+ @job = LoggerJob.new
38
+ info_called = false
39
+ @job.logger.stub(:info, -> description { info_called = true if description == 'Start #perform' }) do
40
+ @job.perform_now
41
+ end
42
+ assert info_called, "In Plugins::Job::Logger.around_perform logger.info('Start #perform') not called"
43
+ end
44
+
45
+ it 'adds completed logging' do
46
+ @job = LoggerJob.new
47
+ benchmark_called = false
48
+ @job.logger.stub(:benchmark_info, -> description, *args { benchmark_called = true if description == 'Completed #perform' }) do
49
+ @job.perform_now
50
+ end
51
+ assert benchmark_called, "In Plugins::Job::Logger.around_perform logger.benchmark_info('Completed #perform') not called"
52
+ end
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,97 @@
1
+ require_relative '../../test_helper'
2
+
3
+ module Plugins
4
+ module Job
5
+ # Unit Test for RocketJob::Job
6
+ class ModelTest < Minitest::Test
7
+ class SimpleJob < RocketJob::Job
8
+ def perform
9
+ 10
10
+ end
11
+ end
12
+
13
+ class TwoArgumentJob < RocketJob::Job
14
+ rocket_job do |job|
15
+ job.priority = 53
16
+ end
17
+
18
+ def perform(a, b)
19
+ a + b
20
+ end
21
+ end
22
+
23
+ describe RocketJob::Plugins::Job::Model do
24
+ after do
25
+ @job.destroy if @job && !@job.new_record?
26
+ @job2.destroy if @job2 && !@job2.new_record?
27
+ @job3.destroy if @job3 && !@job3.new_record?
28
+ end
29
+
30
+ describe '#scheduled?' do
31
+ it 'returns true if job is queued to run in the future' do
32
+ @job = SimpleJob.new(run_at: 1.day.from_now)
33
+ assert_equal true, @job.queued?
34
+ assert_equal true, @job.scheduled?
35
+ @job.start
36
+ assert_equal true, @job.running?
37
+ assert_equal false, @job.scheduled?
38
+ end
39
+
40
+ it 'returns false if job is queued and can be run now' do
41
+ @job = SimpleJob.new
42
+ assert_equal true, @job.queued?
43
+ assert_equal false, @job.scheduled?
44
+ end
45
+
46
+ it 'returns false if job is running' do
47
+ @job = SimpleJob.new
48
+ @job.start
49
+ assert_equal true, @job.running?
50
+ assert_equal false, @job.scheduled?
51
+ end
52
+ end
53
+
54
+ describe 'with queued jobs' do
55
+ before do
56
+ @job = SimpleJob.create!(description: 'first')
57
+ @job2 = SimpleJob.create!(description: 'second', run_at: 1.day.from_now)
58
+ @job3 = SimpleJob.create!(description: 'third', run_at: 2.days.from_now)
59
+ end
60
+
61
+ describe '#scheduled' do
62
+ it 'returns only scheduled jobs' do
63
+ count = 0
64
+ RocketJob::Job.scheduled.each do |job|
65
+ count += 1
66
+ assert job.scheduled?
67
+ end
68
+ assert 2, count
69
+ end
70
+ end
71
+
72
+ describe '#queued_now' do
73
+ it 'returns only queued jobs, not scheduled ones' do
74
+ count = 0
75
+ RocketJob::Job.queued_now.each do |job|
76
+ count += 1
77
+ refute job.scheduled?
78
+ end
79
+ assert 1, count
80
+ end
81
+ end
82
+
83
+ describe '#queued' do
84
+ it 'returns all queued jobs' do
85
+ count = 0
86
+ RocketJob::Job.queued.each do |job|
87
+ count += 1
88
+ end
89
+ assert 3, count
90
+ end
91
+ end
92
+ end
93
+
94
+ end
95
+ end
96
+ end
97
+ end