diff options
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 14 | ||||
-rw-r--r-- | actionmailer/test/fixtures/base_test/late_inline_attachment_mailer/on_render.erb | 7 |
2 files changed, 21 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index d00f5aea47..dcb6959543 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -259,6 +259,20 @@ class BaseTest < ActiveSupport::TestCase assert_match(/Can't add attachments after `mail` was called./, e.message) end + test "adding inline attachments while rendering mail works" do + class LateInlineAttachmentMailer < ActionMailer::Base + def on_render + mail from: "welcome@example.com", to: "to@example.com" + end + end + + mail = LateInlineAttachmentMailer.on_render + assert_nothing_raised { mail.message } + + assert_equal ["image/jpeg; filename=controller_attachments.jpg", + "image/jpeg; filename=attachments.jpg"], mail.attachments.inline.map {|a| a['Content-Type'].to_s } + end + test "accessing attachments works after mail was called" do class LateAttachmentAccessorMailer < ActionMailer::Base def welcome diff --git a/actionmailer/test/fixtures/base_test/late_inline_attachment_mailer/on_render.erb b/actionmailer/test/fixtures/base_test/late_inline_attachment_mailer/on_render.erb new file mode 100644 index 0000000000..6decd3bb31 --- /dev/null +++ b/actionmailer/test/fixtures/base_test/late_inline_attachment_mailer/on_render.erb @@ -0,0 +1,7 @@ +<h1>Adding an inline image while rendering</h1> + +<% controller.attachments.inline["controller_attachments.jpg"] = 'via controller.attachments.inline' %> +<%= image_tag attachments['controller_attachments.jpg'].url %> + +<% attachments.inline["attachments.jpg"] = 'via attachments.inline' %> +<%= image_tag attachments['attachments.jpg'].url %> |