aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorRafael França <rafael@franca.dev>2019-07-26 16:00:44 -0400
committerGitHub <noreply@github.com>2019-07-26 16:00:44 -0400
commitabaa73f34ae71362e0c61e212106ddc2a62f8b02 (patch)
tree903fd64f03f40ed41fb400cd96d45fee53a9ccf1 /actionmailer/test
parentdd6032d02740299ac7ca09740dcae419c6a29ae7 (diff)
parentefeddb08dae3dc6240118444234e3acdcfdffaa1 (diff)
downloadrails-abaa73f34ae71362e0c61e212106ddc2a62f8b02.tar.gz
rails-abaa73f34ae71362e0c61e212106ddc2a62f8b02.tar.bz2
rails-abaa73f34ae71362e0c61e212106ddc2a62f8b02.zip
Merge pull request #36227 from betesh/avoid-misleading-error-about-late-attachments
Prevent reading inline attachments after `mail` was called from raising an inaccurate exception
Diffstat (limited to 'actionmailer/test')
-rw-r--r--actionmailer/test/base_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 4ea5634cd0..a6223964e5 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -267,6 +267,17 @@ class BaseTest < ActiveSupport::TestCase
assert_match(/Can't add attachments after `mail` was called./, e.message)
end
+ test "accessing inline attachments after mail was called works" do
+ class LateInlineAttachmentMailer < ActionMailer::Base
+ def welcome
+ mail body: "yay", from: "welcome@example.com", to: "to@example.com"
+ attachments.inline["invoice.pdf"]
+ end
+ end
+
+ assert_nothing_raised { LateInlineAttachmentMailer.welcome.message }
+ end
+
test "adding inline attachments while rendering mail works" do
class LateInlineAttachmentMailer < ActionMailer::Base
def on_render