diff options
Diffstat (limited to 'test/unit/mailbox')
-rw-r--r-- | test/unit/mailbox/callbacks_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/unit/mailbox/callbacks_test.rb b/test/unit/mailbox/callbacks_test.rb index 617e8a89b1..279bf7e574 100644 --- a/test/unit/mailbox/callbacks_test.rb +++ b/test/unit/mailbox/callbacks_test.rb @@ -27,6 +27,23 @@ class BouncingCallbackMailbox < ActionMailbox::Base end end +class DiscardingCallbackMailbox < ActionMailbox::Base + before_processing { $before_processing = [ "Pre-discard" ] } + + before_processing do + delivered! + $before_processing << "Discard" + end + + before_processing { $before_processing << "Post-discard" } + + after_processing { $after_processing = true } + + def process + $processed = true + end +end + class ActionMailbox::Base::CallbacksTest < ActiveSupport::TestCase setup do $before_processing = $after_processing = $around_processing = $processed = false @@ -47,4 +64,12 @@ class ActionMailbox::Base::CallbacksTest < ActiveSupport::TestCase assert_not $processed assert_not $after_processing end + + test "marking the inbound email as delivered in a callback terminates processing" do + DiscardingCallbackMailbox.receive @inbound_email + assert @inbound_email.delivered? + assert_equal [ "Pre-discard", "Discard" ], $before_processing + assert_not $processed + assert_not $after_processing + end end |