delete plans
This commit is contained in:
parent
1b232a1bd4
commit
d4afe93a5d
|
@ -24,5 +24,10 @@ module DiscoursePatrons
|
|||
|
||||
render json: plan
|
||||
end
|
||||
|
||||
def destroy
|
||||
plan = ::Stripe::Plan.delete(params[:id])
|
||||
render json: plan
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
actions: {
|
||||
deletePlan(plan) {}
|
||||
deletePlan(id) {
|
||||
return ajax(`/patrons/admin/plans/${id}`, { method: "delete" });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<td>{{plan.interval}}</td>
|
||||
<td>{{plan.amount}}</td>
|
||||
<td>
|
||||
{{d-button action=(action "deletePlan" plan) icon="trash" class="btn-danger btn no-text btn-icon"}}
|
||||
{{d-button action=(action "deletePlan" plan.id) icon="trash-alt" class="btn-danger btn no-text btn-icon"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
DiscoursePatrons::Engine.routes.draw do
|
||||
get '/admin' => 'admin#index'
|
||||
get '/admin/subscriptions' => 'subscriptions#index'
|
||||
get '/admin/plans' => 'plans#index'
|
||||
get '/admin/plans/:plan_id' => 'plans#show'
|
||||
post '/admin/plans' => 'plans#create'
|
||||
scope 'admin' do
|
||||
get '/' => 'admin#index'
|
||||
|
||||
resources :subscriptions, only: [:index]
|
||||
resources :plans
|
||||
end
|
||||
|
||||
get '/' => 'patrons#index'
|
||||
get '/:pid' => 'patrons#show'
|
||||
|
||||
resources :patrons, only: [:index, :create]
|
||||
end
|
||||
|
|
|
@ -36,5 +36,12 @@ module DiscoursePatrons
|
|||
post "/patrons/admin/plans.json", params: { amount: '102' }
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete" do
|
||||
it "deletes a plan" do
|
||||
::Stripe::Plan.expects(:delete).with('plan_12345')
|
||||
delete "/patrons/admin/plans/plan_12345.json"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue