From 01f9fd323222b7b4f2e2925ecbd304491f9e81a9 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 12 Oct 2017 17:38:20 +1100 Subject: [PATCH] Rename webhook handler status mappings --- lib/stripe/webhook_handler.rb | 6 +++--- spec/controllers/stripe/webhooks_controller_spec.rb | 4 ++-- spec/lib/stripe/webhook_handler_spec.rb | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/stripe/webhook_handler.rb b/lib/stripe/webhook_handler.rb index da5482d723..875dd9e52b 100644 --- a/lib/stripe/webhook_handler.rb +++ b/lib/stripe/webhook_handler.rb @@ -5,7 +5,7 @@ module Stripe end def handle - return :failure unless known_event? + return :unknown unless known_event? send(event_mappings[@event.type]) end @@ -22,9 +22,9 @@ module Stripe end def deauthorize - return :silent_fail unless @event.respond_to?(:account) + return :ignored unless @event.respond_to?(:account) destroyed = destroy_stripe_accounts_linked_to(@event.account) - destroyed.any? ? :success : :silent_fail + destroyed.any? ? :success : :ignored end def destroy_stripe_accounts_linked_to(account) diff --git a/spec/controllers/stripe/webhooks_controller_spec.rb b/spec/controllers/stripe/webhooks_controller_spec.rb index d413bbb08b..8c0bda6c87 100644 --- a/spec/controllers/stripe/webhooks_controller_spec.rb +++ b/spec/controllers/stripe/webhooks_controller_spec.rb @@ -53,8 +53,8 @@ describe Stripe::WebhooksController do end end - context "when the result returned by the handler is :failure" do - before { allow(handler).to receive(:handle) { :failure } } + context "when the result returned by the handler is :unknown" do + before { allow(handler).to receive(:handle) { :unknown } } it "responds with 202" do post 'create', params diff --git a/spec/lib/stripe/webhook_handler_spec.rb b/spec/lib/stripe/webhook_handler_spec.rb index 1795430b9f..e83cf01805 100644 --- a/spec/lib/stripe/webhook_handler_spec.rb +++ b/spec/lib/stripe/webhook_handler_spec.rb @@ -45,18 +45,18 @@ module Stripe allow(handler).to receive(:event_mappings) { { 'some.other.event' => :some_method } } end - it "does not call the handler method, and returns :failure" do + it "does not call the handler method, and returns :unknown" do expect(handler).to_not receive(:some_method) - expect(handler.handle).to be :failure + expect(handler.handle).to be :unknown end end end describe "deauthorize" do context "when the event has no 'account' attribute" do - it "does destroy stripe accounts, returns :silent_fail" do + it "does destroy stripe accounts, returns :ignored" do expect(handler).to_not receive(:destroy_stripe_accounts_linked_to) - expect(handler.send(:deauthorize)).to be :silent_fail + expect(handler.send(:deauthorize)).to be :ignored end end @@ -78,7 +78,7 @@ module Stripe allow(handler).to receive(:destroy_stripe_accounts_linked_to).with('some.account') { [] } end - it { expect(handler.send(:deauthorize)).to be :silent_fail } + it { expect(handler.send(:deauthorize)).to be :ignored } end end end