mirror of https://github.com/rails/rails
Merge pull request #45103 from dorianmariefr/issue-45088-error-when-submitting-action-mailbox-conductor-form
Fixes development Action Mailbox new mail form
This commit is contained in:
commit
85cd509084
|
@ -22,7 +22,7 @@ module Rails
|
|||
def new_mail
|
||||
Mail.new(mail_params.except(:attachments).to_h).tap do |mail|
|
||||
mail[:bcc]&.include_in_headers = true
|
||||
mail_params[:attachments].to_a.each do |attachment|
|
||||
mail_params[:attachments]&.select(&:present?)&.each do |attachment|
|
||||
mail.add_file(filename: attachment.original_filename, content: attachment.read)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -72,6 +72,29 @@ class Rails::Conductor::ActionMailbox::InboundEmailsControllerTest < ActionDispa
|
|||
end
|
||||
end
|
||||
|
||||
test "create inbound email with empty attachment" do
|
||||
with_rails_env("development") do
|
||||
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do
|
||||
post rails_conductor_inbound_emails_path, params: {
|
||||
mail: {
|
||||
from: "",
|
||||
to: "",
|
||||
cc: "",
|
||||
bcc: "",
|
||||
x_original_to: "",
|
||||
subject: "",
|
||||
in_reply_to: "",
|
||||
body: "",
|
||||
attachments: [ "" ],
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
mail = ActionMailbox::InboundEmail.last.mail
|
||||
assert_equal 0, mail.attachments.count
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def with_rails_env(env)
|
||||
old_rails_env = Rails.env
|
||||
|
|
Loading…
Reference in New Issue