File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class EnqueueError < StandardError; end
10
10
11
11
class << self
12
12
def enqueue_all ( active_jobs )
13
+ active_jobs . each { |job | job . scheduled_at ||= Time . current }
13
14
active_jobs_by_job_id = active_jobs . index_by ( &:job_id )
14
15
15
16
transaction do
Original file line number Diff line number Diff line change @@ -356,6 +356,22 @@ class DiscardableNonOverlappingGroupedJob2 < NonOverlappingJob
356
356
assert_equal "enqueued inside a rolled back transaction" , job . arguments . dig ( "arguments" , 0 )
357
357
end
358
358
359
+ test "enqueue_all assigns scheduled_at if missing" do
360
+ freeze_time do
361
+ active_jobs = [
362
+ AddToBufferJob . new ( 1 ) ,
363
+ AddToBufferJob . new ( 2 ) . set ( wait : 5 . minutes )
364
+ ]
365
+
366
+ ActiveJob . perform_all_later ( active_jobs )
367
+
368
+ jobs = SolidQueue ::Job . where ( active_job_id : active_jobs . map ( &:job_id ) ) . order ( :id )
369
+
370
+ assert_equal Time . current , jobs [ 0 ] . scheduled_at
371
+ assert_equal 5 . minutes . from_now , jobs [ 1 ] . scheduled_at
372
+ end
373
+ end
374
+
359
375
private
360
376
def assert_ready ( &block )
361
377
assert_job_counts ( ready : 1 , &block )
You can’t perform that action at this time.
0 commit comments