Fix Bcc header missing with emails from conductor and test helpers

This commit is contained in:
John Duff 2019-04-16 08:04:38 -04:00
parent 41bc4c6207
commit 09e5d6d004
4 changed files with 39 additions and 1 deletions

@ -1,3 +1,7 @@
* Fix Bcc header not being included with emails from `create_inbound_email_from` test helpers.
*jduff*
* Add `ApplicationMailbox.mailbox_for` to expose mailbox routing.
*James Dabbs*

@ -14,7 +14,11 @@ def create_inbound_email_from_fixture(fixture_name, status: :processing)
#
# create_inbound_email_from_mail(from: "david@loudthinking.com", subject: "Hello!")
def create_inbound_email_from_mail(status: :processing, **mail_options)
create_inbound_email_from_source Mail.new(mail_options).to_s, status: status
mail = Mail.new(mail_options)
# Bcc header is not encoded by default
mail[:bcc].include_in_headers = true if mail[:bcc]
create_inbound_email_from_source mail.to_s, status: status
end
# Create an +InboundEmail+ using the raw rfc822 +source+ as text.

@ -30,6 +30,27 @@ class Rails::Conductor::ActionMailbox::InboundEmailsControllerTest < ActionDispa
end
end
test "create inbound email with bcc" 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>",
bcc: "Replies <replies@example.com>",
subject: "Hey there",
body: "How's it going?"
}
}
end
mail = ActionMailbox::InboundEmail.last.mail
assert_equal %w[ jason@37signals.com ], mail.from
assert_equal %w[ replies@example.com ], mail.bcc
assert_equal "Hey there", mail.subject
assert_equal "How's it going?", mail.body.decoded
end
end
test "create inbound email with attachments" do
with_rails_env("development") do
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do

@ -51,6 +51,15 @@ class RouterTest < ActiveSupport::TestCase
assert_equal inbound_email.mail, $processed_mail
end
test "single string routing on bcc" do
@router.add_routes("first@example.com" => :first)
inbound_email = create_inbound_email_from_mail(to: "someone@example.com", bcc: "first@example.com", subject: "This is a reply")
@router.route inbound_email
assert_equal "FirstMailbox", $processed_by
assert_equal inbound_email.mail, $processed_mail
end
test "single string routing case-insensitively" do
@router.add_routes("first@example.com" => :first)