mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-02-17 17:04:45 +00:00
linting
This commit is contained in:
parent
fcc414dbbe
commit
e46693b94e
@ -1,5 +1,5 @@
|
|||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import Ember from "ember";
|
import { computed } from "@ember/object";
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ export default Controller.extend({
|
|||||||
.then(() => this.set("email", this.currentUser.email));
|
.then(() => this.set("email", this.currentUser.email));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pricingTable: Ember.computed("email", function () {
|
pricingTable: computed("email", function () {
|
||||||
try {
|
try {
|
||||||
const pricing_table_info = JSON.parse(
|
const pricing_table_info = JSON.parse(
|
||||||
this.siteSettings.discourse_subscriptions_pricing_table
|
this.siteSettings.discourse_subscriptions_pricing_table
|
||||||
|
@ -25,11 +25,21 @@ RSpec.describe DiscourseSubscriptions::Admin::PlansController do
|
|||||||
describe "create" do
|
describe "create" do
|
||||||
it "does not create a plan" do
|
it "does not create a plan" do
|
||||||
::Stripe::Price.expects(:create).never
|
::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
|
end
|
||||||
|
|
||||||
it "is not ok" do
|
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
|
expect(response.status).to eq 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -94,12 +104,24 @@ RSpec.describe DiscourseSubscriptions::Admin::PlansController do
|
|||||||
describe "create" do
|
describe "create" do
|
||||||
it "creates a plan with a nickname" do
|
it "creates a plan with a nickname" do
|
||||||
::Stripe::Price.expects(:create).with(has_entry(:nickname, "Veg"))
|
::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
|
end
|
||||||
|
|
||||||
it "creates a plan with a currency" do
|
it "creates a plan with a currency" do
|
||||||
::Stripe::Price.expects(:create).with(has_entry(:currency, "AUD"))
|
::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
|
end
|
||||||
|
|
||||||
it "creates a plan with an interval" do
|
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
|
it "creates a plan with an amount" do
|
||||||
::Stripe::Price.expects(:create).with(has_entry(:unit_amount, "102"))
|
::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
|
end
|
||||||
|
|
||||||
it "creates a plan with a product" do
|
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
|
it "creates a plan with an active status" do
|
||||||
::Stripe::Price.expects(:create).with(has_entry(:active, "false"))
|
::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
|
end
|
||||||
|
|
||||||
# TODO: Need to fix the metadata tests
|
# TODO: Need to fix the metadata tests
|
||||||
|
@ -95,7 +95,9 @@ RSpec.describe DiscourseSubscriptions::HooksController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "deletes the customer" do
|
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
|
expect(response.status).to eq 200
|
||||||
end
|
end
|
||||||
|
@ -412,7 +412,11 @@ RSpec.describe DiscourseSubscriptions::SubscribeController do
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect {
|
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 }
|
}.to change { DiscourseSubscriptions::Customer.count }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -432,7 +436,11 @@ RSpec.describe DiscourseSubscriptions::SubscribeController do
|
|||||||
)
|
)
|
||||||
|
|
||||||
expect {
|
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 }
|
}.to change { DiscourseSubscriptions::Customer.count }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,10 @@ RSpec.describe DiscourseSubscriptions::User::SubscriptionsController do
|
|||||||
it "doesn't update payment method for subscription" do
|
it "doesn't update payment method for subscription" do
|
||||||
::Stripe::Subscription.expects(:update).never
|
::Stripe::Subscription.expects(:update).never
|
||||||
::Stripe::PaymentMethod.expects(:attach).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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -100,7 +103,10 @@ RSpec.describe DiscourseSubscriptions::User::SubscriptionsController do
|
|||||||
it "updates the payment method for subscription" do
|
it "updates the payment method for subscription" do
|
||||||
::Stripe::Subscription.expects(:update).once
|
::Stripe::Subscription.expects(:update).once
|
||||||
::Stripe::PaymentMethod.expects(:attach).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
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
||||||
import { visit } from "@ember/test-helpers";
|
import { visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
acceptance("Discourse Subscriptions", function (needs) {
|
acceptance("Discourse Subscriptions", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user