mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Compare addresses case-insensitively
This commit is contained in:
parent
a91dc46b32
commit
015c33f4cd
2 changed files with 11 additions and 2 deletions
|
@ -10,9 +10,9 @@ class ActionMailbox::Router::Route
|
||||||
def match?(inbound_email)
|
def match?(inbound_email)
|
||||||
case address
|
case address
|
||||||
when String
|
when String
|
||||||
recipients_from(inbound_email.mail).include?(address)
|
recipients_from(inbound_email.mail).any? { |recipient| address.casecmp?(recipient) }
|
||||||
when Regexp
|
when Regexp
|
||||||
recipients_from(inbound_email.mail).detect { |recipient| address.match?(recipient) }
|
recipients_from(inbound_email.mail).any? { |recipient| address.match?(recipient) }
|
||||||
when Proc
|
when Proc
|
||||||
address.call(inbound_email)
|
address.call(inbound_email)
|
||||||
else
|
else
|
||||||
|
|
|
@ -49,6 +49,15 @@ module ActionMailbox
|
||||||
assert_equal inbound_email.mail, $processed_mail
|
assert_equal inbound_email.mail, $processed_mail
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "single string routing case-insensitively" do
|
||||||
|
@router.add_routes("first@example.com" => :first)
|
||||||
|
|
||||||
|
inbound_email = create_inbound_email_from_mail(to: "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 "multiple string routes" do
|
test "multiple string routes" do
|
||||||
@router.add_routes("first@example.com" => :first, "second@example.com" => :second)
|
@router.add_routes("first@example.com" => :first, "second@example.com" => :second)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue