mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-03-06 09:39:51 +00:00
fix paths in request specs
This commit is contained in:
parent
949e32e4fb
commit
a95c119bcf
@ -13,11 +13,11 @@ module DiscoursePatrons
|
||||
describe "index" do
|
||||
it "does not get the plans" do
|
||||
::Stripe::Plan.expects(:list).never
|
||||
get "/patrons/admin/plans.json"
|
||||
get "/s/admin/plans.json"
|
||||
end
|
||||
|
||||
it "not ok" do
|
||||
get "/patrons/admin/plans.json"
|
||||
get "/s/admin/plans.json"
|
||||
expect(response.status).to eq 403
|
||||
end
|
||||
end
|
||||
@ -25,11 +25,11 @@ module DiscoursePatrons
|
||||
describe "create" do
|
||||
it "does not create a plan" do
|
||||
::Stripe::Plan.expects(:create).never
|
||||
post "/patrons/admin/plans.json", params: { name: 'Rick Astley', amount: 1, interval: 'week' }
|
||||
post "/s/admin/plans.json", params: { name: 'Rick Astley', amount: 1, interval: 'week' }
|
||||
end
|
||||
|
||||
it "is not ok" do
|
||||
post "/patrons/admin/plans.json", params: { name: 'Rick Astley', amount: 1, interval: 'week' }
|
||||
post "/s/admin/plans.json", params: { name: 'Rick Astley', amount: 1, interval: 'week' }
|
||||
expect(response.status).to eq 403
|
||||
end
|
||||
end
|
||||
@ -37,11 +37,11 @@ module DiscoursePatrons
|
||||
describe "show" do
|
||||
it "does not show the plan" do
|
||||
::Stripe::Plan.expects(:retrieve).never
|
||||
get "/patrons/admin/plans/plan_12345.json"
|
||||
get "/s/admin/plans/plan_12345.json"
|
||||
end
|
||||
|
||||
it "is not ok" do
|
||||
get "/patrons/admin/plans/plan_12345.json"
|
||||
get "/s/admin/plans/plan_12345.json"
|
||||
expect(response.status).to eq 403
|
||||
end
|
||||
end
|
||||
@ -49,11 +49,11 @@ module DiscoursePatrons
|
||||
describe "update" do
|
||||
it "does not update a plan" do
|
||||
::Stripe::Plan.expects(:update).never
|
||||
delete "/patrons/admin/plans/plan_12345.json"
|
||||
delete "/s/admin/plans/plan_12345.json"
|
||||
end
|
||||
|
||||
it "is not ok" do
|
||||
delete "/patrons/admin/plans/plan_12345.json"
|
||||
delete "/s/admin/plans/plan_12345.json"
|
||||
expect(response.status).to eq 403
|
||||
end
|
||||
end
|
||||
@ -61,11 +61,11 @@ module DiscoursePatrons
|
||||
describe "delete" do
|
||||
it "does not delete a plan" do
|
||||
::Stripe::Plan.expects(:delete).never
|
||||
patch "/patrons/admin/plans/plan_12345.json"
|
||||
patch "/s/admin/plans/plan_12345.json"
|
||||
end
|
||||
|
||||
it "is not ok" do
|
||||
patch "/patrons/admin/plans/plan_12345.json"
|
||||
patch "/s/admin/plans/plan_12345.json"
|
||||
expect(response.status).to eq 403
|
||||
end
|
||||
end
|
||||
@ -79,25 +79,25 @@ module DiscoursePatrons
|
||||
describe "index" do
|
||||
it "lists the plans" do
|
||||
::Stripe::Plan.expects(:list).with(nil)
|
||||
get "/patrons/admin/plans.json"
|
||||
get "/s/admin/plans.json"
|
||||
end
|
||||
|
||||
it "lists the plans for the product" do
|
||||
::Stripe::Plan.expects(:list).with(product: 'prod_id123')
|
||||
get "/patrons/admin/plans.json", params: { product_id: 'prod_id123' }
|
||||
get "/s/admin/plans.json", params: { product_id: 'prod_id123' }
|
||||
end
|
||||
end
|
||||
|
||||
describe "show" do
|
||||
it "shows a plan" do
|
||||
::Stripe::Plan.expects(:retrieve).with('plan_12345').returns(currency: 'aud')
|
||||
get "/patrons/admin/plans/plan_12345.json"
|
||||
get "/s/admin/plans/plan_12345.json"
|
||||
expect(response.status).to eq 200
|
||||
end
|
||||
|
||||
it "upcases the currency" do
|
||||
::Stripe::Plan.expects(:retrieve).with('plan_12345').returns(currency: 'aud')
|
||||
get "/patrons/admin/plans/plan_12345.json"
|
||||
get "/s/admin/plans/plan_12345.json"
|
||||
expect(response.body).to eq '{"currency":"AUD"}'
|
||||
end
|
||||
end
|
||||
@ -105,56 +105,56 @@ module DiscoursePatrons
|
||||
describe "create" do
|
||||
it "creates a plan with a nickname" do
|
||||
::Stripe::Plan.expects(:create).with(has_entry(:nickname, 'Veg'))
|
||||
post "/patrons/admin/plans.json", params: { nickname: 'Veg', metadata: { group_name: '' } }
|
||||
post "/s/admin/plans.json", params: { nickname: 'Veg', metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it "creates a plan with a currency" do
|
||||
::Stripe::Plan.expects(:create).with(has_entry(:currency, 'AUD'))
|
||||
post "/patrons/admin/plans.json", params: { currency: 'AUD', metadata: { group_name: '' } }
|
||||
post "/s/admin/plans.json", params: { currency: 'AUD', metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it "creates a plan with an interval" do
|
||||
::Stripe::Plan.expects(:create).with(has_entry(:interval, 'week'))
|
||||
post "/patrons/admin/plans.json", params: { interval: 'week', metadata: { group_name: '' } }
|
||||
post "/s/admin/plans.json", params: { interval: 'week', metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it "creates a plan with an amount" do
|
||||
::Stripe::Plan.expects(:create).with(has_entry(:amount, '102'))
|
||||
post "/patrons/admin/plans.json", params: { amount: '102', metadata: { group_name: '' } }
|
||||
post "/s/admin/plans.json", params: { amount: '102', metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it "creates a plan with a trial period" do
|
||||
::Stripe::Plan.expects(:create).with(has_entry(:trial_period_days, '14'))
|
||||
post "/patrons/admin/plans.json", params: { trial_period_days: '14', metadata: { group_name: '' } }
|
||||
post "/s/admin/plans.json", params: { trial_period_days: '14', metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it "creates a plan with a product" do
|
||||
::Stripe::Plan.expects(:create).with(has_entry(product: 'prod_walterwhite'))
|
||||
post "/patrons/admin/plans.json", params: { product: 'prod_walterwhite', metadata: { group_name: '' } }
|
||||
post "/s/admin/plans.json", params: { product: 'prod_walterwhite', metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it "creates a plan with an active status" do
|
||||
::Stripe::Plan.expects(:create).with(has_entry(:active, 'false'))
|
||||
post "/patrons/admin/plans.json", params: { active: 'false', metadata: { group_name: '' } }
|
||||
post "/s/admin/plans.json", params: { active: 'false', metadata: { group_name: '' } }
|
||||
end
|
||||
|
||||
it 'has a metadata' do
|
||||
::Stripe::Plan.expects(:create).with(has_entry(metadata: { group_name: 'discourse-user-group-name' }))
|
||||
post "/patrons/admin/plans.json", params: { metadata: { group_name: 'discourse-user-group-name' } }
|
||||
post "/s/admin/plans.json", params: { metadata: { group_name: 'discourse-user-group-name' } }
|
||||
end
|
||||
end
|
||||
|
||||
describe "update" do
|
||||
it "updates a plan" do
|
||||
::Stripe::Plan.expects(:update)
|
||||
patch "/patrons/admin/plans/plan_12345.json", params: { metadata: { group_name: 'discourse-user-group-name' } }
|
||||
patch "/s/admin/plans/plan_12345.json", params: { metadata: { group_name: 'discourse-user-group-name' } }
|
||||
end
|
||||
end
|
||||
|
||||
describe "delete" do
|
||||
it "deletes a plan" do
|
||||
::Stripe::Plan.expects(:delete).with('plan_12345')
|
||||
delete "/patrons/admin/plans/plan_12345.json"
|
||||
delete "/s/admin/plans/plan_12345.json"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -12,31 +12,31 @@ module DiscoursePatrons
|
||||
context 'unauthenticated' do
|
||||
it "does not list the products" do
|
||||
::Stripe::Product.expects(:list).never
|
||||
get "/patrons/admin/products.json"
|
||||
get "/s/admin/products.json"
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it "does not create the product" do
|
||||
::Stripe::Product.expects(:create).never
|
||||
post "/patrons/admin/products.json"
|
||||
post "/s/admin/products.json"
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it "does not show the product" do
|
||||
::Stripe::Product.expects(:retrieve).never
|
||||
get "/patrons/admin/products/prod_qwerty123.json"
|
||||
get "/s/admin/products/prod_qwerty123.json"
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it "does not update the product" do
|
||||
::Stripe::Product.expects(:update).never
|
||||
put "/patrons/admin/products/prod_qwerty123.json"
|
||||
put "/s/admin/products/prod_qwerty123.json"
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it "does not delete the product" do
|
||||
::Stripe::Product.expects(:delete).never
|
||||
delete "/patrons/admin/products/u2.json"
|
||||
delete "/s/admin/products/u2.json"
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
end
|
||||
@ -49,60 +49,60 @@ module DiscoursePatrons
|
||||
describe 'index' do
|
||||
it "gets the empty products" do
|
||||
::Stripe::Product.expects(:list)
|
||||
get "/patrons/admin/products.json"
|
||||
get "/s/admin/products.json"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'create' do
|
||||
it 'is of product type service' do
|
||||
::Stripe::Product.expects(:create).with(has_entry(:type, 'service'))
|
||||
post "/patrons/admin/products.json", params: {}
|
||||
post "/s/admin/products.json", params: {}
|
||||
end
|
||||
|
||||
it 'has a name' do
|
||||
::Stripe::Product.expects(:create).with(has_entry(:name, 'Jesse Pinkman'))
|
||||
post "/patrons/admin/products.json", params: { name: 'Jesse Pinkman' }
|
||||
post "/s/admin/products.json", params: { name: 'Jesse Pinkman' }
|
||||
end
|
||||
|
||||
it 'has an active attribute' do
|
||||
::Stripe::Product.expects(:create).with(has_entry(active: 'false'))
|
||||
post "/patrons/admin/products.json", params: { active: 'false' }
|
||||
post "/s/admin/products.json", params: { active: 'false' }
|
||||
end
|
||||
|
||||
it 'has a statement descriptor' do
|
||||
::Stripe::Product.expects(:create).with(has_entry(statement_descriptor: 'Blessed are the cheesemakers'))
|
||||
post "/patrons/admin/products.json", params: { statement_descriptor: 'Blessed are the cheesemakers' }
|
||||
post "/s/admin/products.json", params: { statement_descriptor: 'Blessed are the cheesemakers' }
|
||||
end
|
||||
|
||||
it 'has no statement descriptor if empty' do
|
||||
::Stripe::Product.expects(:create).with(has_key(:statement_descriptor)).never
|
||||
post "/patrons/admin/products.json", params: { statement_descriptor: '' }
|
||||
post "/s/admin/products.json", params: { statement_descriptor: '' }
|
||||
end
|
||||
|
||||
it 'has a description' do
|
||||
::Stripe::Product.expects(:create).with(has_entry(metadata: { description: 'Oi, I think he just said bless be all the bignoses!' }))
|
||||
post "/patrons/admin/products.json", params: { metadata: { description: 'Oi, I think he just said bless be all the bignoses!' } }
|
||||
post "/s/admin/products.json", params: { metadata: { description: 'Oi, I think he just said bless be all the bignoses!' } }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'show' do
|
||||
it 'retrieves the product' do
|
||||
::Stripe::Product.expects(:retrieve).with('prod_walterwhite')
|
||||
get "/patrons/admin/products/prod_walterwhite.json"
|
||||
get "/s/admin/products/prod_walterwhite.json"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'update' do
|
||||
it 'updates the product' do
|
||||
::Stripe::Product.expects(:update)
|
||||
patch "/patrons/admin/products/prod_walterwhite.json", params: {}
|
||||
patch "/s/admin/products/prod_walterwhite.json", params: {}
|
||||
end
|
||||
end
|
||||
|
||||
describe 'delete' do
|
||||
it 'deletes the product' do
|
||||
::Stripe::Product.expects(:delete).with('prod_walterwhite')
|
||||
delete "/patrons/admin/products/prod_walterwhite.json"
|
||||
delete "/s/admin/products/prod_walterwhite.json"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -11,13 +11,13 @@ module DiscoursePatrons
|
||||
context 'unauthenticated' do
|
||||
it "does nothing" do
|
||||
::Stripe::Subscription.expects(:list).never
|
||||
get "/patrons/admin/subscriptions.json"
|
||||
get "/s/admin/subscriptions.json"
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
||||
it "does not destroy a subscription" do
|
||||
::Stripe::Subscription.expects(:delete).never
|
||||
patch "/patrons/admin/subscriptions/sub_12345.json"
|
||||
patch "/s/admin/subscriptions/sub_12345.json"
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,7 +30,7 @@ module DiscoursePatrons
|
||||
describe "index" do
|
||||
it "gets the subscriptions and products" do
|
||||
::Stripe::Subscription.expects(:list).with(expand: ['data.plan.product'])
|
||||
get "/patrons/admin/subscriptions.json"
|
||||
get "/s/admin/subscriptions.json"
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
end
|
||||
@ -58,7 +58,7 @@ module DiscoursePatrons
|
||||
)
|
||||
|
||||
expect {
|
||||
delete "/patrons/admin/subscriptions/sub_12345.json"
|
||||
delete "/s/admin/subscriptions/sub_12345.json"
|
||||
}.to change { DiscoursePatrons::Customer.count }.by(-1)
|
||||
end
|
||||
|
||||
@ -72,7 +72,7 @@ module DiscoursePatrons
|
||||
)
|
||||
|
||||
expect {
|
||||
delete "/patrons/admin/subscriptions/sub_12345.json"
|
||||
delete "/s/admin/subscriptions/sub_12345.json"
|
||||
}.to change { user.groups.count }.by(-1)
|
||||
end
|
||||
|
||||
@ -86,7 +86,7 @@ module DiscoursePatrons
|
||||
)
|
||||
|
||||
expect {
|
||||
delete "/patrons/admin/subscriptions/sub_12345.json"
|
||||
delete "/s/admin/subscriptions/sub_12345.json"
|
||||
}.not_to change { user.groups.count }
|
||||
end
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ module DiscoursePatrons
|
||||
end
|
||||
|
||||
it "is ok" do
|
||||
get "/patrons/admin.json"
|
||||
get "/s/admin.json"
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
end
|
||||
|
@ -18,14 +18,14 @@ module DiscoursePatrons
|
||||
source: 'tok_interesting'
|
||||
)
|
||||
|
||||
post "/patrons/customers.json", params: { source: 'tok_interesting' }
|
||||
post "/s/customers.json", params: { source: 'tok_interesting' }
|
||||
end
|
||||
|
||||
it "saves the customer" do
|
||||
::Stripe::Customer.expects(:create).returns(id: 'cus_id23456')
|
||||
|
||||
expect {
|
||||
post "/patrons/customers.json", params: { source: 'tok_interesting' }
|
||||
post "/s/customers.json", params: { source: 'tok_interesting' }
|
||||
}.to change { DiscoursePatrons::Customer.count }
|
||||
end
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ module DiscoursePatrons
|
||||
describe "not authenticated" do
|
||||
it "does not list the invoices" do
|
||||
::Stripe::Invoice.expects(:list).never
|
||||
get "/patrons/invoices.json"
|
||||
get "/s/invoices.json"
|
||||
expect(response.status).to eq 403
|
||||
end
|
||||
end
|
||||
@ -24,7 +24,7 @@ module DiscoursePatrons
|
||||
describe "other user invoices" do
|
||||
it "does not list the invoices" do
|
||||
::Stripe::Invoice.expects(:list).never
|
||||
get "/patrons/invoices.json", params: { user_id: 999999 }
|
||||
get "/s/invoices.json", params: { user_id: 999999 }
|
||||
end
|
||||
end
|
||||
|
||||
@ -32,7 +32,7 @@ module DiscoursePatrons
|
||||
context "stripe customer does not exist" do
|
||||
it "lists empty" do
|
||||
::Stripe::Invoice.expects(:list).never
|
||||
get "/patrons/invoices.json", params: { user_id: user.id }
|
||||
get "/s/invoices.json", params: { user_id: user.id }
|
||||
expect(response.body).to eq "[]"
|
||||
end
|
||||
end
|
||||
@ -44,7 +44,7 @@ module DiscoursePatrons
|
||||
|
||||
it "lists the invoices" do
|
||||
::Stripe::Invoice.expects(:list).with(customer: 'cus_id4567')
|
||||
get "/patrons/invoices.json", params: { user_id: user.id }
|
||||
get "/s/invoices.json", params: { user_id: user.id }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,12 +7,12 @@ module DiscoursePatrons
|
||||
describe "index" do
|
||||
it "lists the active plans" do
|
||||
::Stripe::Plan.expects(:list).with(active: true)
|
||||
get "/patrons/plans.json"
|
||||
get "/s/plans.json"
|
||||
end
|
||||
|
||||
it "lists the active plans for a product" do
|
||||
::Stripe::Plan.expects(:list).with(active: true, product: 'prod_3765')
|
||||
get "/patrons/plans.json", params: { product_id: 'prod_3765' }
|
||||
get "/s/plans.json", params: { product_id: 'prod_3765' }
|
||||
end
|
||||
|
||||
it "orders and serialises the plans" do
|
||||
@ -24,7 +24,7 @@ module DiscoursePatrons
|
||||
]
|
||||
)
|
||||
|
||||
get "/patrons/plans.json"
|
||||
get "/s/plans.json"
|
||||
|
||||
expect(JSON.parse(response.body)).to eq([
|
||||
{ "amount" => 1000, "currency" => "aud", "id" => "plan_id678", "interval" => "week" },
|
||||
|
@ -26,7 +26,7 @@ module DiscoursePatrons
|
||||
it "gets products" do
|
||||
::Stripe::Product.expects(:list).with(active: true).returns(data: [product])
|
||||
|
||||
get "/patrons/products.json"
|
||||
get "/s/products.json"
|
||||
|
||||
expect(JSON.parse(response.body)).to eq([{
|
||||
"id" => "prodct_23456",
|
||||
@ -40,7 +40,7 @@ module DiscoursePatrons
|
||||
::DiscoursePatrons::Customer.create(product_id: product[:id], user_id: user.id, customer_id: 'x')
|
||||
::Stripe::Product.expects(:list).with(active: true).returns(data: [product])
|
||||
|
||||
get "/patrons/products.json"
|
||||
get "/s/products.json"
|
||||
data = JSON.parse(response.body)
|
||||
expect(data.first["subscribed"]).to eq true
|
||||
end
|
||||
@ -49,7 +49,7 @@ module DiscoursePatrons
|
||||
::DiscoursePatrons::Customer.delete_all
|
||||
::Stripe::Product.expects(:list).with(active: true).returns(data: [product])
|
||||
|
||||
get "/patrons/products.json"
|
||||
get "/s/products.json"
|
||||
data = JSON.parse(response.body)
|
||||
expect(data.first["subscribed"]).to eq false
|
||||
end
|
||||
@ -58,7 +58,7 @@ module DiscoursePatrons
|
||||
describe 'show' do
|
||||
it 'retrieves the product' do
|
||||
::Stripe::Product.expects(:retrieve).with('prod_walterwhite').returns(product)
|
||||
get "/patrons/products/prod_walterwhite.json"
|
||||
get "/s/products/prod_walterwhite.json"
|
||||
|
||||
expect(JSON.parse(response.body)).to eq(
|
||||
"id" => "prodct_23456",
|
||||
|
@ -8,7 +8,7 @@ module DiscoursePatrons
|
||||
it "does not create a subscription" do
|
||||
::Stripe::Plan.expects(:retrieve).never
|
||||
::Stripe::Subscription.expects(:create).never
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
post "/s/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
end
|
||||
end
|
||||
|
||||
@ -33,7 +33,7 @@ module DiscoursePatrons
|
||||
).returns(status: 'active')
|
||||
|
||||
expect {
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
post "/s/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
}.to change { DiscoursePatrons::Customer.count }
|
||||
end
|
||||
|
||||
@ -42,7 +42,7 @@ module DiscoursePatrons
|
||||
::Stripe::Subscription.expects(:create).returns(status: 'active')
|
||||
|
||||
expect {
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
post "/s/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
}.to change { DiscoursePatrons::Customer.count }
|
||||
end
|
||||
end
|
||||
@ -58,13 +58,13 @@ module DiscoursePatrons
|
||||
|
||||
it "does not add the user to the admins group" do
|
||||
::Stripe::Plan.expects(:retrieve).returns(metadata: { group_name: 'admins' })
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
post "/s/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
expect(user.admin).to eq false
|
||||
end
|
||||
|
||||
it "does not add the user to other group" do
|
||||
::Stripe::Plan.expects(:retrieve).returns(metadata: { group_name: 'other' })
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
post "/s/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
expect(user.groups).to be_empty
|
||||
end
|
||||
end
|
||||
@ -78,7 +78,7 @@ module DiscoursePatrons
|
||||
::Stripe::Subscription.expects(:create).returns(status: 'failed')
|
||||
|
||||
expect {
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
post "/s/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
}.not_to change { group.users.count }
|
||||
|
||||
expect(user.groups).to be_empty
|
||||
@ -88,7 +88,7 @@ module DiscoursePatrons
|
||||
::Stripe::Subscription.expects(:create).returns(status: 'active')
|
||||
|
||||
expect {
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
post "/s/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
}.to change { group.users.count }
|
||||
|
||||
expect(user.groups).not_to be_empty
|
||||
@ -98,7 +98,7 @@ module DiscoursePatrons
|
||||
::Stripe::Subscription.expects(:create).returns(status: 'trialing')
|
||||
|
||||
expect {
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
post "/s/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
}.to change { group.users.count }
|
||||
|
||||
expect(user.groups).not_to be_empty
|
||||
|
@ -11,12 +11,12 @@ module DiscoursePatrons
|
||||
context "not authenticated" do
|
||||
it "does not get the subscriptions" do
|
||||
::Stripe::Customer.expects(:list).never
|
||||
get "/patrons/user/subscriptions.json"
|
||||
get "/s/user/subscriptions.json"
|
||||
end
|
||||
|
||||
it "does not destroy a subscription" do
|
||||
::Stripe::Subscription.expects(:delete).never
|
||||
patch "/patrons/user/subscriptions/sub_12345.json"
|
||||
patch "/s/user/subscriptions/sub_12345.json"
|
||||
end
|
||||
end
|
||||
|
||||
@ -67,7 +67,7 @@ module DiscoursePatrons
|
||||
expand: ['data.subscriptions']
|
||||
).returns(customers)
|
||||
|
||||
get "/patrons/user/subscriptions.json"
|
||||
get "/s/user/subscriptions.json"
|
||||
|
||||
subscription = JSON.parse(response.body).first
|
||||
|
||||
@ -105,7 +105,7 @@ module DiscoursePatrons
|
||||
.never
|
||||
|
||||
expect {
|
||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||
delete "/s/user/subscriptions/sub_12345.json"
|
||||
}.not_to change { DiscoursePatrons::Customer.count }
|
||||
|
||||
expect(response.status).to eq 422
|
||||
@ -125,7 +125,7 @@ module DiscoursePatrons
|
||||
.never
|
||||
|
||||
expect {
|
||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||
delete "/s/user/subscriptions/sub_12345.json"
|
||||
}.not_to change { DiscoursePatrons::Customer.count }
|
||||
|
||||
expect(response.status).to eq 422
|
||||
@ -144,7 +144,7 @@ module DiscoursePatrons
|
||||
.expects(:delete)
|
||||
|
||||
expect {
|
||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||
delete "/s/user/subscriptions/sub_12345.json"
|
||||
}.to change { user.groups.count }.by(-1)
|
||||
end
|
||||
|
||||
@ -161,7 +161,7 @@ module DiscoursePatrons
|
||||
.expects(:delete)
|
||||
|
||||
expect {
|
||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||
delete "/s/user/subscriptions/sub_12345.json"
|
||||
}.not_to change { user.groups.count }
|
||||
end
|
||||
|
||||
@ -179,7 +179,7 @@ module DiscoursePatrons
|
||||
.with('sub_12345')
|
||||
|
||||
expect {
|
||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||
delete "/s/user/subscriptions/sub_12345.json"
|
||||
}.to change { DiscoursePatrons::Customer.count }.by(-1)
|
||||
|
||||
expect(response.status).to eq 200
|
||||
@ -199,7 +199,7 @@ module DiscoursePatrons
|
||||
.with('sub_12345')
|
||||
|
||||
expect {
|
||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||
delete "/s/user/subscriptions/sub_12345.json"
|
||||
}.to change { DiscoursePatrons::Customer.count }.by(-1)
|
||||
|
||||
expect(response.status).to eq 200
|
||||
@ -219,7 +219,7 @@ module DiscoursePatrons
|
||||
.with('sub_12345')
|
||||
|
||||
expect {
|
||||
delete "/patrons/user/subscriptions/sub_12345.json"
|
||||
delete "/s/user/subscriptions/sub_12345.json"
|
||||
}.to change { DiscoursePatrons::Customer.count }.by(-1)
|
||||
|
||||
expect(response.status).to eq 200
|
||||
|
Loading…
x
Reference in New Issue
Block a user