I have this code in my test.rb :
config.active_job.queue_adapter = :inline
In the test I have:
scenario '15 minutes after last call a recall should happen' do
p ActiveJob::Base.queue_adapter
end
This returns: ActiveJob::QueueAdapters::InlineAdapter
which is good because the perform_later are executed immediately.
However when I add type: :request to the test like this:
scenario '15 minutes after last call a recall should happen', type: :request do
p ActiveJob::Base.queue_adapter
end
i'm getting: requestActiveJob::QueueAdapters::TestAdapter and the perform_later isn't executed anymore. Is this intended behaviour? How can I make sure the perform_later blocks are always executed in tests?
This is related to this issue: https://github.com/rails/rails/issues/37270
Putting
(ActiveJob::Base.descendants << ActiveJob::Base).each(&:disable_test_adapter)
IN the actual test fixes it.
Another more cleaner option is to (if possible) change the test type into: type: :system and making sure your rspec-rails version is >= 4.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With