From 3e199600ec1117b6595e402a27d1ae58c18b39e7 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 19 Sep 2018 16:38:33 -0700 Subject: [PATCH] Routing is a named concept now --- .../deliver_inbound_email_to_mailroom_job.rb | 7 ------- app/jobs/action_mailroom/routing_job.rb | 7 +++++++ app/models/action_mailroom/inbound_email.rb | 2 +- .../{deliver_to_mailroom_test.rb => routing_test.rb} | 4 ++-- test/unit/mailbox/routing_test.rb | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 app/jobs/action_mailroom/deliver_inbound_email_to_mailroom_job.rb create mode 100644 app/jobs/action_mailroom/routing_job.rb rename test/unit/inbound_email/{deliver_to_mailroom_test.rb => routing_test.rb} (50%) diff --git a/app/jobs/action_mailroom/deliver_inbound_email_to_mailroom_job.rb b/app/jobs/action_mailroom/deliver_inbound_email_to_mailroom_job.rb deleted file mode 100644 index 2a1ca97481..0000000000 --- a/app/jobs/action_mailroom/deliver_inbound_email_to_mailroom_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ActionMailroom::DeliverInboundEmailToMailroomJob < ActiveJob::Base - queue_as :action_mailroom_inbound_email - - def perform(inbound_email) - ApplicationMailbox.route inbound_email - end -end diff --git a/app/jobs/action_mailroom/routing_job.rb b/app/jobs/action_mailroom/routing_job.rb new file mode 100644 index 0000000000..85a3c7ab00 --- /dev/null +++ b/app/jobs/action_mailroom/routing_job.rb @@ -0,0 +1,7 @@ +class ActionMailroom::RoutingJob < ActiveJob::Base + queue_as :action_mailroom_routing + + def perform(inbound_email) + ApplicationMailbox.route inbound_email + end +end diff --git a/app/models/action_mailroom/inbound_email.rb b/app/models/action_mailroom/inbound_email.rb index 5c351b74b8..d44007c2f1 100644 --- a/app/models/action_mailroom/inbound_email.rb +++ b/app/models/action_mailroom/inbound_email.rb @@ -18,6 +18,6 @@ class ActionMailroom::InboundEmail < ActiveRecord::Base private def deliver_to_mailroom_later - ActionMailroom::DeliverInboundEmailToMailroomJob.perform_later self + ActionMailroom::RoutingJob.perform_later self end end diff --git a/test/unit/inbound_email/deliver_to_mailroom_test.rb b/test/unit/inbound_email/routing_test.rb similarity index 50% rename from test/unit/inbound_email/deliver_to_mailroom_test.rb rename to test/unit/inbound_email/routing_test.rb index ff67057cb8..8f946b24f5 100644 --- a/test/unit/inbound_email/deliver_to_mailroom_test.rb +++ b/test/unit/inbound_email/routing_test.rb @@ -1,8 +1,8 @@ require_relative '../../test_helper' -class ActionMailroom::InboundEmail::DeliverToMailroomTest < ActiveSupport::TestCase +class ActionMailroom::InboundEmail::RoutingTest < ActiveSupport::TestCase test "pending emails are delivered to the mailroom" do - assert_enqueued_jobs 1, only: ActionMailroom::DeliverInboundEmailToMailroomJob do + assert_enqueued_jobs 1, only: ActionMailroom::RoutingJob do create_inbound_email("welcome.eml", status: :pending) end end diff --git a/test/unit/mailbox/routing_test.rb b/test/unit/mailbox/routing_test.rb index 9771efcf40..6026686bea 100644 --- a/test/unit/mailbox/routing_test.rb +++ b/test/unit/mailbox/routing_test.rb @@ -22,7 +22,7 @@ class ActionMailroom::Mailbox::RoutingTest < ActiveSupport::TestCase end test "delayed routing" do - perform_enqueued_jobs only: ActionMailroom::DeliverInboundEmailToMailroomJob do + perform_enqueued_jobs only: ActionMailroom::RoutingJob do another_inbound_email = create_inbound_email("welcome.eml", status: :pending) assert_equal "Discussion: Let's debate these attachments", $processed end