fix null delete subscription error
This commit is contained in:
parent
533dc943d3
commit
e4093e5a69
|
@ -35,10 +35,11 @@ module DiscoursePatrons
|
||||||
|
|
||||||
if subscription[:customer] == customer.customer_id
|
if subscription[:customer] == customer.customer_id
|
||||||
deleted = ::Stripe::Subscription.delete(params[:id])
|
deleted = ::Stripe::Subscription.delete(params[:id])
|
||||||
|
render_json_dump deleted
|
||||||
|
else
|
||||||
|
render_json_error "Customer ID not found"
|
||||||
end
|
end
|
||||||
|
|
||||||
render_json_dump deleted
|
|
||||||
|
|
||||||
else
|
else
|
||||||
render_json_error "Customer ID not found"
|
render_json_error "Customer ID not found"
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# name: discourse-patrons
|
# name: discourse-patrons
|
||||||
# about: Integrates Stripe into Discourse to allow visitors to make payments and Subscribe
|
# 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
|
# url: https://github.com/rimian/discourse-patrons
|
||||||
# authors: Rimian Perkins
|
# authors: Rimian Perkins
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ end
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
::Stripe.api_version = "2019-11-05"
|
::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",
|
"../lib/discourse_patrons/engine",
|
||||||
|
|
|
@ -56,6 +56,7 @@ module DiscoursePatrons
|
||||||
it "deletes a subscription" do
|
it "deletes a subscription" do
|
||||||
::Stripe::Subscription.expects(:delete).never
|
::Stripe::Subscription.expects(:delete).never
|
||||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||||
|
expect(response.status).to eq 422
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,12 +67,14 @@ module DiscoursePatrons
|
||||||
::Stripe::Subscription.expects(:retrieve).with('sub_12345').returns(customer: 'other')
|
::Stripe::Subscription.expects(:retrieve).with('sub_12345').returns(customer: 'other')
|
||||||
::Stripe::Subscription.expects(:delete).never
|
::Stripe::Subscription.expects(:delete).never
|
||||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||||
|
expect(response.status).to eq 422
|
||||||
end
|
end
|
||||||
|
|
||||||
it "deletes a subscription" do
|
it "deletes a subscription" do
|
||||||
::Stripe::Subscription.expects(:retrieve).with('sub_12345').returns(customer: 'cus_tmp76543g')
|
::Stripe::Subscription.expects(:retrieve).with('sub_12345').returns(customer: 'cus_tmp76543g')
|
||||||
::Stripe::Subscription.expects(:delete).with('sub_12345')
|
::Stripe::Subscription.expects(:delete).with('sub_12345')
|
||||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||||
|
expect(response.status).to eq 200
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue