mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix that adding attachments lose a body
This commit is contained in:
parent
9608b180bf
commit
88453093d5
2 changed files with 23 additions and 2 deletions
|
@ -22,7 +22,7 @@ module Rails
|
|||
def new_mail
|
||||
Mail.new(params.require(:mail).permit(:from, :to, :cc, :bcc, :in_reply_to, :subject, :body).to_h).tap do |mail|
|
||||
params[:mail][:attachments].to_a.each do |attachment|
|
||||
mail.attachments[attachment.original_filename] = { filename: attachment.path, content_type: attachment.content_type }
|
||||
mail.add_file(filename: attachment.path, content: attachment.read)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,25 @@ require "test_helper"
|
|||
|
||||
class Rails::Conductor::ActionMailbox::InboundEmailsControllerTest < ActionDispatch::IntegrationTest
|
||||
test "create inbound email" do
|
||||
with_rails_env("development") do
|
||||
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do
|
||||
post rails_conductor_inbound_emails_path, params: {
|
||||
mail: {
|
||||
from: "Jason Fried <jason@37signals.com>",
|
||||
to: "Replies <replies@example.com>",
|
||||
bcc: "",
|
||||
in_reply_to: "<4e6e35f5a38b4_479f13bb90078178@small-app-01.mail>",
|
||||
subject: "Create",
|
||||
body: "New Mail"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_equal "New Mail", ActionMailbox::InboundEmail.last.mail.decoded
|
||||
end
|
||||
end
|
||||
|
||||
test "create inbound email with attachments" do
|
||||
with_rails_env("development") do
|
||||
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do
|
||||
post rails_conductor_inbound_emails_path, params: {
|
||||
|
@ -19,7 +38,9 @@ class Rails::Conductor::ActionMailbox::InboundEmailsControllerTest < ActionDispa
|
|||
}
|
||||
end
|
||||
|
||||
assert_equal 2, ActionMailbox::InboundEmail.last.mail.attachments.size
|
||||
mail = ActionMailbox::InboundEmail.last.mail
|
||||
assert_equal 2, mail.attachments.size
|
||||
assert_equal "Let's talk about these images:", mail.text_part.decoded
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue