2017-07-23 11:17:16 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 13:03:39 -04:00
|
|
|
require "abstract_unit"
|
2011-10-03 03:04:22 -04:00
|
|
|
|
|
|
|
class TestTestMailer < ActionMailer::Base
|
|
|
|
end
|
|
|
|
|
2016-04-22 08:51:39 -04:00
|
|
|
class ClearTestDeliveriesMixinTest < ActiveSupport::TestCase
|
|
|
|
include ActionMailer::TestCase::ClearTestDeliveries
|
|
|
|
|
|
|
|
def before_setup
|
|
|
|
ActionMailer::Base.delivery_method, @original_delivery_method = :test, ActionMailer::Base.delivery_method
|
2016-08-06 13:03:39 -04:00
|
|
|
ActionMailer::Base.deliveries << "better clear me, setup"
|
2016-04-22 08:51:39 -04:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_teardown
|
|
|
|
super
|
|
|
|
assert_equal [], ActionMailer::Base.deliveries
|
|
|
|
ActionMailer::Base.delivery_method = @original_delivery_method
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_deliveries_are_cleared_on_setup_and_teardown
|
|
|
|
assert_equal [], ActionMailer::Base.deliveries
|
2016-08-06 13:03:39 -04:00
|
|
|
ActionMailer::Base.deliveries << "better clear me, teardown"
|
2016-04-22 08:51:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class MailerDeliveriesClearingTest < ActionMailer::TestCase
|
|
|
|
def before_setup
|
2016-08-06 13:03:39 -04:00
|
|
|
ActionMailer::Base.deliveries << "better clear me, setup"
|
2016-04-22 08:51:39 -04:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_teardown
|
|
|
|
super
|
|
|
|
assert_equal [], ActionMailer::Base.deliveries
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_deliveries_are_cleared_on_setup_and_teardown
|
|
|
|
assert_equal [], ActionMailer::Base.deliveries
|
2016-08-06 13:03:39 -04:00
|
|
|
ActionMailer::Base.deliveries << "better clear me, teardown"
|
2016-04-22 08:51:39 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-03 03:04:22 -04:00
|
|
|
class CrazyNameMailerTest < ActionMailer::TestCase
|
|
|
|
tests TestTestMailer
|
|
|
|
|
|
|
|
def test_set_mailer_class_manual
|
|
|
|
assert_equal TestTestMailer, self.class.mailer_class
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class CrazySymbolNameMailerTest < ActionMailer::TestCase
|
|
|
|
tests :test_test_mailer
|
|
|
|
|
|
|
|
def test_set_mailer_class_manual_using_symbol
|
|
|
|
assert_equal TestTestMailer, self.class.mailer_class
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class CrazyStringNameMailerTest < ActionMailer::TestCase
|
2016-08-06 13:03:39 -04:00
|
|
|
tests "test_test_mailer"
|
2011-10-03 03:04:22 -04:00
|
|
|
|
|
|
|
def test_set_mailer_class_manual_using_string
|
|
|
|
assert_equal TestTestMailer, self.class.mailer_class
|
|
|
|
end
|
|
|
|
end
|