From 1219b070d73d0e980d5ac58a5a583048976e5539 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 18 Sep 2018 16:11:03 -0700 Subject: Add test for unsupported content type --- test/fixtures/files/text.txt | 1 + test/unit/controller_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 test/fixtures/files/text.txt diff --git a/test/fixtures/files/text.txt b/test/fixtures/files/text.txt new file mode 100644 index 0000000000..84c3f1cf21 --- /dev/null +++ b/test/fixtures/files/text.txt @@ -0,0 +1 @@ +This Is Not An Email! diff --git a/test/unit/controller_test.rb b/test/unit/controller_test.rb index c9ba1ba45f..f2a49f415f 100644 --- a/test/unit/controller_test.rb +++ b/test/unit/controller_test.rb @@ -12,6 +12,14 @@ class ActionMailroom::InboundEmailsControllerTest < ActionDispatch::IntegrationT assert_equal file_fixture('../files/welcome.eml').read, inbound_email.raw_email.download end + test "rejecting a message of an unsupported type" do + assert_no_difference -> { ActionMailroom::InboundEmail.count } do + post rails_inbound_emails_url, params: { message: fixture_file_upload('files/text.txt', 'text/plain') } + end + + assert_response :unsupported_media_type + end + private def post_inbound_email(fixture_name) post rails_inbound_emails_url, params: { message: fixture_file_upload("files/#{fixture_name}", 'message/rfc822') } -- cgit v1.2.3