Fix ActiveJob tests for Rails 7.2 and 8.0 #2487
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the test suite so that the ActiveJob related tests pass with Rails 7.2 and 8.0.
While working on the ActiveJob integration, I noticed that one of the tests was failing with Rails 7.2 and 8.0, specifically this one:
sentry-ruby/sentry-rails/spec/sentry/rails/activejob_spec.rb
Lines 310 to 324 in 1eb011b
After investigating, I realized that with Rails >= 7.2, all the test jobs were using
ActiveJob::QueueAdapters::AsyncAdapter
as their queue adapter instead ofActiveJob::QueueAdapters::TestAdapter
. This is likely because of this change that was introduced in Rails 7.2.The fix is easy enough: we simply need to make sure
ActiveJob::TestHelper
is included before the test suite runs. After including the helper module, all test jobs correctly useActiveJob::QueueAdapters::TestAdapter
as their queue adapter.What I don't understand is why this happens locally but not in CI 🤔
#skip-changelog