mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Support nesting mailboxes in modules
This commit is contained in:
parent
704179251f
commit
622901636b
2 changed files with 15 additions and 2 deletions
|
@ -21,7 +21,7 @@ class ActionMailbox::Router::Route
|
|||
end
|
||||
|
||||
def mailbox_class
|
||||
"#{mailbox_name.to_s.capitalize}Mailbox".constantize
|
||||
"#{mailbox_name.to_s.camelize}Mailbox".constantize
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -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")
|
||||
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue