aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorMikkel Malmberg <mikkel@brnbw.com>2017-09-24 19:55:32 +0200
committerMikkel Malmberg <mikkel@brnbw.com>2017-09-27 23:22:49 +0200
commitdb6847dcb6448ceeebe6cc37cc7d960dc72a0082 (patch)
tree95956435e2fd9c0024efc65159fea51f53ce6ffd /actionmailer/test
parent36888b9387731394f0079fc855ab9ad61ba8dfe5 (diff)
downloadrails-db6847dcb6448ceeebe6cc37cc7d960dc72a0082.tar.gz
rails-db6847dcb6448ceeebe6cc37cc7d960dc72a0082.tar.bz2
rails-db6847dcb6448ceeebe6cc37cc7d960dc72a0082.zip
Add assert_enqueued_email_with to ActionMailer::TestHelper
Diffstat (limited to 'actionmailer/test')
-rw-r--r--actionmailer/test/test_helper_test.rb42
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