639dab59dc
This is an internal fix, not user facing. I noticed it while working on https://github.com/rails/rails/pull/48585. The `async` adapter has an `immediate` option, which should only be used in tests. This option should tell the adapter to run jobs inline. This works correctly with `perform_later`, but it does not work with `enqueue_at`, which is what other internal mechanisms such as `retry_job` use. This PR fixes this bug.
23 lines
604 B
Ruby
23 lines
604 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "helper"
|
|
require "active_job/queue_adapters/async_adapter"
|
|
require "jobs/hello_job"
|
|
|
|
class AsyncAdapterTest < ActiveSupport::TestCase
|
|
setup do
|
|
JobBuffer.clear
|
|
ActiveJob::Base.queue_adapter.immediate = true
|
|
end
|
|
|
|
test "in immediate run, perform_later runs immediately" do
|
|
HelloJob.perform_later "Alex"
|
|
assert_match(/Alex/, JobBuffer.last_value)
|
|
end
|
|
|
|
test "in immediate run, enqueue with wait: runs immediately" do
|
|
HelloJob.set(wait_until: Date.tomorrow.noon).perform_later "Alex"
|
|
assert_match(/Alex/, JobBuffer.last_value)
|
|
end
|
|
end
|