aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/mailbox
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-18 16:42:27 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-18 16:42:27 -0700
commit5f73fa84fff1b92665de7779c4cb824277930ca8 (patch)
tree7a6c408ae401bdcb3214e649c9d9e65a58865b6a /test/unit/mailbox
parent1ac1459b0f1c257bef410f166c2ffc90bf36deca (diff)
downloadrails-5f73fa84fff1b92665de7779c4cb824277930ca8.tar.gz
rails-5f73fa84fff1b92665de7779c4cb824277930ca8.tar.bz2
rails-5f73fa84fff1b92665de7779c4cb824277930ca8.zip
Extract mailbox test suites into feature-specific slices
Diffstat (limited to 'test/unit/mailbox')
-rw-r--r--test/unit/mailbox/state_test.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/unit/mailbox/state_test.rb b/test/unit/mailbox/state_test.rb
new file mode 100644
index 0000000000..41fbafbd67
--- /dev/null
+++ b/test/unit/mailbox/state_test.rb
@@ -0,0 +1,34 @@
+require_relative '../../test_helper'
+
+class SuccessfulMailbox < ActionMailroom::Mailbox
+ def process
+ $processed = mail.subject
+ end
+end
+
+class UnsuccessfulMailbox < ActionMailroom::Mailbox
+ rescue_from(RuntimeError) { $processed = :failure }
+
+ def process
+ raise "No way!"
+ end
+end
+
+class ActionMailroom::Mailbox::StateTest < ActiveSupport::TestCase
+ setup do
+ $processed = false
+ @inbound_email = create_inbound_email("welcome.eml")
+ end
+
+ test "successful mailbox processing leaves inbound email in delivered state" do
+ SuccessfulMailbox.receive @inbound_email
+ assert @inbound_email.delivered?
+ assert_equal "Discussion: Let's debate these attachments", $processed
+ end
+
+ test "unsuccessful mailbox processing leaves inbound email in failed state" do
+ UnsuccessfulMailbox.receive @inbound_email
+ assert @inbound_email.failed?
+ assert_equal :failure, $processed
+ end
+end