diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-28 12:55:53 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-28 17:58:48 -0200 |
commit | 37586ddf279c46c3d0c8c2553d0918aa82ceb020 (patch) | |
tree | 007e6b8a334dfe24703491e8df635b5bd8114b23 /actionmailer/test | |
parent | 2b5d3aa442625169125ff0be95fe30f7d462ea54 (diff) | |
download | rails-37586ddf279c46c3d0c8c2553d0918aa82ceb020.tar.gz rails-37586ddf279c46c3d0c8c2553d0918aa82ceb020.tar.bz2 rails-37586ddf279c46c3d0c8c2553d0918aa82ceb020.zip |
Merge pull request #8048 from senny/7761_dont_render_view_without_mail_call
Do not render views when mail() isn't called. (NullMail refactoring)
Conflicts:
actionmailer/CHANGELOG.md
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 6 | ||||
-rw-r--r-- | actionmailer/test/fixtures/base_mailer/without_mail_call.erb | 1 | ||||
-rw-r--r-- | actionmailer/test/mailers/base_mailer.rb | 3 |
3 files changed, 10 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index d92fc01ef8..b69b26faf0 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -471,6 +471,12 @@ class BaseTest < ActiveSupport::TestCase assert_equal(%{<img alt="Dummy" src="http://local.com/images/dummy.png" />}, mail.body.to_s.strip) end + test 'the view is not rendered when mail was never called' do + mail = BaseMailer.without_mail_call + assert_equal('', mail.body.to_s.strip) + mail.deliver + end + # Before and After hooks class MyObserver diff --git a/actionmailer/test/fixtures/base_mailer/without_mail_call.erb b/actionmailer/test/fixtures/base_mailer/without_mail_call.erb new file mode 100644 index 0000000000..290379d5fb --- /dev/null +++ b/actionmailer/test/fixtures/base_mailer/without_mail_call.erb @@ -0,0 +1 @@ +<% raise 'the template should not be rendered' %>
\ No newline at end of file diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb index e55d72fdb4..8c4430b046 100644 --- a/actionmailer/test/mailers/base_mailer.rb +++ b/actionmailer/test/mailers/base_mailer.rb @@ -115,4 +115,7 @@ class BaseMailer < ActionMailer::Base def email_with_translations mail :body => render("email_with_translations", :formats => [:html]) end + + def without_mail_call + end end |