Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Active Job:
async
adapter should always run jobs immediately if `im…
…mediate` set This is an internal fix, not user facing. I noticed it while working on #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.
- Loading branch information
1 parent
f46d345
commit 639dab5
Showing
6 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters