Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ActiveJob tests for Rails 7.2 and 8.0 #2487

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

olivier-thatch
Copy link

@olivier-thatch olivier-thatch commented Dec 7, 2024

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:

context "when we are using an adapter which has a specific integration" do
before do
Sentry.configuration.rails.skippable_job_adapters = ["ActiveJob::QueueAdapters::TestAdapter"]
end
after do
Sentry.configuration.rails.skippable_job_adapters = []
end
it "does not trigger sentry and re-raises" do
expect { FailedJob.perform_now }.to raise_error(FailedJob::TestError)
expect(transport.events.size).to eq(0)
end
end

After investigating, I realized that with Rails >= 7.2, all the test jobs were using ActiveJob::QueueAdapters::AsyncAdapter as their queue adapter instead of ActiveJob::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 use ActiveJob::QueueAdapters::TestAdapter as their queue adapter.

What I don't understand is why this happens locally but not in CI 🤔

#skip-changelog

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.19%. Comparing base (48f45e8) to head (325b3c1).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2487      +/-   ##
==========================================
+ Coverage   98.15%   98.19%   +0.04%     
==========================================
  Files         128      128              
  Lines        4827     4885      +58     
==========================================
+ Hits         4738     4797      +59     
+ Misses         89       88       -1     
Components Coverage Δ
sentry-ruby 98.59% <ø> (+0.04%) ⬆️
sentry-rails 97.07% <ø> (ø)
sentry-sidekiq 96.96% <ø> (ø)
sentry-resque 92.85% <ø> (ø)
sentry-delayed_job 95.65% <ø> (ø)
sentry-opentelemetry 99.31% <ø> (ø)

see 3 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant