resque-approve 0.0.4 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,9 @@
28
28
  order_param("num_jobs", @sort_by, @sort_order) }.to_param %>">
29
29
  Pending Jobs
30
30
  </a></th>
31
+ <th>
32
+ Num Running
33
+ </th>
31
34
  <th><a href="<%= u("approve") %>?<%=
32
35
  { sort: "first_enqueued",
33
36
  page_size: @page_size,
@@ -64,3 +67,6 @@
64
67
  </div>
65
68
  <div class="approve_reset"/>
66
69
  <br/>
70
+ <div>
71
+ Approval v<%= VERSION %>
72
+ </div>
@@ -80,3 +80,6 @@
80
80
  <div class="approve_reset"/>
81
81
 
82
82
  <br/>
83
+ <div>
84
+ Approval v<%= VERSION %>
85
+ </div>
@@ -12,6 +12,10 @@
12
12
  </a>
13
13
  </p>
14
14
 
15
+ <p>
16
+ Num active jobs in this queue = <%= pending_queue.num_running %>
17
+ </p>
18
+
15
19
  <% if pending_queue.paused? %>
16
20
  <p>
17
21
  Paused. Skipped <%= pending_queue.num_ignored %> resume actions.
@@ -39,23 +43,16 @@
39
43
 
40
44
  <br/>
41
45
 
46
+ <form method="POST" action="<%= u("approve/reset_running") %>?<%=
47
+ { approval_key: pending_queue.approval_key }.to_param %>">
48
+ <input type="submit" name="" value="Reset Running"/>
49
+ </form>
50
+
42
51
  <form method="POST" action="<%= u("approve/delete_queue") %>?<%=
43
52
  { approval_key: pending_queue.approval_key }.to_param %>">
44
53
  <input type="submit" name="" value="Delete All"/>
45
54
  </form>
46
55
 
47
- <% if pending_queue.paused? %>
48
- <form method="POST" action="<%= u("approve/resume") %>?<%=
49
- { approval_key: pending_queue.approval_key }.to_param %>">
50
- <input type="submit" name="" value="Resume"/>
51
- </form>
52
- <% else %>
53
- <form method="POST" action="<%= u("approve/pause") %>?<%=
54
- { approval_key: pending_queue.approval_key }.to_param %>">
55
- <input type="submit" name="" value="Pause"/>
56
- </form>
57
- <% end %>
58
-
59
56
  <form method="POST" action="<%= u("approve/delete_one_queue") %>?<%=
60
57
  { approval_key: pending_queue.approval_key }.to_param %>">
61
58
  <input type="submit" name="" value="Delete One"/>
@@ -72,5 +69,22 @@
72
69
  </form>
73
70
  <% end %>
74
71
 
72
+ <% if pending_queue.paused? %>
73
+ <form method="POST" action="<%= u("approve/resume") %>?<%=
74
+ { approval_key: pending_queue.approval_key }.to_param %>">
75
+ <input type="submit" name="" value="Resume"/>
76
+ </form>
77
+ <% else %>
78
+ <form method="POST" action="<%= u("approve/pause") %>?<%=
79
+ { approval_key: pending_queue.approval_key }.to_param %>">
80
+ <input type="submit" name="" value="Pause"/>
81
+ </form>
82
+ <% end %>
83
+
75
84
  <div class="approve_reset"/>
76
- <br/>
85
+ <br/>
86
+ <div>
87
+ <p>
88
+ Approval v<%= VERSION %>
89
+ </p>
90
+ </div>
@@ -123,6 +123,33 @@ RSpec.describe Resque::Plugins::Approve::PendingJobQueue do
123
123
  end
124
124
  end
125
125
 
126
+ describe "approve_num" do
127
+ it "enqueues the first x jobs" do
128
+ job_queue.approve_num 3
129
+
130
+ expect(Resque).to have_received(:enqueue_to).with "Some_Queue", BasicJob, 0
131
+ expect(Resque).to have_received(:enqueue_to).with "Some_Queue", BasicJob, 1
132
+ expect(Resque).to have_received(:enqueue_to).with "Some_Queue", BasicJob, 2
133
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 3
134
+
135
+ expect(job_queue.jobs).not_to be_include jobs[0]
136
+ expect(job_queue.num_jobs).to eq 1
137
+ end
138
+
139
+ it "does not enqueues the first x jobs if paused" do
140
+ job_queue.pause
141
+ job_queue.approve_num 3
142
+
143
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 0
144
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 1
145
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 2
146
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 3
147
+
148
+ expect(job_queue.jobs).to be_include jobs[0]
149
+ expect(job_queue.num_jobs).to eq 4
150
+ end
151
+ end
152
+
126
153
  describe "pop_job" do
127
154
  it "enqueues the last job" do
128
155
  job_queue.pop_job
@@ -190,7 +217,7 @@ RSpec.describe Resque::Plugins::Approve::PendingJobQueue do
190
217
  expect(job_queue.num_jobs).to eq 3
191
218
  end
192
219
 
193
- it "removes the first job" do
220
+ it "removes the first job if paused" do
194
221
  job_queue.pause
195
222
  job_queue.remove_one
196
223
 
@@ -204,6 +231,37 @@ RSpec.describe Resque::Plugins::Approve::PendingJobQueue do
204
231
  end
205
232
  end
206
233
 
234
+ describe "remove_num" do
235
+ it "removes the first x jobs" do
236
+ job_queue.remove_num 3
237
+
238
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 0
239
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 1
240
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 2
241
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 3
242
+
243
+ expect(job_queue.jobs).not_to be_include jobs[0]
244
+ expect(job_queue.jobs).not_to be_include jobs[1]
245
+ expect(job_queue.jobs).not_to be_include jobs[2]
246
+ expect(job_queue.num_jobs).to eq 1
247
+ end
248
+
249
+ it "removes the first x jobs if paused" do
250
+ job_queue.pause
251
+ job_queue.remove_num 3
252
+
253
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 0
254
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 1
255
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 2
256
+ expect(Resque).not_to have_received(:enqueue_to).with "Some_Queue", BasicJob, 3
257
+
258
+ expect(job_queue.jobs).not_to be_include jobs[0]
259
+ expect(job_queue.jobs).not_to be_include jobs[1]
260
+ expect(job_queue.jobs).not_to be_include jobs[2]
261
+ expect(job_queue.num_jobs).to eq 1
262
+ end
263
+ end
264
+
207
265
  describe "remove_job_pop" do
208
266
  it "removes the last job" do
209
267
  job_queue.remove_job_pop
@@ -297,7 +355,7 @@ RSpec.describe Resque::Plugins::Approve::PendingJobQueue do
297
355
  describe "first_enqueued" do
298
356
  it "returns the time of the first enqueued item" do
299
357
  4.times do |index|
300
- expect(job_queue.first_enqueued).to be_within(1.second).of((5 - index).hours.ago)
358
+ expect(job_queue.first_enqueued).to be_within(2.seconds).of((5 - index).hours.ago)
301
359
 
302
360
  job_queue.remove_one
303
361
  end
@@ -319,14 +377,34 @@ RSpec.describe Resque::Plugins::Approve::PendingJobQueue do
319
377
  expect(job_queue).to be_paused
320
378
  end
321
379
 
380
+ it "counts approvals while paused" do
381
+ expect(job_queue).not_to be_paused
382
+ job_queue.pause
383
+ expect(job_queue).to be_paused
384
+ job_queue.pause
385
+ expect(job_queue).to be_paused
386
+
387
+ job_queue.approve_num 8
388
+ job_queue.approve_one
389
+ expect(job_queue).to be_paused
390
+ expect(job_queue.num_ignored).to eq 9
391
+ end
392
+
322
393
  it "can be resumed" do
323
394
  expect(job_queue).not_to be_paused
324
395
  job_queue.resume
325
396
  expect(job_queue).not_to be_paused
326
397
  job_queue.pause
327
398
  expect(job_queue).to be_paused
399
+
400
+ job_queue.approve_num 8
401
+ job_queue.approve_one
402
+ expect(job_queue).to be_paused
403
+ expect(job_queue.num_ignored).to eq 9
404
+
328
405
  job_queue.resume
329
406
  expect(job_queue).not_to be_paused
407
+ expect(job_queue.num_ignored).to be_zero
330
408
  end
331
409
  end
332
410
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "rails_helper"
4
4
 
5
- # rubocop:disable Layout/AlignHash
6
5
  RSpec.describe Resque::Plugins::Approve::PendingJob do
7
6
  let(:key_list) { Resque::Plugins::Approve::ApprovalKeyList.new }
8
7
  let!(:key) { Faker::Lorem.sentence }
@@ -38,6 +37,20 @@ RSpec.describe Resque::Plugins::Approve::PendingJob do
38
37
 
39
38
  job
40
39
  end
40
+ let(:approval_require_approval_job) do
41
+ job = Resque::Plugins::Approve::PendingJob.new(SecureRandom.uuid, class_name: job_class, args: [requires_approval: true])
42
+
43
+ key_list.add_job(job)
44
+
45
+ job
46
+ end
47
+ let(:approval_hash_only_args_job) do
48
+ job = Resque::Plugins::Approve::PendingJob.new(SecureRandom.uuid, class_name: job_class, args: [some_hash: "hash", approval_key: key])
49
+
50
+ key_list.add_job(job)
51
+
52
+ job
53
+ end
41
54
  let(:approval_no_hash_args_job) do
42
55
  job = Resque::Plugins::Approve::PendingJob.new(SecureRandom.uuid,
43
56
  class_name: job_class,
@@ -87,36 +100,58 @@ RSpec.describe Resque::Plugins::Approve::PendingJob do
87
100
  describe "initialize" do
88
101
  it "extracts delay arguments from job with no argument" do
89
102
  expect(no_args_job.args).to eq []
103
+ expect(Resque::Plugins::Approve::PendingJob.new(no_args_job.id).args).to eq []
90
104
  expect(no_args_job.approve_options).to eq({}.with_indifferent_access)
91
105
  end
92
106
 
93
107
  it "extracts delay arguments from job with no hash arguments" do
94
108
  expect(no_hash_args_job.args).to eq [1, "fred", "something else", 888]
109
+ expect(Resque::Plugins::Approve::PendingJob.new(no_hash_args_job.id).args).to eq [1, "fred", "something else", 888]
95
110
  expect(no_hash_args_job.approve_options).to eq({}.with_indifferent_access)
96
111
  end
97
112
 
98
113
  it "extracts delay arguments from job with no approval arguments" do
99
114
  expect(hash_args_job.args).to eq [1, "fred", "something else", 888, "other_arg" => 1, "something else" => "something"]
115
+ expect(Resque::Plugins::Approve::PendingJob.new(hash_args_job.id).args).
116
+ to eq [1, "fred", "something else", 888, "other_arg" => 1, "something else" => "something"]
100
117
  expect(hash_args_job.approve_options).to eq({}.with_indifferent_access)
101
118
  end
102
119
 
103
120
  it "extracts delay arguments from job with no argument and approval_args" do
104
121
  expect(approval_only_args_job.args).to eq []
122
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_only_args_job.id).args).to eq []
105
123
  expect(approval_only_args_job.approve_options).to eq("approval_key" => key)
