From b9e220aa41674c974f5a1e8c4fe1684596cab740 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Wed, 3 Oct 2018 15:36:40 -0400 Subject: Terminate processing on bounce --- test/unit/mailbox/callbacks_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/unit/mailbox/callbacks_test.rb b/test/unit/mailbox/callbacks_test.rb index b6cfef9868..fccd89b9df 100644 --- a/test/unit/mailbox/callbacks_test.rb +++ b/test/unit/mailbox/callbacks_test.rb @@ -10,6 +10,21 @@ class CallbackMailbox < ActionMailbox::Base end end +class BouncingCallbackMailbox < ActionMailbox::Base + before_processing { $before_processing = [ "Pre-bounce" ] } + + before_processing do + bounce_with BounceMailer.bounce(to: mail.from) + $before_processing << "Bounce" + end + + before_processing { $before_processing << "Post-bounce" } + + def process + $processed = mail.subject + end +end + class ActionMailbox::Base::CallbacksTest < ActiveSupport::TestCase setup do $before_processing = $after_processing = $around_processing = $processed = false @@ -22,4 +37,11 @@ class ActionMailbox::Base::CallbacksTest < ActiveSupport::TestCase assert_equal "Ran that too!", $after_processing assert_equal "Ran that as well!", $around_processing end + + test "bouncing in a callback terminates processing" do + BouncingCallbackMailbox.receive @inbound_email + assert @inbound_email.bounced? + assert_equal [ "Pre-bounce", "Bounce" ], $before_processing + assert_not $processed + end end -- cgit v1.2.3