fix null delete subscription error
This commit is contained in:
parent
533dc943d3
commit
e4093e5a69
|
@ -35,9 +35,10 @@ module DiscoursePatrons
|
|||
|
||||
if subscription[:customer] == customer.customer_id
|
||||
deleted = ::Stripe::Subscription.delete(params[:id])
|
||||
end
|
||||
|
||||
render_json_dump deleted
|
||||
else
|
||||
render_json_error "Customer ID not found"
|
||||
end
|
||||
|
||||
else
|
||||
render_json_error "Customer ID not found"
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue