diff options
author | George Claghorn <george.claghorn@gmail.com> | 2017-09-27 17:45:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 17:45:28 -0400 |
commit | 212cf238e41f91a0d2ea5bb7ca50f13081b4c1ed (patch) | |
tree | 594cd47da7fd148ab97f091b699f78ef10de79ab /actionmailer/test/test_helper_test.rb | |
parent | 2235f6692279740131298edeb12cfe4cc8fd6ccc (diff) | |
parent | db6847dcb6448ceeebe6cc37cc7d960dc72a0082 (diff) | |
download | rails-212cf238e41f91a0d2ea5bb7ca50f13081b4c1ed.tar.gz rails-212cf238e41f91a0d2ea5bb7ca50f13081b4c1ed.tar.bz2 rails-212cf238e41f91a0d2ea5bb7ca50f13081b4c1ed.zip |
Merge pull request #30695 from mikker/add-asserts-enqueued-emails-with
Add assert_enqueued_email_with to ActionMailer::TestHelper
Diffstat (limited to 'actionmailer/test/test_helper_test.rb')
-rw-r--r-- | actionmailer/test/test_helper_test.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index abf50cf4da..5470d51599 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -10,6 +10,18 @@ class TestHelperMailer < ActionMailer::Base to: "test@example.com", from: "tester@example.com" end + + def test_args(recipient, name) + mail body: render(inline: "Hello, #{name}"), + to: recipient, + from: "tester@example.com" + end + + def test_parameter_args + mail body: render(inline: "All is #{params[:all]}"), + to: "test@example.com", + from: "tester@example.com" + end end class TestHelperMailerTest < ActionMailer::TestCase @@ -207,6 +219,36 @@ class TestHelperMailerTest < ActionMailer::TestCase assert_match(/0 .* but 1/, error.message) end + + def test_assert_enqueued_email_with + assert_nothing_raised do + assert_enqueued_email_with TestHelperMailer, :test do + silence_stream($stdout) do + TestHelperMailer.test.deliver_later + end + end + end + end + + def test_assert_enqueued_email_with_args + assert_nothing_raised do + assert_enqueued_email_with TestHelperMailer, :test_args, args: ["some_email", "some_name"] do + silence_stream($stdout) do + TestHelperMailer.test_args("some_email", "some_name").deliver_later + end + end + end + end + + def test_assert_enqueued_email_with_parameterized_args + assert_nothing_raised do + assert_enqueued_email_with TestHelperMailer, :test_parameter_args, args: { all: "good" } do + silence_stream($stdout) do + TestHelperMailer.with(all: "good").test_parameter_args.deliver_later + end + end + end + end end class AnotherTestHelperMailerTest < ActionMailer::TestCase |