aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-10-01 17:48:44 -0400
committerGeorge Claghorn <george@basecamp.com>2018-10-01 17:48:44 -0400
commit622901636b417731e4239359feef7cf6943b8b3c (patch)
tree58dc407940664c1a10bc74a2fe07b71cef410592 /test
parent704179251f3a96f7e7f2ed9b28e1524ace3a4927 (diff)
downloadrails-622901636b417731e4239359feef7cf6943b8b3c.tar.gz
rails-622901636b417731e4239359feef7cf6943b8b3c.tar.bz2
rails-622901636b417731e4239359feef7cf6943b8b3c.zip
Support nesting mailboxes in modules
Diffstat (limited to 'test')
-rw-r--r--test/unit/router_test.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/unit/router_test.rb b/test/unit/router_test.rb
index e244ff45f4..67a5f24c52 100644
--- a/test/unit/router_test.rb
+++ b/test/unit/router_test.rb
@@ -13,6 +13,11 @@ end
class SecondMailbox < RootMailbox
end
+module Nested
+ class FirstMailbox < RootMailbox
+ end
+end
+
class FirstMailboxAddress
def match?(inbound_email)
inbound_email.mail.to.include?("replies-class@example.com")
@@ -57,7 +62,7 @@ module ActionMailbox
assert_equal "SecondMailbox", $processed_by
assert_equal inbound_email.mail, $processed_mail
end
-
+
test "single regexp route" do
@router.add_routes(/replies-\w+@example.com/ => :first, "replies-nowhere@example.com" => :second)
@@ -81,6 +86,14 @@ module ActionMailbox
assert_equal "FirstMailbox", $processed_by
end
+ test "string route to nested mailbox" do
+ @router.add_route "first@example.com", to: "nested/first"
+
+ inbound_email = create_inbound_email_from_mail(to: "first@example.com", subject: "This is a reply")
+ @router.route inbound_email
+ assert_equal "Nested::FirstMailbox", $processed_by
+ end
+
test "missing route" do
assert_raises(ActionMailbox::Router::RoutingError) do
inbound_email = create_inbound_email_from_mail(to: "going-nowhere@example.com", subject: "This is a reply")