Skip to content

Commit e384446

Browse files
authored
Test sentry-rails against Rails 8.0.0 (#2444)
* Simplify ActiveJob specs setup We don't need to use Sidekiq for ActiveJob specs, we can use Rails' default adapters instead. * Update sentry-rails' Gemfile conditions to support Rails 7.2 * Test against Rails 8.0 on CI * Update Rails 8 related tests
1 parent 9bba2ef commit e384446

File tree

4 files changed

+39
-40
lines changed

4 files changed

+39
-40
lines changed

.github/workflows/sentry_rails_test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
- { ruby_version: "3.1", rails_version: 7.2.0 }
5252
- { ruby_version: "3.2", rails_version: 7.2.0 }
5353
- { ruby_version: "3.3", rails_version: 7.2.0 }
54+
- { ruby_version: "3.2", rails_version: "8.0.0.rc1" }
55+
- { ruby_version: "3.3", rails_version: "8.0.0.rc1" }
5456
- { ruby_version: "jruby", rails_version: 6.1.0 }
5557
- {
5658
ruby_version: "3.2",

sentry-rails/Gemfile

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,49 @@ platform :jruby do
1212
gem "jdbc-sqlite3"
1313
end
1414

15+
ruby_version = Gem::Version.new(RUBY_VERSION)
16+
1517
rails_version = ENV["RAILS_VERSION"]
16-
rails_version = "7.1.0" if rails_version.nil?
18+
rails_version = "7.2.0" if rails_version.nil?
1719
rails_version = Gem::Version.new(rails_version)
1820

19-
if rails_version < Gem::Version.new("6.0.0")
20-
gem "sqlite3", "~> 1.3.0", platform: :ruby
21-
else
22-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
23-
gem "sqlite3", "~> 1.7.3", platform: :ruby
24-
else
25-
gem "sqlite3", "~> 1.6.9", platform: :ruby
26-
end
27-
end
21+
gem "rails", "~> #{rails_version}"
2822

2923
if rails_version >= Gem::Version.new("8.0.0.alpha")
30-
gem "rails", github: "rails/rails"
3124
gem "rspec-rails"
25+
gem "sqlite3", platform: :ruby
3226
elsif rails_version >= Gem::Version.new("7.1.0")
33-
gem "rails", "~> #{rails_version}"
3427
gem "rspec-rails"
28+
gem "sqlite3", "~> 1.7.3", platform: :ruby
29+
elsif rails_version >= Gem::Version.new("6.1.0")
30+
gem "rspec-rails", "~> 4.0"
31+
32+
if ruby_version >= Gem::Version.new("2.7.0")
33+
gem "sqlite3", "~> 1.7.3", platform: :ruby
34+
else
35+
gem "sqlite3", "~> 1.6.9", platform: :ruby
36+
end
3537
else
3638
gem "rspec-rails", "~> 4.0"
37-
gem "rails", "~> #{rails_version}"
3839
gem "psych", "~> 3.0.0"
39-
end
4040

41-
gem "mini_magick"
42-
43-
gem "sprockets-rails"
44-
45-
gem "sidekiq"
46-
47-
48-
ruby_version = Gem::Version.new(RUBY_VERSION)
41+
if rails_version >= Gem::Version.new("6.0.0")
42+
gem "sqlite3", "~> 1.4.0", platform: :ruby
43+
else
44+
gem "sqlite3", "~> 1.3.0", platform: :ruby
45+
end
46+
end
4947

5048
if ruby_version < Gem::Version.new("2.5.0")
5149
# https://github.com/flavorjones/loofah/pull/267
5250
# loofah changed the required ruby version in a patch so we need to explicitly pin it
5351
gem "loofah", "2.20.0"
5452
end
5553

54+
gem "mini_magick"
55+
56+
gem "sprockets-rails"
57+
5658
gem "benchmark-ips"
5759
gem "benchmark_driver"
5860
gem "benchmark-ipsa"

sentry-rails/spec/sentry/rails/activejob_spec.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,17 @@ def perform(event, hint)
309309

310310
context "when we are using an adapter which has a specific integration" do
311311
before do
312-
Sentry.configuration.rails.skippable_job_adapters = ["ActiveJob::QueueAdapters::SidekiqAdapter"]
312+
Sentry.configuration.rails.skippable_job_adapters = ["ActiveJob::QueueAdapters::TestAdapter"]
313313
end
314314

315-
it "does not trigger sentry and re-raises" do
316-
begin
317-
original_queue_adapter = FailedJob.queue_adapter
318-
FailedJob.queue_adapter = :sidekiq
315+
after do
316+
Sentry.configuration.rails.skippable_job_adapters = []
317+
end
319318

320-
expect { FailedJob.perform_now }.to raise_error(FailedJob::TestError)
319+
it "does not trigger sentry and re-raises" do
320+
expect { FailedJob.perform_now }.to raise_error(FailedJob::TestError)
321321

322-
expect(transport.events.size).to eq(0)
323-
ensure
324-
# this doesn't affect test result, but we shouldn't change it anyway
325-
FailedJob.queue_adapter = original_queue_adapter
326-
end
322+
expect(transport.events.size).to eq(0)
327323
end
328324
end
329325

sentry-rails/spec/sentry/rails/tracing/active_support_subscriber_spec.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@
4747
expect(transport.events.count).to eq(1)
4848
cache_transaction = transport.events.first.to_hash
4949
expect(cache_transaction[:type]).to eq("transaction")
50-
expect(cache_transaction[:spans].count).to eq(2)
51-
expect(cache_transaction[:spans][1][:op]).to eq("cache.put")
52-
expect(cache_transaction[:spans][1][:origin]).to eq("auto.cache.rails")
50+
expect(cache_transaction[:spans].count).to eq(1)
51+
expect(cache_transaction[:spans][0][:op]).to eq("cache.put")
52+
expect(cache_transaction[:spans][0][:origin]).to eq("auto.cache.rails")
5353
end
5454

55-
#
5655
it "tracks cache decrement" do
5756
skip("Tracks on Rails 8.0 for all Cache Stores; Until then only MemCached and Redis Stores.") if Rails.version.to_f < 8.0
5857

@@ -67,9 +66,9 @@
6766
expect(transport.events.count).to eq(1)
6867
cache_transaction = transport.events.first.to_hash
6968
expect(cache_transaction[:type]).to eq("transaction")
70-
expect(cache_transaction[:spans].count).to eq(2)
71-
expect(cache_transaction[:spans][1][:op]).to eq("cache.put")
72-
expect(cache_transaction[:spans][1][:origin]).to eq("auto.cache.rails")
69+
expect(cache_transaction[:spans].count).to eq(1)
70+
expect(cache_transaction[:spans][0][:op]).to eq("cache.put")
71+
expect(cache_transaction[:spans][0][:origin]).to eq("auto.cache.rails")
7372
end
7473

7574
it "tracks cache read" do

0 commit comments

Comments
 (0)