-
-
Notifications
You must be signed in to change notification settings - Fork 513
TypeError when payload class is already a constant #2564
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
TypeError when payload class is already a constant #2564
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I've left a couple of comments 🙂
`constantize` is basically an alias for `Object.const_get`, so why are we doing gymnastics to avail ourselves of it? https://github.com/rails/rails/blob/cf6ff17e9a3c6c1139040b519a341f55f0be16cf/activesupport/lib/active_support/inflector/methods.rb#L289
The `constantize` logic needs to remain so long as this gem supports Ruby < 2.7. rails/rails@7057ccf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TY :)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2564 +/- ##
==========================================
+ Coverage 64.11% 64.46% +0.34%
==========================================
Files 123 123
Lines 4724 4672 -52
==========================================
- Hits 3029 3012 -17
+ Misses 1695 1660 -35
|
Description
When
Resque.inline = true
, which is often used in an application's specs when testing a Resque job's business logic, thepayload["class"]
that the Sentry hook gets is an actual class, not a string! I've added a spec for this case and fixed it by avoiding constantization if it's already a class.Note: Reliance on ActiveSupport::Inflector#constantize can be removed if/when
sentry-ruby
no longer supports Ruby 2.4-2.6. According to this Rails commit,Object.const_get
works properly from Rails 2.7 on.