aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unit/mailbox/callbacks_test.rb22
1 files changed, 22 insertions, 0 deletions
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