From 5f73fa84fff1b92665de7779c4cb824277930ca8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 18 Sep 2018 16:42:27 -0700 Subject: Extract mailbox test suites into feature-specific slices --- test/unit/mailbox/state_test.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/unit/mailbox/state_test.rb (limited to 'test/unit/mailbox') 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 -- cgit v1.2.3