diff options
author | George Claghorn <george@basecamp.com> | 2018-11-09 13:45:51 -0500 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-11-09 13:45:51 -0500 |
commit | a4d429f4a7c417b719270e9164634c83ded3d0ec (patch) | |
tree | 8d8acfa67add80c7b5556e4cb249cdd371edd355 | |
parent | 5e1a67c67cbfdbec636b310793fe65be6e5bbb4b (diff) | |
download | rails-a4d429f4a7c417b719270e9164634c83ded3d0ec.tar.gz rails-a4d429f4a7c417b719270e9164634c83ded3d0ec.tar.bz2 rails-a4d429f4a7c417b719270e9164634c83ded3d0ec.zip |
Discard incineration jobs for missing inbound emails
-rw-r--r-- | app/jobs/action_mailbox/incineration_job.rb | 2 | ||||
-rw-r--r-- | test/jobs/incineration_job_test.rb | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/app/jobs/action_mailbox/incineration_job.rb b/app/jobs/action_mailbox/incineration_job.rb index f87c9d0cd9..81b381b0d0 100644 --- a/app/jobs/action_mailbox/incineration_job.rb +++ b/app/jobs/action_mailbox/incineration_job.rb @@ -1,6 +1,8 @@ class ActionMailbox::IncinerationJob < ActiveJob::Base queue_as :action_mailbox_incineration + discard_on ActiveRecord::RecordNotFound + def self.schedule(inbound_email) set(wait: ActionMailbox.incinerate_after).perform_later(inbound_email) end diff --git a/test/jobs/incineration_job_test.rb b/test/jobs/incineration_job_test.rb new file mode 100644 index 0000000000..a3907898ab --- /dev/null +++ b/test/jobs/incineration_job_test.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require "test_helper" + +class ActionMailbox::IncinerationJobTest < ActiveJob::TestCase + setup { @inbound_email = receive_inbound_email_from_fixture("welcome.eml") } + + test "ignoring a missing inbound email" do + @inbound_email.destroy! + + perform_enqueued_jobs do + assert_nothing_raised do + ActionMailbox::IncinerationJob.perform_later @inbound_email + end + end + end +end |