From 04db4c286888aad1023c05488fe4def876f85e1c Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Tue, 19 Aug 2014 23:26:45 -0300 Subject: Add `set_delivery_method` and `restore_delivery_method` to `ActionMailer::TestCase`. This way these methods are available outside the ActionMailer test suite, but they are still duplicated inside `test/abstract_unit` for test cases that don't inherit from the `ActionMailer::TestCase` class. --- actionmailer/lib/action_mailer/test_case.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index d507032838..b53d2b7fa0 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -68,6 +68,15 @@ module ActionMailer ActionMailer::Base.deliveries.clear end + def set_delivery_method(method) + @old_delivery_method = ActionMailer::Base.delivery_method + ActionMailer::Base.delivery_method = method + end + + def restore_delivery_method + ActionMailer::Base.delivery_method = @old_delivery_method + end + def set_expected_mail @expected = Mail.new @expected.content_type ["text", "plain", { "charset" => charset }] -- cgit v1.2.3