mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Rename webhook handler status mappings
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user