106
124
  end
107
125
 
126
+ it "extracts delay arguments from job with no argument and require_approval" do
127
+ expect(approval_require_approval_job.args).to eq []
128
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_require_approval_job.id).args).to eq []
129
+ expect(approval_require_approval_job.approve_options).to eq("approval_key" => "Some_Queue", "requires_approval" => true)
130
+ end
131
+
132
+ it "extracts delay arguments from job with only hash arguments and approval_args" do
133
+ expect(approval_hash_only_args_job.args).to eq [{ "some_hash" => "hash" }]
134
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_hash_only_args_job.id).args).to eq [{ "some_hash" => "hash" }]
135
+ expect(approval_hash_only_args_job.approve_options).to eq("approval_key" => key)
136
+ end
137
+
108
138
  it "extracts delay arguments from job with no hash arguments and approval args" do
109
139
  expect(approval_no_hash_args_job.args).to eq [1, "fred", "something else", 888]
140
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_no_hash_args_job.id).args).to eq [1, "fred", "something else", 888]
110
141
  expect(approval_no_hash_args_job.approve_options).to eq("approval_key" => key)
111
142
  end
112
143
 
113
144
  it "extracts delay arguments from job with no approval arguments and approval args" do
114
145
  expect(approval_hash_args_job.args).to eq [1, "fred", "something else", 888, "other_arg" => 1, "something else" => "something"]
