DEV: Update linting (#189)

This commit is contained in:
Jarek Radosz 2024-01-16 17:51:44 +01:00 committed by GitHub
parent a3883d2a9a
commit d33cf2921e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 2444 additions and 1941 deletions

View File

@ -1,6 +0,0 @@
{
"globals": {
"Stripe": true
},
"extends": "eslint-config-discourse"
}

1
.eslintrc.cjs Normal file
View File

@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/eslint");

View File

@ -1 +0,0 @@
{}

1
.prettierrc.cjs Normal file
View File

@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/prettier");

1
.template-lintrc.cjs Normal file
View File

@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/template-lint");

View File

@ -1,4 +0,0 @@
module.exports = {
plugins: ["ember-template-lint-plugin-discourse"],
extends: "discourse:recommended",
};

View File

@ -8,35 +8,45 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
ast (2.4.2) ast (2.4.2)
json (2.6.2) json (2.7.1)
parallel (1.22.1) language_server-protocol (3.17.0.3)
parser (3.1.2.1) parallel (1.24.0)
parser (3.3.0.4)
ast (~> 2.4.1) ast (~> 2.4.1)
prettier_print (1.2.0) racc
prettier_print (1.2.1)
racc (1.7.3)
rainbow (3.1.1) rainbow (3.1.1)
regexp_parser (2.6.0) regexp_parser (2.9.0)
rexml (3.2.5) rexml (3.2.6)
rubocop (1.36.0) rubocop (1.60.0)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.1.2.1) parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0) regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0) rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0) rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0) unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.21.0) rubocop-ast (1.30.0)
parser (>= 3.1.1.0) parser (>= 3.2.1.0)
rubocop-discourse (3.0) rubocop-capybara (2.20.0)
rubocop (>= 1.1.0) rubocop (~> 1.41)
rubocop-rspec (>= 2.0.0) rubocop-discourse (3.6.0)
rubocop-rspec (2.13.2) rubocop (>= 1.59.0)
rubocop (~> 1.33) rubocop-rspec (>= 2.25.0)
ruby-progressbar (1.11.0) rubocop-factory_bot (2.25.1)
syntax_tree (5.1.0) rubocop (~> 1.41)
rubocop-rspec (2.26.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0) prettier_print (>= 1.2.0)
unicode-display_width (2.3.0) unicode-display_width (2.5.0)
PLATFORMS PLATFORMS
ruby ruby
@ -47,4 +57,4 @@ DEPENDENCIES
translations-manager! translations-manager!
BUNDLED WITH BUNDLED WITH
2.3.4 2.5.4

View File

@ -1,11 +1,11 @@
import { action } from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import { equal } from "@ember/object/computed";
import { setting } from "discourse/lib/computed";
import Component from "@ember/component"; import Component from "@ember/component";
import discourseComputed, { observes } from "discourse-common/utils/decorators"; import { action } from "@ember/object";
import { equal } from "@ember/object/computed";
import { later } from "@ember/runloop"; import { later } from "@ember/runloop";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { ajax } from "discourse/lib/ajax";
import { setting } from "discourse/lib/computed";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
const SIDEBAR_BODY_CLASS = "subscription-campaign-sidebar"; const SIDEBAR_BODY_CLASS = "subscription-campaign-sidebar";
@ -96,6 +96,7 @@ export default Component.extend({
}, },
willDestroyElement() { willDestroyElement() {
this._super(...arguments);
document.body.classList.remove(SIDEBAR_BODY_CLASS); document.body.classList.remove(SIDEBAR_BODY_CLASS);
}, },

View File

