diff options
-rw-r--r-- | lib/action_mailroom/test_helper.rb | 4 | ||||
-rw-r--r-- | test/unit/mailbox/state_test.rb | 5 | ||||
-rw-r--r-- | test/unit/router_test.rb | 6 |
3 files changed, 7 insertions, 8 deletions
diff --git a/lib/action_mailroom/test_helper.rb b/lib/action_mailroom/test_helper.rb index 7f56831f36..bd9d57bd38 100644 --- a/lib/action_mailroom/test_helper.rb +++ b/lib/action_mailroom/test_helper.rb @@ -6,8 +6,8 @@ module ActionMailroom create_inbound_email file_fixture(fixture_name).open, filename: fixture_name, status: status end - def create_inbound_email_from_mail(status: :processing, &block) - create_inbound_email(StringIO.new(Mail.new { instance_eval(&block) }.to_s), status: status) + def create_inbound_email_from_mail(status: :processing, **mail_options) + create_inbound_email(StringIO.new(Mail.new(mail_options).to_s), status: status) end def create_inbound_email(io, filename: 'mail.eml', status: status) diff --git a/test/unit/mailbox/state_test.rb b/test/unit/mailbox/state_test.rb index d73ecaa1e2..de9da54d3f 100644 --- a/test/unit/mailbox/state_test.rb +++ b/test/unit/mailbox/state_test.rb @@ -17,13 +17,14 @@ end class ActionMailroom::Mailbox::StateTest < ActiveSupport::TestCase setup do $processed = false - @inbound_email = create_inbound_email_from_fixture("welcome.eml") + @inbound_email = create_inbound_email_from_mail \ + to: "replies@example.com", subject: "I was processed" 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 + assert_equal "I was processed", $processed end test "unsuccessful mailbox processing leaves inbound email in failed state" do diff --git a/test/unit/router_test.rb b/test/unit/router_test.rb index fa7ac2ba19..3ce669025e 100644 --- a/test/unit/router_test.rb +++ b/test/unit/router_test.rb @@ -15,10 +15,8 @@ module ActionMailroom end test "routed to mailbox" do - @router.route create_inbound_email_from_mail { - to "replies@example.com" - subject "This is a reply" - } + @router.route \ + create_inbound_email_from_mail(to: "replies@example.com", subject: "This is a reply") assert_equal "This is a reply", $processed end |