aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorGannon McGibbon <gannon.mcgibbon@gmail.com>2018-03-12 14:30:25 -0400
committerGannon McGibbon <gannon.mcgibbon@shopify.com>2018-03-12 15:35:18 -0400
commit96218b45680e210fcda647401cf4feeb60bfe41b (patch)
tree7936e43b9fc3cdf2a9d915ac265d115982632397 /actionmailer/test
parent309bb6c4d068b0d480681cf4ef1b90158527dfe5 (diff)
downloadrails-96218b45680e210fcda647401cf4feeb60bfe41b.tar.gz
rails-96218b45680e210fcda647401cf4feeb60bfe41b.tar.bz2
rails-96218b45680e210fcda647401cf4feeb60bfe41b.zip
Perform email jobs in #assert_emails
Perform enqueued delivery jobs in #assert_emails and #assert_no_emails.
Diffstat (limited to 'actionmailer/test')
-rw-r--r--actionmailer/test/test_helper_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb
index 3866097389..8fdc687a8b 100644
--- a/actionmailer/test/test_helper_test.rb
+++ b/actionmailer/test/test_helper_test.rb
@@ -69,6 +69,16 @@ class TestHelperMailerTest < ActionMailer::TestCase
end
end
+ def test_assert_emails_with_enqueued_emails
+ assert_nothing_raised do
+ assert_emails 1 do
+ silence_stream($stdout) do
+ TestHelperMailer.test.deliver_later
+ end
+ end
+ end
+ end
+
def test_repeated_assert_emails_calls
assert_nothing_raised do
assert_emails 1 do
@@ -105,6 +115,18 @@ class TestHelperMailerTest < ActionMailer::TestCase
end
end
+ def test_assert_no_emails_with_enqueued_emails
+ error = assert_raise ActiveSupport::TestCase::Assertion do
+ assert_no_emails do
+ silence_stream($stdout) do
+ TestHelperMailer.test.deliver_later
+ end
+ end
+ end
+
+ assert_match(/0 .* but 1/, error.message)
+ end
+
def test_assert_emails_too_few_sent
error = assert_raise ActiveSupport::TestCase::Assertion do
assert_emails 2 do