aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailbox/test
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2019-05-09 23:02:21 -0500
committerGitHub <noreply@github.com>2019-05-09 23:02:21 -0500
commit6394f9da6938d0dccfd8c95f10b2fb7ee98ab953 (patch)
tree366fc7d2a8c064f5c4987c4344d27ba5365a92e8 /actionmailbox/test
parent3363a3c2a54ab1796f1a520538820271f977bc71 (diff)
parent937f7d582efc75bae336fbf1de4bd93476ab7f5e (diff)
downloadrails-6394f9da6938d0dccfd8c95f10b2fb7ee98ab953.tar.gz
rails-6394f9da6938d0dccfd8c95f10b2fb7ee98ab953.tar.bz2
rails-6394f9da6938d0dccfd8c95f10b2fb7ee98ab953.zip
Merge pull request #36181 from jamesdabbs/jcd/action-mailbox-for
Expose `mailbox_for` method
Diffstat (limited to 'actionmailbox/test')
-rw-r--r--actionmailbox/test/unit/mailbox/routing_test.rb5
-rw-r--r--actionmailbox/test/unit/router_test.rb14
2 files changed, 19 insertions, 0 deletions
diff --git a/actionmailbox/test/unit/mailbox/routing_test.rb b/actionmailbox/test/unit/mailbox/routing_test.rb
index d4ba702ac5..8302b1d5cc 100644
--- a/actionmailbox/test/unit/mailbox/routing_test.rb
+++ b/actionmailbox/test/unit/mailbox/routing_test.rb
@@ -28,4 +28,9 @@ class ActionMailbox::Base::RoutingTest < ActiveSupport::TestCase
assert_equal "Discussion: Let's debate these attachments", $processed
end
end
+
+ test "mailbox_for" do
+ inbound_email = create_inbound_email_from_fixture "welcome.eml", status: :pending
+ assert_equal RepliesMailbox, ApplicationMailbox.mailbox_for(inbound_email)
+ end
end
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