mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
commit
abaa73f34a
2 changed files with 12 additions and 1 deletions
|
@ -737,7 +737,7 @@ module ActionMailer
|
|||
end
|
||||
|
||||
class LateAttachmentsProxy < SimpleDelegator
|
||||
def inline; _raise_error end
|
||||
def inline; self end
|
||||
def []=(_name, _content); _raise_error end
|
||||
|
||||
private
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue