2018-12-14 05:06:12 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-24 15:16:22 -05:00
|
|
|
require_relative "../../test_helper"
|
2018-09-19 18:52:16 -04:00
|
|
|
|
2018-09-28 15:19:43 -04:00
|
|
|
class ApplicationMailbox < ActionMailbox::Base
|
2018-09-19 18:52:16 -04:00
|
|
|
routing "replies@example.com" => :replies
|
|
|
|
end
|
|
|
|
|
2018-09-28 15:19:43 -04:00
|
|
|
class RepliesMailbox < ActionMailbox::Base
|
2018-09-19 18:52:16 -04:00
|
|
|
def process
|
|
|
|
$processed = mail.subject
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-28 15:19:43 -04:00
|
|
|
class ActionMailbox::Base::RoutingTest < ActiveSupport::TestCase
|
2018-09-19 18:52:16 -04:00
|
|
|
setup do
|
|
|
|
$processed = false
|
|
|
|
end
|
|
|
|
|
|
|
|
test "string routing" do
|
2019-01-17 12:13:40 -05:00
|
|
|
ApplicationMailbox.route create_inbound_email_from_fixture("welcome.eml")
|
2018-09-19 18:52:16 -04:00
|
|
|
assert_equal "Discussion: Let's debate these attachments", $processed
|
|
|
|
end
|
2018-09-19 19:23:14 -04:00
|
|
|
|
|
|
|
test "delayed routing" do
|
2018-09-28 15:19:43 -04:00
|
|
|
perform_enqueued_jobs only: ActionMailbox::RoutingJob do
|
2018-10-17 12:42:54 -04:00
|
|
|
create_inbound_email_from_fixture "welcome.eml", status: :pending
|
2018-09-19 19:23:14 -04:00
|
|
|
assert_equal "Discussion: Let's debate these attachments", $processed
|
|
|
|
end
|
|
|
|
end
|
2019-05-04 13:53:08 -04:00
|
|
|
|
|
|
|
test "mailbox_for" do
|
2019-05-05 13:29:31 -04:00
|
|
|
inbound_email = create_inbound_email_from_fixture "welcome.eml", status: :pending
|
|
|
|
assert_equal RepliesMailbox, ApplicationMailbox.mailbox_for(inbound_email)
|
2019-05-04 13:53:08 -04:00
|
|
|
end
|
2018-09-19 18:52:16 -04:00
|
|
|
end
|