aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-10-06 22:15:36 -0400
committerGeorge Claghorn <george@basecamp.com>2018-10-06 22:15:36 -0400
commit7b95ebc9e44b7dba1e4aa32b773a124f75de9474 (patch)
tree46bda2e17a446dbbbb626153622d9bbfe2d82f1f /test
parent015c33f4cd6758e2c7d43f82ff5da93bac5cf3e3 (diff)
downloadrails-7b95ebc9e44b7dba1e4aa32b773a124f75de9474.tar.gz
rails-7b95ebc9e44b7dba1e4aa32b773a124f75de9474.tar.bz2
rails-7b95ebc9e44b7dba1e4aa32b773a124f75de9474.zip
Terminate processing if inbound email is marked as delivered in callback
Diffstat (limited to 'test')
-rw-r--r--test/unit/mailbox/callbacks_test.rb25
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