{{#unless model.plans}}
- Create a pricing plan to subscribe customers to this product
+ {{i18n 'discourse_patrons.admin.products.product.plan_help'}}
{{/unless}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 4edc029..11802c0 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -75,6 +75,7 @@ en:
statement_descriptor_help: Extra information about a product which will appear on your customer’s credit card statement.
group: User Group
group_help: This is the discourse user group the customer gets added to when the subscription is created.
+ plan_help: Create a pricing plan to subscribe customers to this product
active: Active
created_at: Created
plans:
@@ -95,6 +96,8 @@ en:
amount: Amount
trial: Trial Period Days
trial_help: Subscriptions to this plan will automatically start with a free trial of this length
+ group: User Group
+ group_help: This is the discourse user group the customer gets added to when the subscription is created.
created_at: Created
subscriptions:
title: Subscriptions
diff --git a/spec/requests/admin/plans_controller_spec.rb b/spec/requests/admin/plans_controller_spec.rb
index 8bd0ce0..0147066 100644
--- a/spec/requests/admin/plans_controller_spec.rb
+++ b/spec/requests/admin/plans_controller_spec.rb
@@ -79,33 +79,38 @@ 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' }
+ post "/patrons/admin/plans.json", params: { nickname: 'Veg', metadata: { group_name: '' } }
end
it "creates a plan with a currency" do
SiteSetting.stubs(:discourse_patrons_currency).returns('aud')
::Stripe::Plan.expects(:create).with(has_entry(:currency, 'aud'))
- post "/patrons/admin/plans.json", params: {}
+ post "/patrons/admin/plans.json", params: { 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' }
+ post "/patrons/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' }
+ post "/patrons/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' }
+ post "/patrons/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' }
+ post "/patrons/admin/plans.json", params: { product: 'prod_walterwhite', 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' } }
end
end
diff --git a/spec/requests/admin/products_controller_spec.rb b/spec/requests/admin/products_controller_spec.rb
index eda8cb2..e776d4b 100644
--- a/spec/requests/admin/products_controller_spec.rb
+++ b/spec/requests/admin/products_controller_spec.rb
@@ -56,27 +56,22 @@ module DiscoursePatrons
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: { metadata: { group_name: '' } }
+ post "/patrons/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', metadata: { group_name: '' } }
+ post "/patrons/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', metadata: { group_name: '' } }
+ post "/patrons/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', metadata: { group_name: '' } }
- end
-
- it 'has a metadata' do
- ::Stripe::Product.expects(:create).with(has_entry(metadata: { group_name: 'discourse-user-group-name' }))
- post "/patrons/admin/products.json", params: { metadata: { group_name: 'discourse-user-group-name' } }
+ post "/patrons/admin/products.json", params: { statement_descriptor: 'Blessed are the cheesemakers' }
end
end
@@ -90,7 +85,7 @@ module DiscoursePatrons
describe 'update' do
it 'updates the product' do
::Stripe::Product.expects(:update)
- patch "/patrons/admin/products/prod_walterwhite.json", params: { metadata: { group_name: '' } }
+ patch "/patrons/admin/products/prod_walterwhite.json", params: {}
end
end