user group specs. help page
This commit is contained in:
parent
8650e6c236
commit
eead6fd345
|
@ -6,28 +6,34 @@
|
|||
{{/link-to}}
|
||||
</p>
|
||||
|
||||
<table class="table discourse-patrons-admin">
|
||||
<thead>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.name'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.created_at'}}</th>
|
||||
<th class="td-right">{{i18n 'discourse_patrons.admin.products.product.active'}}</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
{{#each model as |product|}}
|
||||
<tr>
|
||||
<td>{{product.name}}</td>
|
||||
<td>{{format-date product.createdFormatted}}</td>
|
||||
<td class="td-right">{{product.active}}</td>
|
||||
<td class="td-right">
|
||||
{{#link-to "adminPlugins.discourse-patrons.products.show" product.id class="btn no-text btn-icon"}}
|
||||
{{d-icon "far-edit"}}
|
||||
{{/link-to}}
|
||||
{{d-button
|
||||
action=(route-action "destroyProduct")
|
||||
actionParam=product
|
||||
icon="trash-alt"
|
||||
class="btn-danger btn no-text btn-icon"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{#if model}}
|
||||
<table class="table discourse-patrons-admin">
|
||||
<thead>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.name'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.products.product.created_at'}}</th>
|
||||
<th class="td-right">{{i18n 'discourse_patrons.admin.products.product.active'}}</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
{{#each model as |product|}}
|
||||
<tr>
|
||||
<td>{{product.name}}</td>
|
||||
<td>{{format-date product.createdFormatted}}</td>
|
||||
<td class="td-right">{{product.active}}</td>
|
||||
<td class="td-right">
|
||||
{{#link-to "adminPlugins.discourse-patrons.products.show" product.id class="btn no-text btn-icon"}}
|
||||
{{d-icon "far-edit"}}
|
||||
{{/link-to}}
|
||||
{{d-button
|
||||
action=(route-action "destroyProduct")
|
||||
actionParam=product
|
||||
icon="trash-alt"
|
||||
class="btn-danger btn no-text btn-icon"}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{else}}
|
||||
<p>
|
||||
{{i18n 'discourse_patrons.admin.products.product_help'}}
|
||||
</p>
|
||||
{{/if}}
|
||||
|
|
|
@ -76,6 +76,7 @@ en:
|
|||
plan_help: Create a pricing plan to subscribe customers to this product
|
||||
active: Active
|
||||
created_at: Created
|
||||
product_help: Before cutomers can subscribe to your site, you need to create at least one product and an associated plan.
|
||||
plans:
|
||||
title: Pricing Plans
|
||||
operations:
|
||||
|
|
|
@ -27,12 +27,21 @@ module DiscoursePatrons
|
|||
let(:group) { Fabricate(:group, name: group_name) }
|
||||
|
||||
context "unauthorized group" do
|
||||
before do
|
||||
::Stripe::Subscription.expects(:create).returns(status: 'active')
|
||||
end
|
||||
|
||||
it "does not add the user to the admins group" do
|
||||
::Stripe::Plan.expects(:retrieve).returns(metadata: { group_name: 'admins' })
|
||||
::Stripe::Subscription.expects(:create).returns(status: 'active')
|
||||
post "/patrons/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' }
|
||||
expect(user.groups).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context "plan has group in metadata" do
|
||||
|
@ -46,6 +55,8 @@ module DiscoursePatrons
|
|||
expect {
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
}.not_to change { group.users.count }
|
||||
|
||||
expect(user.groups).to be_empty
|
||||
end
|
||||
|
||||
it "adds the user to the group when the subscription is active" do
|
||||
|
@ -54,6 +65,8 @@ module DiscoursePatrons
|
|||
expect {
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
}.to change { group.users.count }
|
||||
|
||||
expect(user.groups).not_to be_empty
|
||||
end
|
||||
|
||||
it "adds the user to the group when the subscription is trialing" do
|
||||
|
@ -62,6 +75,8 @@ module DiscoursePatrons
|
|||
expect {
|
||||
post "/patrons/subscriptions.json", params: { plan: 'plan_1234', customer: 'cus_1234' }
|
||||
}.to change { group.users.count }
|
||||
|
||||
expect(user.groups).not_to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue