diff --git a/assets/javascripts/discourse/routes/s-subscribe-show.js.es6 b/assets/javascripts/discourse/routes/s-subscribe-show.js.es6 index 7664b0e..d3a21d8 100644 --- a/assets/javascripts/discourse/routes/s-subscribe-show.js.es6 +++ b/assets/javascripts/discourse/routes/s-subscribe-show.js.es6 @@ -5,12 +5,10 @@ import Subscription from "discourse/plugins/discourse-subscriptions/discourse/mo export default Discourse.Route.extend({ model(params) { const product_id = params["subscription-id"]; - const product = Product.find(product_id); + const product = Product.find(product_id); const subscription = Subscription.create(); - const plans = Plan.findAll({ product_id: product_id }).then(results => - results.map(p => ({ id: p.id, name: p.subscriptionRate })) - ); + const plans = Plan.findAll({ product_id: product_id }); return Ember.RSVP.hash({ plans, product, subscription }); } diff --git a/assets/javascripts/discourse/templates/components/payment-options.hbs b/assets/javascripts/discourse/templates/components/payment-options.hbs index 06a1388..76ad56f 100644 --- a/assets/javascripts/discourse/templates/components/payment-options.hbs +++ b/assets/javascripts/discourse/templates/components/payment-options.hbs @@ -18,7 +18,7 @@ class="btn btn-discourse-subscriptions-subscribe" }}
- {{plan.interval}} + {{i18n (concat "discourse_subscriptions.plans.interval.adverb." plan.interval)}}
{{format-currency plan.currency plan.amountDollars}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 1a59974..7107b7c 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -25,6 +25,12 @@ en: subscriptions: Subscriptions subscribe: Subscribe billing: Billing + plans: + interval: + adverb: + week: Weekly + month: Monthly + year: Yearly user: plans: rate: Rate diff --git a/test/javascripts/components/payment-options-test.js.es6 b/test/javascripts/components/payment-options-test.js.es6 index 88b9c0b..e7e5a96 100644 --- a/test/javascripts/components/payment-options-test.js.es6 +++ b/test/javascripts/components/payment-options-test.js.es6 @@ -21,8 +21,8 @@ componentTest("Discourse Subscriptions payment options has content", { async test(assert) { this.set("plans", [ - { currency: 'AUD', interval: 'year', amountDollars: "44.99" }, - { currency: 'GDP', interval: 'month', amountDollars: "9.99" }, + { currency: "aud", interval: "year", amountDollars: "44.99" }, + { currency: "gdp", interval: "month", amountDollars: "9.99" } ]); assert.equal( @@ -36,12 +36,16 @@ componentTest("Discourse Subscriptions payment options has content", { "The none are selected" ); assert.equal( - find(".btn-discourse-subscriptions-subscribe:first-child .interval").text().trim(), - "year", + find(".btn-discourse-subscriptions-subscribe:first-child .interval") + .text() + .trim(), + "Yearly", "The plan interval is shown" ); assert.equal( - find(".btn-discourse-subscriptions-subscribe:first-child .amount").text().trim(), + find(".btn-discourse-subscriptions-subscribe:first-child .amount") + .text() + .trim(), "$AUD 44.99", "The plan amount and currency is shown" ); @@ -55,10 +59,13 @@ componentTest("Discourse Subscriptions payment options plan is selected", { async test(assert) { assert.expect(1); - this.set("plans", [1, 2]); + this.set("plans", [ + { currency: "aud", interval: "year", amountDollars: "44.99" }, + { currency: "gdp", interval: "month", amountDollars: "9.99" } + ]); this.set("selectPlan", function(plan) { - assert.equal(plan, 1, "the plan is selected"); + assert.equal(plan, this.get('plans.firstObject'), "the plan is selected"); }); await click(".btn-discourse-subscriptions-subscribe:first-child");