Rename stripe controller action from 'deauthorize' to 'webhook'

This commit is contained in:
Rob Harrington
2017-10-11 17:11:02 +11:00
parent 23d2b3a664
commit c54119f482
3 changed files with 6 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
class StripeController < BaseController
def deauthorize
def webhook
# TODO is there a sensible way to confirm this webhook call is actually from Stripe?
event = Stripe::Event.construct_from(params)
return render nothing: true, status: 204 unless event.type == "account.application.deauthorized"

View File

@@ -54,7 +54,7 @@ Openfoodnetwork::Application.routes.draw do
end
resource :stripe, only: [] do
post :deauthorize
post :webhook
end
namespace :admin do

View File

@@ -1,7 +1,7 @@
require 'spec_helper'
describe StripeController do
describe "#deauthorize" do
describe "#webhook" do
let!(:stripe_account) { create(:stripe_account, stripe_user_id: "webhook_id") }
let(:params) do
{
@@ -15,7 +15,7 @@ describe StripeController do
end
it "deletes Stripe accounts in response to a webhook" do
post 'deauthorize', params
post 'webhook', params
expect(response.status).to eq 200
expect(response.body).to eq "Account webhook_id deauthorized"
expect(StripeAccount.all).not_to include stripe_account
@@ -27,7 +27,7 @@ describe StripeController do
end
it "does nothing" do
post 'deauthorize', params
post 'webhook', params
expect(response.status).to eq 204
expect(StripeAccount.all).to include stripe_account
end
@@ -39,7 +39,7 @@ describe StripeController do
end
it "does nothing" do
post 'deauthorize', params
post 'webhook', params
expect(response.status).to eq 204
expect(StripeAccount.all).to include stripe_account
end