aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2015-09-18 21:33:18 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2015-09-18 21:33:18 +0200
commitd4a2470f89c4f1edb8bd21d59008af8ad664369f (patch)
treeb9a28e15ee762cacea29e05f813ae0b4034cd643
parent2a9cf7995742ee014ab591e58eb5566ec99d3837 (diff)
parentfef6c11d2afeb57028886c6c15febcf5be3945ae (diff)
downloadrails-d4a2470f89c4f1edb8bd21d59008af8ad664369f.tar.gz
rails-d4a2470f89c4f1edb8bd21d59008af8ad664369f.tar.bz2
rails-d4a2470f89c4f1edb8bd21d59008af8ad664369f.zip
Merge pull request #21667 from ronakjangir47/test_action_mailer_without_any_format
Added test for `any` if called without specifying any format
-rw-r--r--actionmailer/test/base_test.rb7
-rw-r--r--actionmailer/test/mailers/base_mailer.rb6
2 files changed, 13 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 6b2e6a531c..9d6b6c7914 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -449,6 +449,13 @@ class BaseTest < ActiveSupport::TestCase
assert_equal("Format with any!", email.parts[1].body.encoded)
end
+ test 'test' do
+ error = assert_raises(ArgumentError) do
+ BaseMailer.explicit_without_specifying_format_with_any.parts
+ end
+ assert_equal "You have to supply at least one format", error.message
+ end
+
test "explicit multipart with format(Hash)" do
email = BaseMailer.explicit_multipart_with_options(true)
email.ready_to_send!
diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb
index bd991e209e..8c2225ce60 100644
--- a/actionmailer/test/mailers/base_mailer.rb
+++ b/actionmailer/test/mailers/base_mailer.rb
@@ -80,6 +80,12 @@ class BaseMailer < ActionMailer::Base
end
end
+ def explicit_without_specifying_format_with_any(hash = {})
+ mail(hash) do |format|
+ format.any
+ end
+ end
+
def explicit_multipart_with_options(include_html = false)
mail do |format|
format.text(content_transfer_encoding: "base64"){ render "welcome" }