From e46693b94eb8bef38a1808a5a04d7a02742907b0 Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Wed, 24 Apr 2024 10:09:53 -0600 Subject: [PATCH] linting --- .../discourse/controllers/subscriptions.js | 4 +- .../requests/admin/coupons_controller_spec.rb | 2 +- spec/requests/admin/plans_controller_spec.rb | 48 ++++++++++++++++--- .../admin/products_controller_spec.rb | 2 +- .../admin/subscriptions_controller_spec.rb | 2 +- spec/requests/hooks_controller_spec.rb | 6 ++- spec/requests/subscribe_controller_spec.rb | 14 ++++-- .../requests/user/payments_controller_spec.rb | 2 +- .../user/subscriptions_controller_spec.rb | 12 +++-- .../acceptance/pricing-table-test.js | 2 +- 10 files changed, 72 insertions(+), 22 deletions(-) diff --git a/assets/javascripts/discourse/controllers/subscriptions.js b/assets/javascripts/discourse/controllers/subscriptions.js index c5614cf..4e35b5a 100644 --- a/assets/javascripts/discourse/controllers/subscriptions.js +++ b/assets/javascripts/discourse/controllers/subscriptions.js @@ -1,5 +1,5 @@ import Controller from "@ember/controller"; -import Ember from "ember"; +import { computed } from "@ember/object"; import { htmlSafe } from "@ember/template"; import I18n from "I18n"; @@ -14,7 +14,7 @@ export default Controller.extend({ .then(() => this.set("email", this.currentUser.email)); } }, - pricingTable: Ember.computed("email", function () { + pricingTable: computed("email", function () { try { const pricing_table_info = JSON.parse( this.siteSettings.discourse_subscriptions_pricing_table diff --git a/spec/requests/admin/coupons_controller_spec.rb b/spec/requests/admin/coupons_controller_spec.rb index fdcdc40..d918aea 100644 --- a/spec/requests/admin/coupons_controller_spec.rb +++ b/spec/requests/admin/coupons_controller_spec.rb @@ -84,4 +84,4 @@ RSpec.describe DiscourseSubscriptions::Admin::CouponsController do end end end -end \ No newline at end of file +end diff --git a/spec/requests/admin/plans_controller_spec.rb b/spec/requests/admin/plans_controller_spec.rb index 1315225..9b8315d 100644 --- a/spec/requests/admin/plans_controller_spec.rb +++ b/spec/requests/admin/plans_controller_spec.rb @@ -25,11 +25,21 @@ RSpec.describe DiscourseSubscriptions::Admin::PlansController do describe "create" do it "does not create a plan" do ::Stripe::Price.expects(:create).never - post "/subscriptions/admin/plans.json", params: { name: "Rick Astley", amount: 1, interval: "week" } + post "/subscriptions/admin/plans.json", + params: { + name: "Rick Astley", + amount: 1, + interval: "week", + } end it "is not ok" do - post "/subscriptions/admin/plans.json", params: { name: "Rick Astley", amount: 1, interval: "week" } + post "/subscriptions/admin/plans.json", + params: { + name: "Rick Astley", + amount: 1, + interval: "week", + } expect(response.status).to eq 404 end end @@ -94,12 +104,24 @@ RSpec.describe DiscourseSubscriptions::Admin::PlansController do describe "create" do it "creates a plan with a nickname" do ::Stripe::Price.expects(:create).with(has_entry(:nickname, "Veg")) - post "/subscriptions/admin/plans.json", params: { nickname: "Veg", metadata: { group_name: "" } } + post "/subscriptions/admin/plans.json", + params: { + nickname: "Veg", + metadata: { + group_name: "", + }, + } end it "creates a plan with a currency" do ::Stripe::Price.expects(:create).with(has_entry(:currency, "AUD")) - post "/subscriptions/admin/plans.json", params: { currency: "AUD", metadata: { group_name: "" } } + post "/subscriptions/admin/plans.json", + params: { + currency: "AUD", + metadata: { + group_name: "", + }, + } end it "creates a plan with an interval" do @@ -121,7 +143,13 @@ RSpec.describe DiscourseSubscriptions::Admin::PlansController do it "creates a plan with an amount" do ::Stripe::Price.expects(:create).with(has_entry(:unit_amount, "102")) - post "/subscriptions/admin/plans.json", params: { amount: "102", metadata: { group_name: "" } } + post "/subscriptions/admin/plans.json", + params: { + amount: "102", + metadata: { + group_name: "", + }, + } end it "creates a plan with a product" do @@ -137,7 +165,13 @@ RSpec.describe DiscourseSubscriptions::Admin::PlansController do it "creates a plan with an active status" do ::Stripe::Price.expects(:create).with(has_entry(:active, "false")) - post "/subscriptions/admin/plans.json", params: { active: "false", metadata: { group_name: "" } } + post "/subscriptions/admin/plans.json", + params: { + active: "false", + metadata: { + group_name: "", + }, + } end # TODO: Need to fix the metadata tests @@ -167,4 +201,4 @@ RSpec.describe DiscourseSubscriptions::Admin::PlansController do end end end -end \ No newline at end of file +end diff --git a/spec/requests/admin/products_controller_spec.rb b/spec/requests/admin/products_controller_spec.rb index 97edb56..fc114c6 100644 --- a/spec/requests/admin/products_controller_spec.rb +++ b/spec/requests/admin/products_controller_spec.rb @@ -127,4 +127,4 @@ RSpec.describe DiscourseSubscriptions::Admin::ProductsController do end end end -end \ No newline at end of file +end diff --git a/spec/requests/admin/subscriptions_controller_spec.rb b/spec/requests/admin/subscriptions_controller_spec.rb index 6ec6aae..8162d1d 100644 --- a/spec/requests/admin/subscriptions_controller_spec.rb +++ b/spec/requests/admin/subscriptions_controller_spec.rb @@ -140,4 +140,4 @@ RSpec.describe DiscourseSubscriptions::Admin::SubscriptionsController do end end end -end \ No newline at end of file +end diff --git a/spec/requests/hooks_controller_spec.rb b/spec/requests/hooks_controller_spec.rb index 9149835..fcfc8eb 100644 --- a/spec/requests/hooks_controller_spec.rb +++ b/spec/requests/hooks_controller_spec.rb @@ -95,7 +95,9 @@ RSpec.describe DiscourseSubscriptions::HooksController do end it "deletes the customer" do - expect { post "/subscriptions/hooks.json" }.to change { DiscourseSubscriptions::Customer.count }.by(-1) + expect { post "/subscriptions/hooks.json" }.to change { + DiscourseSubscriptions::Customer.count + }.by(-1) expect(response.status).to eq 200 end @@ -107,4 +109,4 @@ RSpec.describe DiscourseSubscriptions::HooksController do end end end -end \ No newline at end of file +end diff --git a/spec/requests/subscribe_controller_spec.rb b/spec/requests/subscribe_controller_spec.rb index b2861b5..f56d221 100644 --- a/spec/requests/subscribe_controller_spec.rb +++ b/spec/requests/subscribe_controller_spec.rb @@ -412,7 +412,11 @@ RSpec.describe DiscourseSubscriptions::SubscribeController do ) expect { - post "/subscriptions/finalize.json", params: { plan: "plan_1234", transaction: "sub_1234" } + post "/subscriptions/finalize.json", + params: { + plan: "plan_1234", + transaction: "sub_1234", + } }.to change { DiscourseSubscriptions::Customer.count } end end @@ -432,7 +436,11 @@ RSpec.describe DiscourseSubscriptions::SubscribeController do ) expect { - post "/subscriptions/finalize.json", params: { plan: "plan_1234", transaction: "in_1234" } + post "/subscriptions/finalize.json", + params: { + plan: "plan_1234", + transaction: "in_1234", + } }.to change { DiscourseSubscriptions::Customer.count } end end @@ -515,4 +523,4 @@ RSpec.describe DiscourseSubscriptions::SubscribeController do end end end -end \ No newline at end of file +end diff --git a/spec/requests/user/payments_controller_spec.rb b/spec/requests/user/payments_controller_spec.rb index 9782af8..52dbb69 100644 --- a/spec/requests/user/payments_controller_spec.rb +++ b/spec/requests/user/payments_controller_spec.rb @@ -61,4 +61,4 @@ RSpec.describe DiscourseSubscriptions::User::PaymentsController do expect(parsed_body.count).to eq(2) end end -end \ No newline at end of file +end diff --git a/spec/requests/user/subscriptions_controller_spec.rb b/spec/requests/user/subscriptions_controller_spec.rb index b9eefe9..dac9860 100644 --- a/spec/requests/user/subscriptions_controller_spec.rb +++ b/spec/requests/user/subscriptions_controller_spec.rb @@ -25,7 +25,10 @@ RSpec.describe DiscourseSubscriptions::User::SubscriptionsController do it "doesn't update payment method for subscription" do ::Stripe::Subscription.expects(:update).never ::Stripe::PaymentMethod.expects(:attach).never - put "/subscriptions/user/subscriptions/sub_12345.json", params: { payment_method: "pm_abc123abc" } + put "/subscriptions/user/subscriptions/sub_12345.json", + params: { + payment_method: "pm_abc123abc", + } end end @@ -100,8 +103,11 @@ RSpec.describe DiscourseSubscriptions::User::SubscriptionsController do it "updates the payment method for subscription" do ::Stripe::Subscription.expects(:update).once ::Stripe::PaymentMethod.expects(:attach).once - put "/subscriptions/user/subscriptions/sub_1234.json", params: { payment_method: "pm_abc123abc" } + put "/subscriptions/user/subscriptions/sub_1234.json", + params: { + payment_method: "pm_abc123abc", + } end end end -end \ No newline at end of file +end diff --git a/test/javascripts/acceptance/pricing-table-test.js b/test/javascripts/acceptance/pricing-table-test.js index 931c874..ff7cad7 100644 --- a/test/javascripts/acceptance/pricing-table-test.js +++ b/test/javascripts/acceptance/pricing-table-test.js @@ -1,6 +1,6 @@ -import { acceptance } from "discourse/tests/helpers/qunit-helpers"; import { visit } from "@ember/test-helpers"; import { test } from "qunit"; +import { acceptance } from "discourse/tests/helpers/qunit-helpers"; acceptance("Discourse Subscriptions", function (needs) { needs.user();