@ -1,10 +1,10 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { Input } from "@ember/component";
import { fn, hash } from "@ember/helper";
import DButton from "discourse/components/d-button"; import DButton from "discourse/components/d-button";
import DModal from "discourse/components/d-modal"; import DModal from "discourse/components/d-modal";
import Component from "@glimmer/component";
import { fn, hash } from "@ember/helper";
import i18n from "discourse-common/helpers/i18n"; import i18n from "discourse-common/helpers/i18n";
import { Input } from "@ember/component";
import { tracked } from "@glimmer/tracking";
export default class AdminCancelSubscription extends Component { export default class AdminCancelSubscription extends Component {
@tracked refund; @tracked refund;

View File

@ -1,6 +1,6 @@
import discourseComputed from "discourse-common/utils/decorators";
import { isEmpty } from "@ember/utils";
import Component from "@ember/component"; import Component from "@ember/component";
import { isEmpty } from "@ember/utils";
import discourseComputed from "discourse-common/utils/decorators";
export default Component.extend({ export default Component.extend({
classNames: ["product-list"], classNames: ["product-list"],

View File

@ -1,6 +1,6 @@
import ComboBoxComponent from "select-kit/components/combo-box";
import { computed } from "@ember/object"; import { computed } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import ComboBoxComponent from "select-kit/components/combo-box";
export default ComboBoxComponent.extend({ export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["subscribe-ca-province-select"], pluginApiIdentifiers: ["subscribe-ca-province-select"],

View File

@ -24,5 +24,8 @@ export default Component.extend({
}, },
}); });
}, },
didDestroyElement() {},
didDestroyElement() {
this._super(...arguments);
},
}); });

View File

