From a1d449e061d163fc0f6cb8c966d9ebf70923b665 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 6 Dec 2018 13:27:45 -0800 Subject: Add a :all catch-all route --- test/unit/router_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/unit') diff --git a/test/unit/router_test.rb b/test/unit/router_test.rb index b8c187f95e..70d39ba6a1 100644 --- a/test/unit/router_test.rb +++ b/test/unit/router_test.rb @@ -103,6 +103,23 @@ module ActionMailbox assert_equal "Nested::FirstMailbox", $processed_by end + test "all as the only route" do + @router.add_route :all, to: :first + @router.route create_inbound_email_from_mail(to: "replies-class@example.com", subject: "This is a reply") + assert_equal "FirstMailbox", $processed_by + end + + test "all as the second route" do + @router.add_route FirstMailboxAddress.new, to: :first + @router.add_route :all, to: :second + + @router.route create_inbound_email_from_mail(to: "replies-class@example.com", subject: "This is a reply") + assert_equal "FirstMailbox", $processed_by + + @router.route create_inbound_email_from_mail(to: "elsewhere@example.com", subject: "This is a reply") + assert_equal "SecondMailbox", $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") -- cgit v1.2.3