diff --git a/app/jobs/action_mailbox/routing_job.rb b/app/jobs/action_mailbox/routing_job.rb index a2618bb8aa..af4aa9f8fa 100644 --- a/app/jobs/action_mailbox/routing_job.rb +++ b/app/jobs/action_mailbox/routing_job.rb @@ -2,6 +2,6 @@ class ActionMailbox::RoutingJob < ActiveJob::Base queue_as :action_mailbox_routing def perform(inbound_email) - ApplicationMailbox.route inbound_email + inbound_email.route end end diff --git a/app/models/action_mailbox/inbound_email/routable.rb b/app/models/action_mailbox/inbound_email/routable.rb index 1928f9e387..48b357af45 100644 --- a/app/models/action_mailbox/inbound_email/routable.rb +++ b/app/models/action_mailbox/inbound_email/routable.rb @@ -8,4 +8,8 @@ module ActionMailbox::InboundEmail::Routable def route_later ActionMailbox::RoutingJob.perform_later self end + + def route + ApplicationMailbox.route self + end end diff --git a/lib/action_mailbox/test_helper.rb b/lib/action_mailbox/test_helper.rb index 65a15a1281..4694f61b8a 100644 --- a/lib/action_mailbox/test_helper.rb +++ b/lib/action_mailbox/test_helper.rb @@ -6,7 +6,7 @@ module ActionMailbox # referenced with +fixture_name+ located in +test/fixtures/files/fixture_name+. def create_inbound_email_from_fixture(fixture_name, status: :processing) create_inbound_email file_fixture(fixture_name), filename: fixture_name, status: status - end + end def create_inbound_email_from_mail(status: :processing, **mail_options) raw_email = Tempfile.new.tap { |raw_email| raw_email.write Mail.new(mail_options).to_s } @@ -18,5 +18,9 @@ module ActionMailbox ActionDispatch::Http::UploadedFile.new(tempfile: io, filename: filename, type: 'message/rfc822'), status: status end + + def receive_inbound_email_from_mail(**kwargs) + create_inbound_email_from_mail(**kwargs).tap(&:route) + end end end