aboutsummaryrefslogtreecommitdiffstats
path: root/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-10-18 10:23:17 -0400
committerGeorge Claghorn <george@basecamp.com>2018-10-18 10:23:17 -0400
commitb3919d01554d31c5486d17332f4a4dde89a23239 (patch)
tree42a4bcacda5f7e88824487b269e2893a96422333 /test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
parent88227658217ee82af7516d6a8013a6c04f037073 (diff)
downloadrails-b3919d01554d31c5486d17332f4a4dde89a23239.tar.gz
rails-b3919d01554d31c5486d17332f4a4dde89a23239.tar.bz2
rails-b3919d01554d31c5486d17332f4a4dde89a23239.zip
Don't require Postfix to send form data
Diffstat (limited to 'test/controllers/ingresses/postfix/inbound_emails_controller_test.rb')
-rw-r--r--test/controllers/ingresses/postfix/inbound_emails_controller_test.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb b/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
index bade5215d6..3fa0854576 100644
--- a/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
+++ b/test/controllers/ingresses/postfix/inbound_emails_controller_test.rb
@@ -5,8 +5,8 @@ ActionMailbox::Ingresses::Postfix::InboundEmailsController.password = "tbsy84uSV
class ActionMailbox::Ingresses::Postfix::InboundEmailsControllerTest < ActionDispatch::IntegrationTest
test "receiving an inbound email from Postfix" do
assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do
- post rails_postfix_inbound_emails_url, headers: { authorization: credentials },
- params: { message: fixture_file_upload("files/welcome.eml", "message/rfc822") }
+ post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "message/rfc822" },
+ params: file_fixture("../files/welcome.eml").read
end
assert_response :no_content
@@ -18,12 +18,22 @@ class ActionMailbox::Ingresses::Postfix::InboundEmailsControllerTest < ActionDis
test "rejecting an unauthorized inbound email from Postfix" do
assert_no_difference -> { ActionMailbox::InboundEmail.count } do
- post rails_postfix_inbound_emails_url, params: { message: fixture_file_upload("files/welcome.eml", "message/rfc822") }
+ post rails_postfix_inbound_emails_url, headers: { "Content-Type" => "message/rfc822" },
+ params: file_fixture("../files/welcome.eml").read
end
assert_response :unauthorized
end
+ test "rejecting an inbound email of an unsupported media type from Postfix" do
+ assert_no_difference -> { ActionMailbox::InboundEmail.count } do
+ post rails_postfix_inbound_emails_url, headers: { "Authorization" => credentials, "Content-Type" => "text/plain" },
+ params: file_fixture("../files/welcome.eml").read
+ end
+
+ assert_response :unsupported_media_type
+ end
+
private
delegate :username, :password, to: ActionMailbox::Ingresses::Postfix::InboundEmailsController