Fix ActionMailer plugin to add rescue_from
to the correct class
#1143
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
This PR has two fixes.
ActiveJob
plugin is now a true plugin, with all of the methods and capabilities that should be present. It now loads at the correct load time, and can be disabled from the Rollbar config. d3e0029rescue_from
handler is added to the correct base class. 4d4f391This PR also refactors the tests to test Rails 6+, which previously didn't get coverage that included the mailer class. Where possible, the tests are now in shared examples called by both the old and new contexts.
Background facts about
rescue_from
handlers.When
MailDeliveryJob
was added in Rails 6.x, it included arescue_from
handler that calls therescue_from
of the Mailer class.When the Rollbar
ActiveJob
plugin installs its handler onMailDeliveryJob
, it is added after the one in theMailDeliveryJob
class, and has precedence. This causes the intended handler to never get called, and therefore never pass the error to the Mailer class.ActionMailer::Base
is the base class for all Mailers, and this is the correct place to add the Rollbar handler. With this fix, the application's handler will be used if it matches the exception class, and if not, the Rollbar handler is called.Type of change
Related issues
Fixes #1126