diff --git a/app/controllers/user/subscriptions_controller.rb b/app/controllers/user/subscriptions_controller.rb index 14f9678..e73e0ad 100644 --- a/app/controllers/user/subscriptions_controller.rb +++ b/app/controllers/user/subscriptions_controller.rb @@ -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 diff --git a/plugin.rb b/plugin.rb index 7be4536..07dac1d 100644 --- a/plugin.rb +++ b/plugin.rb @@ -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", diff --git a/spec/requests/user/subscriptions_controller_spec.rb b/spec/requests/user/subscriptions_controller_spec.rb index 9a09288..47aa5a8 100644 --- a/spec/requests/user/subscriptions_controller_spec.rb +++ b/spec/requests/user/subscriptions_controller_spec.rb @@ -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