146
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_hash_args_job.id).args).
147
+ to eq [1, "fred", "something else", 888, "other_arg" => 1, "something else" => "something"]
115
148
  expect(approval_hash_args_job.approve_options).to eq("approval_key" => key)
116
149
  end
117
150
 
118
151
  it "extracts all delay arguments from job with no approval arguments and approval args" do
119
152
  expect(approval_all_args_job.args).to eq [1, "fred", "something else", 888, "other_arg" => 1, "something else" => "something"]
153
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_all_args_job.id).args).
154
+ to eq [1, "fred", "something else", 888, "other_arg" => 1, "something else" => "something"]
120
155
 
121
156
  expect(approval_all_args_job.approve_options[:approval_key]).to eq key
122
157
  expect(approval_all_args_job.approve_options["approval_key"]).to eq key
@@ -124,8 +159,8 @@ RSpec.describe Resque::Plugins::Approve::PendingJob do
124
159
  expect(approval_all_args_job.approve_options[:approval_queue]).to eq "Another Queue"
125
160
  expect(approval_all_args_job.approve_options["approval_queue"]).to eq "Another Queue"
126
161
 
127
- expect(approval_all_args_job.approve_options[:approval_at]).to be_within(2.seconds).of(2.hours.from_now)
128
- expect(approval_all_args_job.approve_options["approval_at"]).to be_within(2.seconds).of(2.hours.from_now)
162
+ expect(approval_all_args_job.approve_options[:approval_at].to_time).to be_within(2.seconds).of(2.hours.from_now)
163
+ expect(approval_all_args_job.approve_options["approval_at"].to_time).to be_within(2.seconds).of(2.hours.from_now)
129
164
  end
130
165
  end
131
166
 
@@ -165,6 +200,8 @@ RSpec.describe Resque::Plugins::Approve::PendingJob do
165
200
 
166
201
  it "has args" do
167
202
  expect(job.args).to eq [1, "fred", "something else", 888, "other_arg" => 1, "something else" => "something"]
203
+ expect(Resque::Plugins::Approve::PendingJob.new(job.id).args).
204
+ to eq [1, "fred", "something else", 888, "other_arg" => 1, "something else" => "something"]
168
205
  end
169
206
 
170
207
  it "has the approval_key" do
@@ -176,11 +213,11 @@ RSpec.describe Resque::Plugins::Approve::PendingJob do
176
213
  end
177
214
 
178
215
  it "has the approval_at" do
179
- expect(job.approval_at).to be_within(1.second).of(2.hours.from_now)
216
+ expect(job.approval_at).to be_within(2.seconds).of(2.hours.from_now)
180
217
  end
181
218
 
182
219
  it "has the queue_time" do
183
- expect(job.queue_time).to be_within(1.second).of(2.hours.ago)
220
+ expect(job.queue_time).to be_within(2.seconds).of(2.hours.ago)
184
221
  end
185
222
 
186
223
  it "has the queue" do
@@ -245,6 +282,146 @@ RSpec.describe Resque::Plugins::Approve::PendingJob do
245
282
 
246
283
  expect(job).not_to be_requires_approval
247
284
  end
