fix null delete subscription error

This commit is contained in:
Rimian Perkins 2019-11-14 12:07:24 +11:00
parent 533dc943d3
commit e4093e5a69
3 changed files with 8 additions and 4 deletions

View File

@ -35,10 +35,11 @@ module DiscoursePatrons
if subscription[:customer] == customer.customer_id
deleted = ::Stripe::Subscription.delete(params[:id])
render_json_dump deleted
else
render_json_error "Customer ID not found"
end
render_json_dump deleted
else
render_json_error "Customer ID not found"
end

View File

@ -2,7 +2,7 @@
# name: discourse-patrons
# about: Integrates Stripe into Discourse to allow visitors to make payments and Subscribe
# version: 2.2.0
# version: 2.2.1
# url: https://github.com/rimian/discourse-patrons
# authors: Rimian Perkins
@ -40,7 +40,7 @@ end
after_initialize do
::Stripe.api_version = "2019-11-05"
::Stripe.set_app_info('Discourse Patrons', version: '2.2.0', url: 'https://github.com/rimian/discourse-patrons')
::Stripe.set_app_info('Discourse Patrons', version: '2.2.1', url: 'https://github.com/rimian/discourse-patrons')
[
"../lib/discourse_patrons/engine",

View File

@ -56,6 +56,7 @@ module DiscoursePatrons
it "deletes a subscription" do
::Stripe::Subscription.expects(:delete).never
delete "/patrons/user/subscriptions/sub_12345.json"
expect(response.status).to eq 422
end
end
@ -66,12 +67,14 @@ module DiscoursePatrons
::Stripe::Subscription.expects(:retrieve).with('sub_12345').returns(customer: 'other')
::Stripe::Subscription.expects(:delete).never
delete "/patrons/user/subscriptions/sub_12345.json"
expect(response.status).to eq 422
end
it "deletes a subscription" do
::Stripe::Subscription.expects(:retrieve).with('sub_12345').returns(customer: 'cus_tmp76543g')
::Stripe::Subscription.expects(:delete).with('sub_12345')
delete "/patrons/user/subscriptions/sub_12345.json"
expect(response.status).to eq 200
end
end
end