Skip to content

Commit 997ef4e

Browse files
authored
chore(rails): 8.1 in test setup (#2764)
* fix(rails): set correct rspec-rails version specs * chore(rails): support 8.1 in the Gemfile * chore(rails): update versions in bin/test * chore(rails): add 8.1.0 to matrix * fix(rails): avoid filter_parameters accumulation between spec runs
1 parent d643fcd commit 997ef4e

File tree

7 files changed

+29
-16
lines changed

7 files changed

+29
-16
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
rails_version: "8.0.0"
5252
- ruby_version: "3.4"
5353
rails_version: "8.0.0"
54+
- ruby_version: "3.4"
55+
rails_version: "8.1.0"
5456
- ruby_version: "3.2"
5557
rails_version: 7.1.0
5658
options:

sentry-rails/Gemfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ rails_version = Gem::Version.new(rails_version)
3030

3131
gem "rails", "~> #{rails_version}"
3232

33-
if rails_version >= Gem::Version.new("8.0.0")
34-
gem "rspec-rails"
33+
if rails_version >= Gem::Version.new("8.1.0")
34+
gem "rspec-rails", "~> 8.0.0"
35+
gem "sqlite3", "~> 2.1.1", platform: :ruby
36+
elsif rails_version >= Gem::Version.new("8.0.0")
37+
gem "rspec-rails", "~> 8.0.0"
3538
gem "sqlite3", "~> 2.1.1", platform: :ruby
3639
elsif rails_version >= Gem::Version.new("7.1.0")
3740
gem "psych", "~> 4.0.0"
38-
gem "rspec-rails"
41+
gem "rspec-rails", "~> 7.0"
3942
gem "sqlite3", "~> 1.7.3", platform: :ruby
4043
elsif rails_version >= Gem::Version.new("6.1.0")
41-
gem "rspec-rails", "~> 4.0"
42-
44+
gem "rspec-rails", "~> 6.0"
4345
gem "sqlite3", "~> 1.7.3", platform: :ruby
4446
else
4547
gem "psych", "~> 3.0.0"

sentry-rails/bin/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require 'optparse'
2424
require 'fileutils'
2525

2626
class RailsVersionTester
27-
SUPPORTED_VERSIONS = %w[5.0 5.1 5.2 6.0 6.1 7.0 7.1 7.2 8.0].freeze
27+
SUPPORTED_VERSIONS = %w[5.2 6.0 6.1 7.0 7.1 7.2 8.0 8.1].freeze
2828

2929
def initialize
3030
@options = {}

sentry-rails/spec/dummy/test_rails_app/app.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def self.name
5858
app.config.active_job.queue_adapter = :test
5959
app.config.cache_store = :memory_store
6060
app.config.action_controller.perform_caching = true
61-
app.config.filter_parameters += [:password, :secret]
6261

6362
# Eager load namespaces can be accumulated after repeated initializations and make initialization
6463
# slower after each run
@@ -70,15 +69,15 @@ def self.name
7069
configure_app(app)
7170

7271
# Configure parameter filtering for consistent test behavior
73-
app.config.filter_parameters.concat(
74-
[:custom_secret,
75-
:api_key,
76-
:credit_card,
77-
:authorization,
78-
:password,
79-
:token]
80-
)
81-
app.config.filter_parameters.uniq!
72+
app.config.filter_parameters = [
73+
:password,
74+
:secret,
75+
:custom_secret,
76+
:api_key,
77+
:credit_card,
78+
:authorization,
79+
:token
80+
]
8281

8382
app.routes.append do
8483
get "/exception", to: "hello#exception"

sentry-rails/spec/dummy/test_rails_app/configs/7-1.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def run_pre_initialize_cleanup
3030
# Rails 7.1 stores the error reporter directly under the ActiveSupport class.
3131
# So we need to make sure the subscriber is not subscribed unexpectedly before any tests
3232
ActiveSupport.error_reporter.unsubscribe(Sentry::Rails::ErrorSubscriber)
33+
34+
if ActiveSupport.respond_to?(:filter_parameters)
35+
ActiveSupport.filter_parameters.clear
36+
end
3337
end
3438

3539
def configure_app(app)

sentry-rails/spec/dummy/test_rails_app/configs/7-2.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def run_pre_initialize_cleanup
3030
# Rails 7.1 stores the error reporter directly under the ActiveSupport class.
3131
# So we need to make sure the subscriber is not subscribed unexpectedly before any tests
3232
ActiveSupport.error_reporter.unsubscribe(Sentry::Rails::ErrorSubscriber)
33+
34+
if ActiveSupport.respond_to?(:filter_parameters)
35+
ActiveSupport.filter_parameters.clear
36+
end
3337
end
3438

3539
def configure_app(app)

sentry-rails/spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
end
6565

6666
reset_sentry_globals!
67+
68+
Rails.application = nil
6769
end
6870

6971
config.before :each do

0 commit comments

Comments
 (0)