diff options
author | Eugene Kenny <elkenny@gmail.com> | 2017-01-31 03:36:23 +0000 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2017-01-30 22:20:47 -0700 |
commit | ebededb3726a8143a4372fdf19ad10fe9fe2e233 (patch) | |
tree | b8e5d788c285941d2df2c7a200abdb73814abe23 /railties | |
parent | d1e06546499c858db6e16f60c9f0bb7a3fda0a41 (diff) | |
download | rails-ebededb3726a8143a4372fdf19ad10fe9fe2e233.tar.gz rails-ebededb3726a8143a4372fdf19ad10fe9fe2e233.tar.bz2 rails-ebededb3726a8143a4372fdf19ad10fe9fe2e233.zip |
Don't mutate raw_source in mailer preview interceptor
The raw_source method is documented as returning the exact value that
was used to create the body; mutating it breaks that contract.
Additionally, if the value used to create the body is blank, raw_source
returns a frozen string which causes the interceptor to raise an error.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/mailer_previews_test.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/railties/test/application/mailer_previews_test.rb b/railties/test/application/mailer_previews_test.rb index 790aca2aa4..c3a360e5d4 100644 --- a/railties/test/application/mailer_previews_test.rb +++ b/railties/test/application/mailer_previews_test.rb @@ -671,6 +671,40 @@ module ApplicationTests assert_match %r[<p>Hello, World!</p>], last_response.body end + test "multipart mailer preview with empty parts" do + mailer "notifier", <<-RUBY + class Notifier < ActionMailer::Base + default from: "from@example.com" + + def foo + mail to: "to@example.org" + end + end + RUBY + + text_template "notifier/foo", <<-RUBY + RUBY + + html_template "notifier/foo", <<-RUBY + RUBY + + mailer_preview "notifier", <<-RUBY + class NotifierPreview < ActionMailer::Preview + def foo + Notifier.foo + end + end + RUBY + + app("development") + + get "/rails/mailers/notifier/foo?part=text/plain" + assert_equal 200, last_response.status + + get "/rails/mailers/notifier/foo?part=text/html" + assert_equal 200, last_response.status + end + private def build_app super |