@ -1,6 +1,6 @@
import ComboBoxComponent from "select-kit/components/combo-box";
import { computed } from "@ember/object"; import { computed } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import ComboBoxComponent from "select-kit/components/combo-box";
export default ComboBoxComponent.extend({ export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["subscribe-country-select"], pluginApiIdentifiers: ["subscribe-country-select"],

View File

@ -1,6 +1,6 @@
import ComboBoxComponent from "select-kit/components/combo-box";
import { computed } from "@ember/object"; import { computed } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import ComboBoxComponent from "select-kit/components/combo-box";
export default ComboBoxComponent.extend({ export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["subscribe-us-state-select"], pluginApiIdentifiers: ["subscribe-us-state-select"],

View File

@ -1,6 +1,6 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import AdminCoupon from "discourse/plugins/discourse-subscriptions/discourse/models/admin-coupon";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import AdminCoupon from "discourse/plugins/discourse-subscriptions/discourse/models/admin-coupon";
export default Controller.extend({ export default Controller.extend({
creating: null, creating: null,

View File

@ -1,6 +1,6 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Controller.extend({ export default Controller.extend({
router: service(), router: service(),

View File

@ -1,8 +1,8 @@
import discourseComputed from "discourse-common/utils/decorators";
import DiscourseURL from "discourse/lib/url";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { alias } from "@ember/object/computed"; import { alias } from "@ember/object/computed";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import DiscourseURL from "discourse/lib/url";
import discourseComputed from "discourse-common/utils/decorators";
const RECURRING = "recurring"; const RECURRING = "recurring";
const ONE_TIME = "one_time"; const ONE_TIME = "one_time";

View File

@ -1,6 +1,6 @@
import { popupAjaxError } from "discourse/lib/ajax-error";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Controller.extend({ export default Controller.extend({
router: service(), router: service(),

View File

@ -1,9 +1,9 @@
import AdminCancelSubscription from "../components/modal/admin-cancel-subscription";
import AdminSubscription from "../models/admin-subscription";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
import AdminCancelSubscription from "../components/modal/admin-cancel-subscription";
import AdminSubscription from "../models/admin-subscription";
export default Controller.extend({ export default Controller.extend({
modal: service(), modal: service(),

View File

@ -1,11 +1,11 @@
import { action } from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import discourseComputed from "discourse-common/utils/decorators"; import { action } from "@ember/object";
import I18n from "I18n";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n";
export default Controller.extend({ export default Controller.extend({
loading: false, loading: false,

View File

@ -1,6 +1,6 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import discourseComputed from "discourse-common/utils/decorators";
import User from "discourse/models/user"; import User from "discourse/models/user";
import discourseComputed from "discourse-common/utils/decorators";
export default Controller.extend({ export default Controller.extend({
@discourseComputed() @discourseComputed()

View File

@ -1,10 +1,11 @@
/* global Stripe */
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { not } from "@ember/object/computed";
import { inject as service } from "@ember/service";
import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n";
import Subscription from "discourse/plugins/discourse-subscriptions/discourse/models/subscription"; import Subscription from "discourse/plugins/discourse-subscriptions/discourse/models/subscription";
import Transaction from "discourse/plugins/discourse-subscriptions/discourse/models/transaction"; import Transaction from "discourse/plugins/discourse-subscriptions/discourse/models/transaction";
import I18n from "I18n";
import { not } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
import { inject as service } from "@ember/service";
export default Controller.extend({ export default Controller.extend({
dialog: service(), dialog: service(),

View File

@ -1,14 +1,17 @@
/* global Stripe */
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import I18n from "I18n"; import I18n from "I18n";
import { inject as service } from "@ember/service";
export default Controller.extend({ export default Controller.extend({
dialog: service(), dialog: service(),
loading: false, loading: false,
saved: false, saved: false,
init() { init() {
this._super(...arguments); this._super(...arguments);
this.set( this.set(

View File

@ -1,5 +1,5 @@
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
import { autoUpdatingRelativeAge } from "discourse/lib/formatter";
export default function formatUnixDate(timestamp) { export default function formatUnixDate(timestamp) {
if (timestamp) { if (timestamp) {

View File

@ -5,7 +5,7 @@ export default {
name: "setup-subscriptions", name: "setup-subscriptions",
initialize(container) { initialize(container) {
withPluginApi("0.8.11", (api) => { withPluginApi("0.8.11", (api) => {
const siteSettings = container.lookup("site-settings:main"); const siteSettings = container.lookup("service:site-settings");
const isNavLinkEnabled = const isNavLinkEnabled =
siteSettings.discourse_subscriptions_extra_nav_subscribe; siteSettings.discourse_subscriptions_extra_nav_subscribe;
if (isNavLinkEnabled) { if (isNavLinkEnabled) {

View File

@ -1,5 +1,5 @@
import { ajax } from "discourse/lib/ajax";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
const AdminCoupon = EmberObject.extend({ const AdminCoupon = EmberObject.extend({

View File

@ -1,6 +1,6 @@
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
import discourseComputed from "discourse-common/utils/decorators";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import discourseComputed from "discourse-common/utils/decorators";
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
const AdminPlan = Plan.extend({ const AdminPlan = Plan.extend({
isNew: false, isNew: false,

View File

@ -1,5 +1,5 @@
import { ajax } from "discourse/lib/ajax";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax";
const AdminProduct = EmberObject.extend({ const AdminProduct = EmberObject.extend({
isNew: false, isNew: false,

View File

@ -1,7 +1,7 @@
import discourseComputed from "discourse-common/utils/decorators";
import { ajax } from "discourse/lib/ajax";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
import discourseComputed from "discourse-common/utils/decorators";
const AdminSubscription = EmberObject.extend({ const AdminSubscription = EmberObject.extend({
@discourseComputed("status") @discourseComputed("status")

View File

@ -1,6 +1,6 @@
import discourseComputed from "discourse-common/utils/decorators";
import { ajax } from "discourse/lib/ajax";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import discourseComputed from "discourse-common/utils/decorators";
const Subscription = EmberObject.extend({ const Subscription = EmberObject.extend({
@discourseComputed("status") @discourseComputed("status")

View File

@ -1,6 +1,6 @@
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import discourseComputed from "discourse-common/utils/decorators";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import discourseComputed from "discourse-common/utils/decorators";
const UserPayment = EmberObject.extend({ const UserPayment = EmberObject.extend({
@discourseComputed("amount") @discourseComputed("amount")

View File

@ -1,8 +1,8 @@
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import discourseComputed from "discourse-common/utils/decorators";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan"; import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n"; import I18n from "I18n";
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
const UserSubscription = EmberObject.extend({ const UserSubscription = EmberObject.extend({
@discourseComputed("status") @discourseComputed("status")

View File

@ -1,6 +1,6 @@
import { action } from "@ember/object";
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import AdminCoupon from "discourse/plugins/discourse-subscriptions/discourse/models/admin-coupon"; import AdminCoupon from "discourse/plugins/discourse-subscriptions/discourse/models/admin-coupon";
import { action } from "@ember/object";
export default Route.extend({ export default Route.extend({
model() { model() {

View File

@ -1,8 +1,8 @@
import Route from "@ember/routing/route";
import AdminProduct from "discourse/plugins/discourse-subscriptions/discourse/models/admin-product";
import I18n from "I18n";
import { action } from "@ember/object"; import { action } from "@ember/object";
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import I18n from "I18n";
import AdminProduct from "discourse/plugins/discourse-subscriptions/discourse/models/admin-product";
export default Route.extend({ export default Route.extend({
dialog: service(), dialog: service(),

View File

@ -1,7 +1,7 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
import Group from "discourse/models/group";
import { hash } from "rsvp"; import { hash } from "rsvp";
import Group from "discourse/models/group";
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
export default Route.extend({ export default Route.extend({
model(params) { model(params) {

View File

@ -1,10 +1,10 @@
import Route from "@ember/routing/route";
import AdminProduct from "discourse/plugins/discourse-subscriptions/discourse/models/admin-product";
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
import I18n from "I18n";
import { hash } from "rsvp";
import { action } from "@ember/object"; import { action } from "@ember/object";
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { hash } from "rsvp";
import I18n from "I18n";
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
import AdminProduct from "discourse/plugins/discourse-subscriptions/discourse/models/admin-product";
export default Route.extend({ export default Route.extend({
dialog: service(), dialog: service(),

View File

@ -1,5 +1,5 @@
import Route from "@ember/routing/route";
import { action } from "@ember/object"; import { action } from "@ember/object";
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
export default Route.extend({ export default Route.extend({

View File

@ -1,6 +1,6 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
export default Route.extend({ export default Route.extend({
router: service(), router: service(),

View File

@ -1,6 +1,6 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan"; import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
import Subscription from "discourse/plugins/discourse-subscriptions/discourse/models/subscription"; import Subscription from "discourse/plugins/discourse-subscriptions/discourse/models/subscription";
export default Route.extend({ export default Route.extend({

View File

@ -1,8 +1,8 @@
import Route from "@ember/routing/route";
import UserSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/user-subscription";
import I18n from "I18n";
import { action } from "@ember/object"; import { action } from "@ember/object";
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import I18n from "I18n";
import UserSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/user-subscription";
export default Route.extend({ export default Route.extend({
dialog: service(), dialog: service(),

View File

@ -1,11 +1,14 @@
import Route from "@ember/routing/route"; import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
export default Route.extend({ export default Route.extend({
router: service(),
templateName: "user/billing", templateName: "user/billing",
setupController(controller, model) { setupController(controller, model) {
if (this.currentUser.id !== this.modelFor("user").id) { if (this.currentUser.id !== this.modelFor("user").id) {
this.replaceWith("userActivity"); this.router.replaceWith("userActivity");
} else { } else {
controller.setProperties({ model }); controller.setProperties({ model });
} }

View File

@ -1,12 +1,10 @@
<DSection {{body-class "user-billing-page"}}
@pageClass="user-billing"
@class="user-secondary-navigation" <section class="user-secondary-navigation">
@scrollTop="false"
>
<MobileNav <MobileNav
@class="activity-nav"
@desktopClass="action-list nav-stacked" @desktopClass="action-list nav-stacked"
@currentPath={{router._router.currentPath}} @currentPath={{router._router.currentPath}}
class="activity-nav"
> >
<li> <li>
<LinkTo @route="user.billing.subscriptions"> <LinkTo @route="user.billing.subscriptions">
@ -20,7 +18,7 @@
</LinkTo> </LinkTo>
</li> </li>
</MobileNav> </MobileNav>
</DSection> </section>
<section class="user-content"> <section class="user-content">
{{outlet}} {{outlet}}

View File

@ -90,14 +90,14 @@ def import_subscriptions(procourse_import)
product_ids = DiscourseSubscriptions::Product.all.pluck(:external_id) product_ids = DiscourseSubscriptions::Product.all.pluck(:external_id)
all_customers = get_stripe_customers all_customers = get_stripe_customers
puts "Total available Stripe Customers: #{all_customers.length.to_s}, the first of which is customer id: #{all_customers[0][:description]}" puts "Total available Stripe Customers: #{all_customers.length}, the first of which is customer id: #{all_customers[0][:description]}"
subscriptions = get_stripe_subscriptions subscriptions = get_stripe_subscriptions
puts "Total Active Subscriptions available: #{subscriptions.length.to_s}" puts "Total Active Subscriptions available: #{subscriptions.length}"
subscriptions_for_products = subscriptions_for_products =
subscriptions.select { |sub| product_ids.include?(sub[:items][:data][0][:price][:product]) } subscriptions.select { |sub| product_ids.include?(sub[:items][:data][0][:price][:product]) }
puts "Total Subscriptions matching Products to Import: #{subscriptions_for_products.length.to_s}" puts "Total Subscriptions matching Products to Import: #{subscriptions_for_products.length}"
subscriptions_for_products.each do |subscription| subscriptions_for_products.each do |subscription|
product_id = subscription[:items][:data][0][:plan][:product] product_id = subscription[:items][:data][0][:plan][:product]

View File

@ -1,10 +1,10 @@
{ {
"name": "discourse-subscriptions", "name": "discourse-subscriptions",
"version": "1.0.0", "private": true,
"repository": "https://github.com/discourse/discourse-subscriptions",
"author": "Discourse",
"license": "MIT",
"devDependencies": { "devDependencies": {
"eslint-config-discourse": "^3.4.0" "@discourse/lint-configs": "^1.3.5",
"ember-template-lint": "^5.13.0",
"eslint": "^8.56.0",
"prettier": "^2.8.8"
} }
} }

View File

@ -6,7 +6,6 @@
# version: 2.8.1 # version: 2.8.1
# url: https://github.com/discourse/discourse-subscriptions # url: https://github.com/discourse/discourse-subscriptions
# authors: Rimian Perkins, Justin DiRose # authors: Rimian Perkins, Justin DiRose
# transpile_js: true
enabled_site_setting :discourse_subscriptions_enabled enabled_site_setting :discourse_subscriptions_enabled

View File

@ -2,8 +2,7 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::Customer do
RSpec.describe Customer do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
let(:stripe_customer) { { id: "cus_id4567" } } let(:stripe_customer) { { id: "cus_id4567" } }
@ -23,4 +22,3 @@ module DiscourseSubscriptions
expect(customer.customer_id).to eq "cus_id4567" expect(customer.customer_id).to eq "cus_id4567"
end end
end end
end

View File

@ -2,12 +2,9 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::Admin::CouponsController do
RSpec.describe Admin::CouponsController do
it "is a subclass of AdminController" do it "is a subclass of AdminController" do
expect(DiscourseSubscriptions::Admin::CouponsController < ::Admin::AdminController).to eq( expect(DiscourseSubscriptions::Admin::CouponsController < ::Admin::AdminController).to eq(true)
true,
)
end end
context "when unauthenticated" do context "when unauthenticated" do
@ -86,4 +83,3 @@ module DiscourseSubscriptions
end end
end end
end end
end

View File

@ -2,13 +2,9 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::Admin::PlansController do
module Admin
RSpec.describe PlansController do
it "is a subclass of AdminController" do it "is a subclass of AdminController" do
expect(DiscourseSubscriptions::Admin::PlansController < ::Admin::AdminController).to eq( expect(DiscourseSubscriptions::Admin::PlansController < ::Admin::AdminController).to eq(true)
true,
)
end end
context "when not authenticated" do context "when not authenticated" do
@ -170,5 +166,3 @@ module DiscourseSubscriptions
end end
end end
end end
end
end

View File

@ -2,13 +2,9 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::Admin::ProductsController do
module Admin
RSpec.describe ProductsController do
it "is a subclass of AdminController" do it "is a subclass of AdminController" do
expect(DiscourseSubscriptions::Admin::ProductsController < ::Admin::AdminController).to eq( expect(DiscourseSubscriptions::Admin::ProductsController < ::Admin::AdminController).to eq(true)
true,
)
end end
context "when unauthenticated" do context "when unauthenticated" do
@ -130,5 +126,3 @@ module DiscourseSubscriptions
end end
end end
end end
end
end

View File

@ -2,12 +2,11 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::Admin::SubscriptionsController do
RSpec.describe Admin::SubscriptionsController do
it "is a subclass of AdminController" do it "is a subclass of AdminController" do
expect( expect(DiscourseSubscriptions::Admin::SubscriptionsController < ::Admin::AdminController).to eq(
DiscourseSubscriptions::Admin::SubscriptionsController < ::Admin::AdminController, true,
).to eq(true) )
end end
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
@ -140,4 +139,3 @@ module DiscourseSubscriptions
end end
end end
end end
end

View File

@ -2,8 +2,7 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::AdminController do
RSpec.describe AdminController do
let(:admin) { Fabricate(:admin) } let(:admin) { Fabricate(:admin) }
before { sign_in(admin) } before { sign_in(admin) }
@ -17,4 +16,3 @@ module DiscourseSubscriptions
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
end end
end

View File

@ -2,11 +2,10 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::HooksController do
RSpec.describe HooksController do
before { SiteSetting.discourse_subscriptions_webhook_secret = "zascharoo" } before { SiteSetting.discourse_subscriptions_webhook_secret = "zascharoo" }
it "contructs a webhook event" do it "constructs a webhook event" do
payload = "we-want-a-shrubbery" payload = "we-want-a-shrubbery"
headers = { HTTP_STRIPE_SIGNATURE: "stripe-webhook-signature" } headers = { HTTP_STRIPE_SIGNATURE: "stripe-webhook-signature" }
@ -93,9 +92,7 @@ module DiscourseSubscriptions
end end
it "deletes the customer" do it "deletes the customer" do
expect { post "/s/hooks.json" }.to change { DiscourseSubscriptions::Customer.count }.by( expect { post "/s/hooks.json" }.to change { DiscourseSubscriptions::Customer.count }.by(-1)
-1,
)
expect(response.status).to eq 200 expect(response.status).to eq 200
end end
@ -108,4 +105,3 @@ module DiscourseSubscriptions
end end
end end
end end
end

View File

@ -2,14 +2,9 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::SubscribeController do
RSpec.describe SubscribeController do let(:user) { Fabricate(:user) }
let (:user) { let(:campaign_user) { Fabricate(:user) }
Fabricate(:user)
}
let (:campaign_user) {
Fabricate(:user)
}
context "when showing products" do context "when showing products" do
let(:product) do let(:product) do
@ -316,10 +311,7 @@ module DiscourseSubscriptions
context "with customer name & address" do context "with customer name & address" do
it "creates a customer & subscription when a customer address is provided" do it "creates a customer & subscription when a customer address is provided" do
::Stripe::Price.expects(:retrieve).returns(type: "recurring", metadata: {}) ::Stripe::Price.expects(:retrieve).returns(type: "recurring", metadata: {})
::Stripe::Subscription.expects(:create).returns( ::Stripe::Subscription.expects(:create).returns(status: "active", customer: "cus_1234")
status: "active",
customer: "cus_1234",
)
expect { expect {
post "/s/create.json", post "/s/create.json",
params: { params: {
@ -572,4 +564,3 @@ module DiscourseSubscriptions
end end
end end
end end
end

View File

@ -2,8 +2,7 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::User::PaymentsController do
RSpec.describe User::PaymentsController do
it "is a subclass of ApplicationController" do it "is a subclass of ApplicationController" do
expect(DiscourseSubscriptions::User::PaymentsController < ::ApplicationController).to eq(true) expect(DiscourseSubscriptions::User::PaymentsController < ::ApplicationController).to eq(true)
end end
@ -61,4 +60,3 @@ module DiscourseSubscriptions
end end
end end
end end
end

View File

@ -2,8 +2,7 @@
require "rails_helper" require "rails_helper"
module DiscourseSubscriptions RSpec.describe DiscourseSubscriptions::User::SubscriptionsController do
RSpec.describe User::SubscriptionsController do
it "is a subclass of ApplicationController" do it "is a subclass of ApplicationController" do
expect(DiscourseSubscriptions::User::SubscriptionsController < ::ApplicationController).to eq( expect(DiscourseSubscriptions::User::SubscriptionsController < ::ApplicationController).to eq(
true, true,
@ -104,4 +103,3 @@ module DiscourseSubscriptions
end end
end end
end end
end

View File

@ -11,6 +11,7 @@ describe SiteSerializer do
SiteSetting.discourse_subscriptions_enabled = true SiteSetting.discourse_subscriptions_enabled = true
SiteSetting.discourse_subscriptions_campaign_enabled = true SiteSetting.discourse_subscriptions_campaign_enabled = true
end end
it "is false if the goal_met date is < 7 days old" do it "is false if the goal_met date is < 7 days old" do
Discourse.redis.set("subscriptions_goal_met_date", 10.days.ago) Discourse.redis.set("subscriptions_goal_met_date", 10.days.ago)
data = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json data = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json

View File

@ -4,12 +4,8 @@ require "rails_helper"
describe DiscourseSubscriptions::Campaign do describe DiscourseSubscriptions::Campaign do
describe "campaign data is refreshed" do describe "campaign data is refreshed" do
let (:user) { let(:user) { Fabricate(:user) }
Fabricate(:user) let(:user2) { Fabricate(:user) }
}
let (:user2) {
Fabricate(:user)
}
let(:subscription) do let(:subscription) do
{ {
id: "sub_1234", id: "sub_1234",

View File

@ -1,7 +1,7 @@
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
import { visit } from "@ember/test-helpers"; import { visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
acceptance("Discourse Subscriptions", function (needs) { acceptance("Discourse Subscriptions", function (needs) {
needs.user(); needs.user();

View File

@ -1,8 +1,8 @@
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
import { click, visit } from "@ember/test-helpers"; import { click, visit } from "@ember/test-helpers";
import { test } from "qunit"; import { test } from "qunit";
import pretender, { response } from "discourse/tests/helpers/create-pretender"; import pretender, { response } from "discourse/tests/helpers/create-pretender";
import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
import { stubStripe } from "discourse/plugins/discourse-subscriptions/helpers/stripe";
function singleProductPretender() { function singleProductPretender() {
pretender.get("/s", () => { pretender.get("/s", () => {

View File

@ -1,8 +1,8 @@
import { count, discourseModule } from "discourse/tests/helpers/qunit-helpers"; import hbs from "htmlbars-inline-precompile";
import componentTest, { import componentTest, {
setupRenderingTest, setupRenderingTest,
} from "discourse/tests/helpers/component-test"; } from "discourse/tests/helpers/component-test";
import hbs from "htmlbars-inline-precompile"; import { count, discourseModule } from "discourse/tests/helpers/qunit-helpers";
discourseModule("payment-options", function (hooks) { discourseModule("payment-options", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);

View File

@ -1,12 +1,12 @@
import hbs from "htmlbars-inline-precompile";
import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import { import {
count, count,
discourseModule, discourseModule,
query, query,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import hbs from "htmlbars-inline-precompile";
discourseModule("payment-plan", function (hooks) { discourseModule("payment-plan", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);

1777
yarn.lock

File diff suppressed because it is too large Load Diff