2017-07-23 15:17:16 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 17:03:39 +00:00
|
|
|
require "active_job/arguments"
|
2016-05-14 00:43:48 +00:00
|
|
|
|
|
|
|
class DelayedMailerError < StandardError; end
|
|
|
|
|
2014-08-12 18:24:19 +00:00
|
|
|
class DelayedMailer < ActionMailer::Base
|
2016-05-14 00:43:48 +00: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 18:24:19 +00:00
|
|
|
|
|
|
|
def test_message(*)
|
2016-08-06 17:03:39 +00:00
|
|
|
mail(from: "test-sender@test.com", to: "test-receiver@test.com", subject: "Test Subject", body: "Test Body")
|
2014-08-12 18:24:19 +00:00
|
|
|
end
|
2016-05-14 00:43:48 +00:00
|
|
|
|
2020-01-19 05:29:32 +00:00
|
|
|
def test_kwargs(argument:)
|
|
|
|
mail(from: "test-sender@test.com", to: "test-receiver@test.com", subject: "Test Subject", body: "Test Body")
|
|
|
|
end
|
|
|
|
|
2016-05-14 00:43:48 +00:00
|
|
|
def test_raise(klass_name)
|
2016-08-06 17:03:39 +00:00
|
|
|
raise klass_name.constantize, "boom"
|
2016-05-14 00:43:48 +00:00
|
|
|
end
|
2014-08-12 18:24:19 +00:00
|
|
|
end
|