aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorYoshiyuki Kinjo <yskkin@gmail.com>2018-09-08 17:14:12 +0900
committerYoshiyuki Kinjo <yskkin@gmail.com>2018-09-08 17:29:28 +0900
commit383b8bc8e215d5fa2b018d6f0b9c363ea95251cf (patch)
tree3fed38fc6682c1dcc753d58accb2e543652a2e20 /actionmailer/test
parent5f35c60f848dda275e34bc055f58031c08d7b416 (diff)
downloadrails-383b8bc8e215d5fa2b018d6f0b9c363ea95251cf.tar.gz
rails-383b8bc8e215d5fa2b018d6f0b9c363ea95251cf.tar.bz2
rails-383b8bc8e215d5fa2b018d6f0b9c363ea95251cf.zip
Skip delivery notification when perform_deliveries is false.
Diffstat (limited to 'actionmailer/test')
-rw-r--r--actionmailer/test/log_subscriber_test.rb11
-rw-r--r--actionmailer/test/mailers/base_mailer.rb5
2 files changed, 16 insertions, 0 deletions
diff --git a/actionmailer/test/log_subscriber_test.rb b/actionmailer/test/log_subscriber_test.rb
index 2e89758dfb..48edb80c0c 100644
--- a/actionmailer/test/log_subscriber_test.rb
+++ b/actionmailer/test/log_subscriber_test.rb
@@ -37,6 +37,17 @@ class AMLogSubscriberTest < ActionMailer::TestCase
BaseMailer.deliveries.clear
end
+ def test_deliver_is_not_notified_when_perform_deliveries_is_false
+ BaseMailer.welcome_without_deliveries.deliver_now
+ wait
+
+ assert_equal(0, @logger.logged(:info).size)
+ assert_equal(1, @logger.logged(:debug).size)
+ assert_match(/BaseMailer#welcome_without_deliveries: processed outbound mail in [\d.]+ms/, @logger.logged(:debug).first)
+ ensure
+ BaseMailer.deliveries.clear
+ end
+
def test_receive_is_notified
fixture = File.read(File.expand_path("fixtures/raw_email", __dir__))
TestMailer.receive(fixture)
diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb
index bfaecdb658..a3101207dc 100644
--- a/actionmailer/test/mailers/base_mailer.rb
+++ b/actionmailer/test/mailers/base_mailer.rb
@@ -21,6 +21,11 @@ class BaseMailer < ActionMailer::Base
mail(template_name: "welcome", template_path: path)
end
+ def welcome_without_deliveries
+ mail(template_name: "welcome")
+ mail.perform_deliveries = false
+ end
+
def html_only(hash = {})
mail(hash)
end