From 65a6d525c6ce36acefd4b1918bbc5f14132e7810 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 17 Sep 2018 22:32:05 -0700 Subject: Add basic, unauthenticated inbound emails controller --- test/unit/controller_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/unit/controller_test.rb (limited to 'test') diff --git a/test/unit/controller_test.rb b/test/unit/controller_test.rb new file mode 100644 index 0000000000..c9ba1ba45f --- /dev/null +++ b/test/unit/controller_test.rb @@ -0,0 +1,19 @@ +require_relative '../test_helper' + +class ActionMailroom::InboundEmailsControllerTest < ActionDispatch::IntegrationTest + test "receiving a valid RFC 822 message" do + assert_difference -> { ActionMailroom::InboundEmail.count }, +1 do + post_inbound_email "welcome.eml" + end + + assert_response :created + + inbound_email = ActionMailroom::InboundEmail.last + assert_equal file_fixture('../files/welcome.eml').read, inbound_email.raw_email.download + end + + private + def post_inbound_email(fixture_name) + post rails_inbound_emails_url, params: { message: fixture_file_upload("files/#{fixture_name}", 'message/rfc822') } + end +end -- cgit v1.2.3