diff options
Diffstat (limited to 'test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb')
-rw-r--r-- | test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb | 28 |
1 files changed, 28 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 index abef6baa4f..1658d85104 100644 --- a/test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb +++ b/test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb @@ -28,4 +28,32 @@ class ActionMailbox::Ingresses::Mandrill::InboundEmailsControllerTest < ActionDi assert_response :unauthorized end + + test "raising when Mandrill API key is nil" do + switch_key_to nil do + assert_raises ArgumentError do + post rails_mandrill_inbound_emails_url, + headers: { "X-Mandrill-Signature" => "gldscd2tAb/G+DmpiLcwukkLrC4=" }, params: { mandrill_events: @events } + end + end + end + + test "raising when Mandrill API key is blank" do + switch_key_to "" do + assert_raises ArgumentError do + post rails_mandrill_inbound_emails_url, + headers: { "X-Mandrill-Signature" => "gldscd2tAb/G+DmpiLcwukkLrC4=" }, params: { mandrill_events: @events } + end + end + end + + private + delegate :key, :key=, to: ActionMailbox::Ingresses::Mandrill::InboundEmailsController::Authenticator + + def switch_key_to(new_key) + previous_key, self.key = key, new_key + yield + ensure + self.key = previous_key + end end |