Rename webhook handler status mappings

This commit is contained in:
Rob Harrington
2017-10-12 17:38:20 +11:00
parent 99cac20725
commit 01f9fd3232
3 changed files with 10 additions and 10 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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