285
+
286
+ it "requires approval if requires_approval is passed" do
287
+ expect(approval_require_approval_job).to be_requires_approval
288
+ end
289
+
290
+ context "MaxActiveJob" do
291
+ let(:job_class) { MaxActiveJob }
292
+ let(:num_queue) { Resque::Plugins::Approve::PendingJobQueue.new("Some_Queue") }
293
+
294
+ before(:each) do
295
+ num_queue.reset_running
296
+ end
297
+
298
+ it "does not require approval if num jobs below max" do
299
+ expect(approval_require_approval_job).not_to be_requires_approval
300
+
301
+ expect(approval_require_approval_job.args).to eq ["approval_key" => "Some_Queue"]
302
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_require_approval_job.id).args).to eq ["approval_key" => "Some_Queue"]
303
+ expect(approval_require_approval_job.approve_options).to eq("approval_key" => "Some_Queue", "requires_approval" => true)
304
+ end
305
+
306
+ it "does require approval if num jobs above max" do
307
+ 10.times { num_queue.increment_running }
308
+
309
+ expect(approval_require_approval_job).to be_requires_approval
310
+
311
+ expect(approval_require_approval_job.args).to eq ["approval_key" => "Some_Queue"]
312
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_require_approval_job.id).args).to eq ["approval_key" => "Some_Queue"]
313
+ expect(approval_require_approval_job.approve_options).to eq("approval_key" => "Some_Queue", "requires_approval" => true)
314
+ end
315
+
316
+ it "calls the perform function" do
317
+ allow(Resque.logger).to receive(:warn).and_call_original
318
+
319
+ MaxActiveJob.perform(*approval_require_approval_job.args)
320
+
321
+ expect(Resque.logger).to have_received(:warn).with("Args:\n[]").exactly(2).times
322
+ end
323
+
324
+ it "does not approve if number of running jobs too high" do
325
+ approval_require_approval_job
326
+
327
+ expect(Resque::Plugins::Approve::PendingJobQueue.new("Some_Queue").num_jobs).to eq 1
328
+
329
+ 10.times { num_queue.increment_running }
330
+
331
+ allow(Resque.logger).to receive(:warn).and_call_original
332
+
333
+ job_class.approve_one
334
+
335
+ expect(Resque.logger).not_to have_received(:warn)
336
+ expect(Resque::Plugins::Approve::PendingJobQueue.new("Some_Queue").num_jobs).to eq 1
337
+
338
+ expect(num_queue.num_running.to_i).to eq 10
339
+ end
340
+
341
+ it "approves the next item in the queue" do
342
+ allow(Resque::Plugins::Approve).to receive(:approve_one).and_call_original
343
+
344
+ MaxActiveJob.perform(*approval_require_approval_job.args)
345
+
346
+ expect(Resque::Plugins::Approve).to have_received(:approve_one).with("Some_Queue").exactly(2).times
347
+ end
348
+
349
+ it "approves the next item in the queue even if there is an exception" do
350
+ allow(Resque.logger).to receive(:warn).with("Args:\n[]").and_raise "Error"
351
+ allow(Resque::Plugins::Approve).to receive(:approve_one).and_call_original
352
+
353
+ expect { MaxActiveJob.perform(*approval_require_approval_job.args) }.to raise_error
354
+
355
+ expect(Resque.logger).to have_received(:warn).with("Args:\n[]").exactly(2).times
356
+ expect(Resque::Plugins::Approve).to have_received(:approve_one).with("Some_Queue").exactly(2).times
357
+ end
358
+
359
+ it "approves the next item in the queue if non-default queue used" do
360
+ job = Resque::Plugins::Approve::PendingJob.new(SecureRandom.uuid, class_name: job_class, args: [approval_key: "New Key"])
361
+
362
+ key_list.add_job(job)
363
+
364
+ allow(Resque.logger).to receive(:warn).and_call_original
365
+ allow(Resque::Plugins::Approve).to receive(:approve_one).and_call_original
366
+
367
+ MaxActiveJob.perform(*job.args)
368
+
369
+ expect(Resque.logger).to have_received(:warn).with("Args:\n[]").exactly(2).times
370
+ expect(Resque::Plugins::Approve).to have_received(:approve_one).with("New Key").exactly(2).times
371
+ end
372
+
373
+ it "approves the next item in the queue if non-default queue used and queue full" do
374
+ job = Resque::Plugins::Approve::PendingJob.new(SecureRandom.uuid, class_name: job_class, args: [requires_approval: true])
375
+
376
+ 10.times { num_queue.increment_running }
377
+ key_list.add_job(job)
378
+
379
+ allow(Resque.logger).to receive(:warn).and_call_original
380
+ allow(Resque::Plugins::Approve).to receive(:approve_one).and_call_original
381
+
382
+ MaxActiveJob.perform(*job.args)
383
+
384
+ expect(Resque::Plugins::Approve).to have_received(:approve_one).with("Some_Queue").exactly(2).times
385
+ expect(Resque.logger).to have_received(:warn).with("Args:\n[]").exactly(2).times
386
+ expect(num_queue.num_running.to_i).to eq 9
387
+ end
388
+
389
+ it "enqueues a job" do
390
+ allow(Resque.logger).to receive(:warn).and_call_original
391
+ allow(Resque::Plugins::Approve).to receive(:approve_one).and_call_original
392
+
393
+ Resque.enqueue MaxActiveJob, requires_approval: true
394
+
395
+ expect(Resque.logger).to have_received(:warn).with("Args:\n[]")
396
+ expect(Resque::Plugins::Approve).to have_received(:approve_one).with("Some_Queue")
397
+ end
398
+
399
+ it "enqueues a job with arguments" do
400
+ allow(Resque.logger).to receive(:warn).and_call_original
401
+ allow(Resque::Plugins::Approve).to receive(:approve_one).and_call_original
402
+
403
+ Resque.enqueue MaxActiveJob, param: "value", requires_approval: true
404
+
405
+ expect(Resque.logger).to have_received(:warn).with("Args:\n[{\"param\":\"value\"}]")
406
+ expect(Resque::Plugins::Approve).to have_received(:approve_one).with("Some_Queue")
407
+ end
408
+
409
+ it "does not enqueue a job if paused" do
410
+ num_queue.pause
411
+
412
+ expect(num_queue.num_jobs).to be_zero
413
+
414
+ allow(Resque.logger).to receive(:warn).and_call_original
415
+ allow(Resque::Plugins::Approve).to receive(:approve_one).and_call_original
416
+
417
+ Resque.enqueue MaxActiveJob, requires_approval: true
418
+
419
+ expect(Resque.logger).not_to have_received(:warn).with("Args:\n[]")
420
+ expect(Resque::Plugins::Approve).not_to have_received(:approve_one).with("Some_Queue")
421
+
422
+ expect(num_queue.num_jobs).to eq 1
423
+ end
424
+ end
248
425
  end
