From a91dc46b32b3062d2c75c226c733b04da50d0bc8 Mon Sep 17 00:00:00 2001 From: George Claghorn <george@basecamp.com> Date: Wed, 3 Oct 2018 16:04:33 -0400 Subject: Skip after callbacks on terminate --- lib/action_mailbox/callbacks.rb | 2 +- test/unit/mailbox/callbacks_test.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/action_mailbox/callbacks.rb b/lib/action_mailbox/callbacks.rb index e8bf2ffd55..a5f7aa7e6f 100644 --- a/lib/action_mailbox/callbacks.rb +++ b/lib/action_mailbox/callbacks.rb @@ -17,7 +17,7 @@ module ActionMailbox end included do - define_callbacks :process, terminator: TERMINATOR + define_callbacks :process, terminator: TERMINATOR, skip_after_callbacks_if_terminated: true end module ClassMethods diff --git a/test/unit/mailbox/callbacks_test.rb b/test/unit/mailbox/callbacks_test.rb index fccd89b9df..617e8a89b1 100644 --- a/test/unit/mailbox/callbacks_test.rb +++ b/test/unit/mailbox/callbacks_test.rb @@ -20,8 +20,10 @@ class BouncingCallbackMailbox < ActionMailbox::Base before_processing { $before_processing << "Post-bounce" } + after_processing { $after_processing = true } + def process - $processed = mail.subject + $processed = true end end @@ -43,5 +45,6 @@ class ActionMailbox::Base::CallbacksTest < ActiveSupport::TestCase assert @inbound_email.bounced? assert_equal [ "Pre-bounce", "Bounce" ], $before_processing assert_not $processed + assert_not $after_processing end end -- cgit v1.2.3