diff options
author | James Dabbs <jamesdabbs@gmail.com> | 2019-05-04 10:53:08 -0700 |
---|---|---|
committer | James Dabbs <jamesdabbs@gmail.com> | 2019-05-04 10:53:08 -0700 |
commit | 9f96d094a39100df53ea68b8bd6fa7fcafd96eac (patch) | |
tree | 237fec97bcb99065be3d464f25f2fa69bf34b6d0 /actionmailbox/test/unit/router_test.rb | |
parent | ac1ba44f8d46ebbbe6889629d263e5690631f6a1 (diff) | |
download | rails-9f96d094a39100df53ea68b8bd6fa7fcafd96eac.tar.gz rails-9f96d094a39100df53ea68b8bd6fa7fcafd96eac.tar.bz2 rails-9f96d094a39100df53ea68b8bd6fa7fcafd96eac.zip |
Expose `mailbox_for` method
Currently, the only exposed entry point into the ApplicationMailbox's configured
routing system is to call `route`, which performs a lot of work to fully
`process` inbound email. It'd be nice to have a way (e.g. in test) of checking
which mailbox an email would route to without necessarily processing it yet.
Diffstat (limited to 'actionmailbox/test/unit/router_test.rb')
-rw-r--r-- | actionmailbox/test/unit/router_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/actionmailbox/test/unit/router_test.rb b/actionmailbox/test/unit/router_test.rb index c5dce60856..4dd3730604 100644 --- a/actionmailbox/test/unit/router_test.rb +++ b/actionmailbox/test/unit/router_test.rb @@ -135,5 +135,19 @@ module ActionMailbox @router.add_route Array.new, to: :first end end + + test "single string mailbox_for" do + @router.add_routes("first@example.com" => :first) + + inbound_email = create_inbound_email_from_mail(to: "first@example.com", subject: "This is a reply") + assert_equal FirstMailbox, @router.mailbox_for(inbound_email) + end + + test "mailbox_for with no matches" do + @router.add_routes("first@example.com" => :first) + + inbound_email = create_inbound_email_from_mail(to: "second@example.com", subject: "This is a reply") + assert_nil @router.mailbox_for(inbound_email) + end end end |