diff options
author | George Claghorn <george@basecamp.com> | 2018-10-17 00:12:03 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-10-17 00:12:03 -0400 |
commit | 3984460424b678d844009319598e2b41c350ca3c (patch) | |
tree | 96a5bd26ae3191dd6a2837d4c7e4bb1e8c55f9bc /test/controllers/ingresses | |
parent | 6b7eac5c51cbef4acd1ab7f48884e7b614f71678 (diff) | |
download | rails-3984460424b678d844009319598e2b41c350ca3c.tar.gz rails-3984460424b678d844009319598e2b41c350ca3c.tar.bz2 rails-3984460424b678d844009319598e2b41c350ca3c.zip |
Add Mandrill support
Diffstat (limited to 'test/controllers/ingresses')
-rw-r--r-- | test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb b/test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb new file mode 100644 index 0000000000..abef6baa4f --- /dev/null +++ b/test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb @@ -0,0 +1,31 @@ +require "test_helper" + +ActionMailbox::Ingresses::Mandrill::InboundEmailsController::Authenticator.key = "1l9Qf7lutEf7h73VXfBwhw" + +class ActionMailbox::Ingresses::Mandrill::InboundEmailsControllerTest < ActionDispatch::IntegrationTest + setup do + @events = JSON.generate([{ event: "inbound", msg: { raw_msg: file_fixture("../files/welcome.eml").read } }]) + end + + test "receiving an inbound email from Mandrill" do + assert_difference -> { ActionMailbox::InboundEmail.count }, +1 do + post rails_mandrill_inbound_emails_url, + headers: { "X-Mandrill-Signature" => "gldscd2tAb/G+DmpiLcwukkLrC4=" }, params: { mandrill_events: @events } + end + + assert_response :ok + + inbound_email = ActionMailbox::InboundEmail.last + assert_equal file_fixture("../files/welcome.eml").read, inbound_email.raw_email.download + assert_equal "0CB459E0-0336-41DA-BC88-E6E28C697DDB@37signals.com", inbound_email.message_id + end + + test "rejecting a forged inbound email from Mandrill" do + assert_no_difference -> { ActionMailbox::InboundEmail.count } do + post rails_mandrill_inbound_emails_url, + headers: { "X-Mandrill-Signature" => "forged" }, params: { mandrill_events: @events } + end + + assert_response :unauthorized + end +end |