sentry-ruby
sentry-ruby copied to clipboard
fix: Don't mutate original enabled_environments
Ensure enabled_environments contains test environment without mutating original list. Otherwise it can cause unexpected spec failures in case original config has unfrozen Array, or fail in attempt to mutate said array.
Alternative approach would be to override Sentry::Configuration#dup to dup underlying arrays and hashes.
See: https://github.com/getsentry/sentry-ruby/pull/2269#issuecomment-2002637738
Codecov Report
Merging #2275 (ebf04a4) into master (ffffce9) will decrease coverage by
0.05%. The diff coverage is100.00%.
:exclamation: Current head ebf04a4 differs from pull request most recent head a573841. Consider uploading reports for the commit a573841 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #2275 +/- ##
==========================================
- Coverage 97.61% 97.56% -0.05%
==========================================
Files 112 112
Lines 4154 4155 +1
==========================================
- Hits 4055 4054 -1
- Misses 99 101 +2
| Components | Coverage Δ | |
|---|---|---|
| sentry-ruby | 98.27% <100.00%> (-0.04%) |
:arrow_down: |
| sentry-rails | 95.05% <ø> (-0.18%) |
:arrow_down: |
| sentry-sidekiq | 94.70% <ø> (ø) |
|
| sentry-resque | 90.76% <ø> (ø) |
|
| sentry-delayed_job | 95.60% <ø> (ø) |
|
| sentry-opentelemetry | 100.00% <ø> (ø) |
| Files | Coverage Δ | |
|---|---|---|
| sentry-ruby/lib/sentry/test_helper.rb | 100.00% <100.00%> (ø) |
Thanks for the PR, but why did you find it necessary to freeze the enabled_environments array in the first place?
My tests were randomly passing randomly failing. Adding a freeze helped to nail down that Sentry helper was changing configuration inplace - thus specs became order-dependent
superseded by #2317
I still think |= better reflects the desire than += :D
didn’t work for me :(
didn’t work for me :(
Oh. That's weird. Either way, as long as Sentry does not mutate original config - we're good :D
:heart: :heart: :heart: