diff options
author | Ronak Jangir <ronakjangir47@gmail.com> | 2015-09-18 22:56:42 +0530 |
---|---|---|
committer | Ronak Jangir <ronakjangir47@gmail.com> | 2015-09-18 22:56:42 +0530 |
commit | fef6c11d2afeb57028886c6c15febcf5be3945ae (patch) | |
tree | 975e80a29a9988d4c6b4602e13afc8d1e5c7cde9 /actionmailer | |
parent | e80b39c390c4fef3669f0341b30ae4741674f09c (diff) | |
download | rails-fef6c11d2afeb57028886c6c15febcf5be3945ae.tar.gz rails-fef6c11d2afeb57028886c6c15febcf5be3945ae.tar.bz2 rails-fef6c11d2afeb57028886c6c15febcf5be3945ae.zip |
Added test for `any` if called without specifying any format
Example
````ruby
mail(hash) do |format|
format.any
end
````
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/test/base_test.rb | 7 | ||||
-rw-r--r-- | actionmailer/test/mailers/base_mailer.rb | 6 |
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" } |