diff options
author | arktisklada <mail@enorganik.com> | 2016-04-22 07:51:39 -0500 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-25 22:41:18 -0500 |
commit | 9d63111499164884635462bb09f5de979e7bffb9 (patch) | |
tree | ab948b05699cd156b8fd1bcefa97ef41daf276e0 /actionmailer/lib/action_mailer | |
parent | 9364d50654a791e6405b0a14854ab08cd5420cab (diff) | |
download | rails-9d63111499164884635462bb09f5de979e7bffb9.tar.gz rails-9d63111499164884635462bb09f5de979e7bffb9.tar.bz2 rails-9d63111499164884635462bb09f5de979e7bffb9.zip |
Clear ActionMailer deliveries on setup and teardown
Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/test_case.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/actionmailer/lib/action_mailer/test_case.rb b/actionmailer/lib/action_mailer/test_case.rb index 65e7347ae4..b045e883ad 100644 --- a/actionmailer/lib/action_mailer/test_case.rb +++ b/actionmailer/lib/action_mailer/test_case.rb @@ -15,10 +15,12 @@ module ActionMailer extend ActiveSupport::Concern included do + setup :clear_test_deliveries teardown :clear_test_deliveries end private + def clear_test_deliveries if ActionMailer::Base.delivery_method == :test ActionMailer::Base.deliveries.clear @@ -76,6 +78,7 @@ module ActionMailer set_delivery_method :test @old_perform_deliveries = ActionMailer::Base.perform_deliveries ActionMailer::Base.perform_deliveries = true + ActionMailer::Base.deliveries.clear end def restore_test_deliveries # :nodoc: @@ -89,6 +92,7 @@ module ActionMailer end def restore_delivery_method # :nodoc: + ActionMailer::Base.deliveries.clear ActionMailer::Base.delivery_method = @old_delivery_method end @@ -114,6 +118,5 @@ module ActionMailer end include Behavior - include ClearTestDeliveries end end |