249
426
 
250
427
  describe "enqueue_job" do
@@ -322,5 +499,44 @@ RSpec.describe Resque::Plugins::Approve::PendingJob do
322
499
  expect(Resque::Plugins::Approve::ApprovalKeyList.new.num_queues).to eq 0
323
500
  end
324
501
  end
502
+
503
+ describe "max_active_jobs?" do
504
+ it "returns false if not set on class" do
505
+ expect(no_args_job.max_active_jobs?).to be_falsey
506
+ end
507
+
508
+ context "MaxActiveJob" do
509
+ let(:job_class) { MaxActiveJob }
510
+
511
+ it "returns true if a max is set" do
512
+ expect(no_args_job.max_active_jobs?).to be_truthy
513
+ end
514
+ end
515
+ end
516
+
517
+ describe "requires_approval" do
518
+ context "DefaultApprovalQueue" do
519
+ let(:job_class) { DefaultApprovalQueue }
520
+
521
+ it "sets the key to the default queue" do
522
+ expect(approval_require_approval_job.args).to eq []
523
+ expect(Resque::Plugins::Approve::PendingJob.new(approval_require_approval_job.id).args).to eq []
524
+ expect(approval_require_approval_job.approve_options).to eq("approval_key" => "Default Approval Queue", "requires_approval" => true)
525
+ end
526
+ end
527
+ end
528
+
529
+ describe "max_active_jobs" do
530
+ it "returns -1 if not set on class" do
531
+ expect(no_args_job.max_active_jobs).to eq(-1)
532
+ end
533
+
534
+ context "MaxActiveJob" do
535
+ let(:job_class) { MaxActiveJob }
536
+
537
+ it "returns value if max set" do
538
+ expect(no_args_job.max_active_jobs).to eq 10
539
+ end
540
+ end
541
+ end
325
542
  end
326
- # rubocop:enable Layout/AlignHash