diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2017-01-30 13:41:08 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2017-01-30 13:41:08 +0100 |
commit | d5651436d64c1a3f0b95910cb66c13bb29229f46 (patch) | |
tree | d38f666d23828884759548dc95d29c73bacc17ed /actionmailer | |
parent | 6b7bfece376c025e1da04478c0e34a88bdb9cf83 (diff) | |
download | rails-d5651436d64c1a3f0b95910cb66c13bb29229f46.tar.gz rails-d5651436d64c1a3f0b95910cb66c13bb29229f46.tar.bz2 rails-d5651436d64c1a3f0b95910cb66c13bb29229f46.zip |
Make assert_enqueued_emails + assert_no_enqueued_emails consider parameterized delivery jobs
Needed for testing of parameterized mailers
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/test_helper.rb | 4 | ||||
-rw-r--r-- | actionmailer/test/test_helper_test.rb | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/actionmailer/lib/action_mailer/test_helper.rb b/actionmailer/lib/action_mailer/test_helper.rb index c17ecad4c6..c30fb1fc18 100644 --- a/actionmailer/lib/action_mailer/test_helper.rb +++ b/actionmailer/lib/action_mailer/test_helper.rb @@ -88,7 +88,7 @@ module ActionMailer # end # end def assert_enqueued_emails(number, &block) - assert_enqueued_jobs number, only: ActionMailer::DeliveryJob, &block + assert_enqueued_jobs number, only: [ ActionMailer::DeliveryJob, ActionMailer::Parameterized::DeliveryJob ], &block end # Asserts that no emails are enqueued for later delivery. @@ -107,7 +107,7 @@ module ActionMailer # end # end def assert_no_enqueued_emails(&block) - assert_no_enqueued_jobs only: ActionMailer::DeliveryJob, &block + assert_no_enqueued_jobs only: [ ActionMailer::DeliveryJob, ActionMailer::Parameterized::DeliveryJob ], &block end end end diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 31ac5a5211..876e9b0634 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -143,6 +143,16 @@ class TestHelperMailerTest < ActionMailer::TestCase end end + def test_assert_enqueued_parameterized_emails + assert_nothing_raised do + assert_enqueued_emails 1 do + silence_stream($stdout) do + TestHelperMailer.with(a: 1).test.deliver_later + end + end + end + end + def test_assert_enqueued_emails_too_few_sent error = assert_raise ActiveSupport::TestCase::Assertion do assert_enqueued_emails 2 do @@ -176,6 +186,14 @@ class TestHelperMailerTest < ActionMailer::TestCase end end + def test_assert_no_enqueued_parameterized_emails + assert_nothing_raised do + assert_no_enqueued_emails do + TestHelperMailer.with(a: 1).test.deliver_now + end + end + end + def test_assert_no_enqueued_emails_failure error = assert_raise ActiveSupport::TestCase::Assertion do assert_no_enqueued_emails do |