rails/activejob/test/helper.rb
Alex Ghiculescu 639dab59dc Active Job: async adapter should always run jobs immediately if immediate set
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.
2023-07-03 09:02:51 +10:00

26 lines
586 B
Ruby

# frozen_string_literal: true
require "active_support/testing/strict_warnings"
require "active_job"
require "support/job_buffer"
GlobalID.app = "aj"
@adapter = ENV["AJ_ADAPTER"] ||= "inline"
puts "Using #{@adapter}"
if ENV["AJ_INTEGRATION_TESTS"]
require "support/integration/helper"
else
ActiveJob::Base.logger = Logger.new(nil)
require "adapters/#{@adapter}"
end
require "active_support/testing/autorun"
require_relative "../../tools/test_common"
def adapter_is?(*adapter_class_symbols)
adapter_class_symbols.map(&:to_s).include? ActiveJob::Base.queue_adapter_name
end