2016-08-06 13:03:39 -04:00
|
|
|
require "active_job/arguments"
|
2016-05-13 20:43:48 -04:00
|
|
|
|
|
|
|
class DelayedMailerError < StandardError; end
|
|
|
|
|
2014-08-12 14:24:19 -04:00
|
|
|
class DelayedMailer < ActionMailer::Base
|
2016-05-13 20:43:48 -04:00
|
|
|
cattr_accessor :last_error
|
|
|
|
cattr_accessor :last_rescue_from_instance
|
|
|
|
|
|
|
|
rescue_from DelayedMailerError do |error|
|
|
|
|
@@last_error = error
|
|
|
|
@@last_rescue_from_instance = self
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue_from ActiveJob::DeserializationError do |error|
|
|
|
|
@@last_error = error
|
|
|
|
@@last_rescue_from_instance = self
|
|
|
|
end
|
2014-08-12 14:24:19 -04:00
|
|
|
|
|
|
|
def test_message(*)
|
2016-08-06 13:03:39 -04:00
|
|
|
mail(from: "test-sender@test.com", to: "test-receiver@test.com", subject: "Test Subject", body: "Test Body")
|
2014-08-12 14:24:19 -04:00
|
|
|
end
|
2016-05-13 20:43:48 -04:00
|
|
|
|
|
|
|
def test_raise(klass_name)
|
2016-08-06 13:03:39 -04:00
|
|
|
raise klass_name.constantize, "boom"
|
2016-05-13 20:43:48 -04:00
|
|
|
end
|
2014-08-12 14:24:19 -04:00
|
|
|
end
|