aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-18 16:42:38 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-18 16:42:38 -0700
commit0f140fe15852b829d22864a2f7664440204ac723 (patch)
tree588993cc03b29f98b643d92154b5417f5a53279e /test
parent5f73fa84fff1b92665de7779c4cb824277930ca8 (diff)
downloadrails-0f140fe15852b829d22864a2f7664440204ac723.tar.gz
rails-0f140fe15852b829d22864a2f7664440204ac723.tar.bz2
rails-0f140fe15852b829d22864a2f7664440204ac723.zip
Add callbacks
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
new file mode 100644
index 0000000000..ada6410876
--- /dev/null
+++ b/test/unit/mailbox/callbacks_test.rb
@@ -0,0 +1,25 @@
+require_relative '../../test_helper'
+
+class CallbackMailbox < ActionMailroom::Mailbox
+ before_processing { $before_processing = "Ran that!" }
+ after_processing { $after_processing = "Ran that too!" }
+ around_processing ->(r, block) { block.call; $around_processing = "Ran that as well!" }
+
+ def process
+ $processed = mail.subject
+ end
+end
+
+class ActionMailroom::Mailbox::CallbacksTest < ActiveSupport::TestCase
+ setup do
+ $before_processing = $after_processing = $around_processing = $processed = false
+ @inbound_email = create_inbound_email("welcome.eml")
+ end
+
+ test "all callback types" do
+ CallbackMailbox.receive @inbound_email
+ assert_equal "Ran that!", $before_processing
+ assert_equal "Ran that too!", $after_processing
+ assert_equal "Ran that as well!", $around_processing
+ end
+end