diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-18 16:11:03 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-09-18 16:11:03 -0700 |
commit | 1219b070d73d0e980d5ac58a5a583048976e5539 (patch) | |
tree | f5e0ddfb04df117f10c2767094f2f6757a79c75f | |
parent | 31ff0f7b6cc4ec7bbc70a9472e01215cd9b046e8 (diff) | |
download | rails-1219b070d73d0e980d5ac58a5a583048976e5539.tar.gz rails-1219b070d73d0e980d5ac58a5a583048976e5539.tar.bz2 rails-1219b070d73d0e980d5ac58a5a583048976e5539.zip |
Add test for unsupported content type
-rw-r--r-- | test/fixtures/files/text.txt | 1 | ||||
-rw-r--r-- | test/unit/controller_test.rb | 8 |
2 files changed, 9 insertions, 0 deletions
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') } |