aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/action_mailbox/router/route.rb4
-rw-r--r--test/unit/router_test.rb9
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/action_mailbox/router/route.rb b/lib/action_mailbox/router/route.rb
index e9acf310b1..e123a93bb1 100644
--- a/lib/action_mailbox/router/route.rb
+++ b/lib/action_mailbox/router/route.rb
@@ -10,9 +10,9 @@ class ActionMailbox::Router::Route
def match?(inbound_email)
case address
when String
- recipients_from(inbound_email.mail).include?(address)
+ recipients_from(inbound_email.mail).any? { |recipient| address.casecmp?(recipient) }
when Regexp
- recipients_from(inbound_email.mail).detect { |recipient| address.match?(recipient) }
+ recipients_from(inbound_email.mail).any? { |recipient| address.match?(recipient) }
when Proc
address.call(inbound_email)
else
diff --git a/test/unit/router_test.rb b/test/unit/router_test.rb
index 67a5f24c52..cc87ae6c0e 100644
--- a/test/unit/router_test.rb
+++ b/test/unit/router_test.rb
@@ -49,6 +49,15 @@ module ActionMailbox
assert_equal inbound_email.mail, $processed_mail
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
@router.add_routes("first@example.com" => :first, "second@example.com" => :second)