Skip to content

Commit 3b4fd0b

Browse files
Fix handling of scheduled jobs.
1 parent 71e5b2f commit 3b4fd0b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/active_job/queue_adapters/async_job_adapter.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ def initialize(dispatcher = ::Async::Job::Adapter::ActiveJob::Railtie.dispatcher
2020
end
2121

2222
# Enqueue a job for processing.
23+
# @parameter job [ActiveJob::Base] The job to enqueue.
2324
def enqueue(job)
2425
Sync do
2526
@dispatcher.call(job)
2627
end
2728
end
2829

2930
# Enqueue a job for processing at a specific time.
31+
# @parameter job [ActiveJob::Base] The job to enqueue.
32+
# @parameter timestamp [Time] The time at which to enqueue the job.
3033
def enqueue_at(job, timestamp)
34+
job.scheduled_at = timestamp
35+
3136
Sync do
3237
@dispatcher.call(job)
3338
end

test/active_job/queue_adapters/async_job_adapter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
with "#enqueue_at" do
7070
let(:adapter) {subject.new(dispatcher)}
7171
let(:job) {TestJob.new}
72-
let(:timestamp) {Time.now + 60}
72+
let(:timestamp) {Time.now}
7373

7474
before do
7575
dispatcher.queues["default"] = queue
@@ -84,6 +84,7 @@
8484
"job_class" => be == "TestJob",
8585
"queue_name" => be == "default",
8686
"arguments" => be == [],
87+
"scheduled_at" => be == timestamp.iso8601(9),
8788
)
8889
end
8990
end

0 commit comments

Comments
 (0)