DEV: Fix new Rubocop offenses

This commit is contained in:
Loïc Guitaut 2024-03-06 14:51:25 +01:00 committed by Loïc Guitaut
parent 7b8a41ad0d
commit 87659e237b
22 changed files with 85 additions and 14 deletions

View File

@ -7,11 +7,31 @@ GIT
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.6)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
drb (2.2.1)
i18n (1.14.3)
concurrent-ruby (~> 1.0)
racc (~> 1.7)
json (2.7.1)
language_server-protocol (3.17.0.3)
minitest (5.22.2)
mutex_m (0.2.0)
parallel (1.24.0)
parser (3.3.0.4)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
@ -19,7 +39,7 @@ GEM
rainbow (3.1.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.60.0)
rubocop (1.62.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
@ -27,25 +47,30 @@ GEM
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-ast (1.31.1)
parser (>= 3.3.0.4)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-discourse (3.6.0)
rubocop-discourse (3.7.1)
activesupport (>= 6.1)
rubocop (>= 1.59.0)
rubocop-capybara (>= 2.0.0)
rubocop-factory_bot (>= 2.0.0)
rubocop-rspec (>= 2.25.0)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-rspec (2.26.1)
rubocop-rspec (2.27.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)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
PLATFORMS

View File

@ -5,6 +5,9 @@ module DiscourseSubscriptions
class CouponsController < ::Admin::AdminController
include DiscourseSubscriptions::Stripe
include DiscourseSubscriptions::Group
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
before_action :set_api_key
def index

View File

@ -5,6 +5,8 @@ module DiscourseSubscriptions
class PlansController < ::Admin::AdminController
include DiscourseSubscriptions::Stripe
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
before_action :set_api_key
def index

View File

@ -5,6 +5,8 @@ module DiscourseSubscriptions
class ProductsController < ::Admin::AdminController
include DiscourseSubscriptions::Stripe
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
before_action :set_api_key
def index

View File

@ -3,6 +3,8 @@
module DiscourseSubscriptions
module Admin
class SubscriptionsController < ::Admin::AdminController
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
include DiscourseSubscriptions::Stripe
include DiscourseSubscriptions::Group
before_action :set_api_key

View File

@ -2,6 +2,8 @@
module DiscourseSubscriptions
class AdminController < ::Admin::AdminController
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
def index
head 200
end

View File

@ -5,6 +5,8 @@ module DiscourseSubscriptions
include DiscourseSubscriptions::Group
include DiscourseSubscriptions::Stripe
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
layout false
skip_before_action :check_xhr

View File

@ -4,6 +4,9 @@ module DiscourseSubscriptions
class SubscribeController < ::ApplicationController
include DiscourseSubscriptions::Stripe
include DiscourseSubscriptions::Group
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
before_action :set_api_key
requires_login except: %i[index contributors show]

View File

@ -4,6 +4,9 @@ module DiscourseSubscriptions
module User
class PaymentsController < ::ApplicationController
include DiscourseSubscriptions::Stripe
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
before_action :set_api_key
requires_login

View File

@ -5,6 +5,9 @@ module DiscourseSubscriptions
class SubscriptionsController < ::ApplicationController
include DiscourseSubscriptions::Stripe
include DiscourseSubscriptions::Group
requires_plugin DiscourseSubscriptions::PLUGIN_NAME
before_action :set_api_key
requires_login

View File

@ -54,9 +54,13 @@ Discourse::Application.routes.append do
}
end
load File.expand_path("lib/discourse_subscriptions/engine.rb", __dir__)
load File.expand_path("app/controllers/concerns/stripe.rb", __dir__)
load File.expand_path("app/controllers/concerns/group.rb", __dir__)
module ::DiscourseSubscriptions
PLUGIN_NAME = "discourse-subscriptions"
end
require_relative "lib/discourse_subscriptions/engine"
require_relative "app/controllers/concerns/stripe"
require_relative "app/controllers/concerns/group"
after_initialize do
::Stripe.api_version = "2020-08-27"

View File

@ -3,6 +3,8 @@
require "rails_helper"
RSpec.describe DiscourseSubscriptions::Admin::CouponsController do
before { SiteSetting.discourse_subscriptions_enabled = true }
it "is a subclass of AdminController" do
expect(DiscourseSubscriptions::Admin::CouponsController < ::Admin::AdminController).to eq(true)
end

View File

@ -3,6 +3,8 @@
require "rails_helper"
RSpec.describe DiscourseSubscriptions::Admin::PlansController do
before { SiteSetting.discourse_subscriptions_enabled = true }
it "is a subclass of AdminController" do
expect(DiscourseSubscriptions::Admin::PlansController < ::Admin::AdminController).to eq(true)
end

View File

@ -3,6 +3,8 @@
require "rails_helper"
RSpec.describe DiscourseSubscriptions::Admin::ProductsController do
before { SiteSetting.discourse_subscriptions_enabled = true }
it "is a subclass of AdminController" do
expect(DiscourseSubscriptions::Admin::ProductsController < ::Admin::AdminController).to eq(true)
end

View File

@ -3,6 +3,8 @@
require "rails_helper"
RSpec.describe DiscourseSubscriptions::Admin::SubscriptionsController do
before { SiteSetting.discourse_subscriptions_enabled = true }
it "is a subclass of AdminController" do
expect(DiscourseSubscriptions::Admin::SubscriptionsController < ::Admin::AdminController).to eq(
true,

View File

@ -5,7 +5,10 @@ require "rails_helper"
RSpec.describe DiscourseSubscriptions::AdminController do
let(:admin) { Fabricate(:admin) }
before { sign_in(admin) }
before do
sign_in(admin)
SiteSetting.discourse_subscriptions_enabled = true
end
it "is a subclass of AdminController" do
expect(DiscourseSubscriptions::AdminController < ::Admin::AdminController).to eq(true)

View File

@ -3,7 +3,10 @@
require "rails_helper"
RSpec.describe DiscourseSubscriptions::HooksController do
before { SiteSetting.discourse_subscriptions_webhook_secret = "zascharoo" }
before do
SiteSetting.discourse_subscriptions_webhook_secret = "zascharoo"
SiteSetting.discourse_subscriptions_enabled = true
end
it "constructs a webhook event" do
payload = "we-want-a-shrubbery"

View File

@ -6,6 +6,8 @@ RSpec.describe DiscourseSubscriptions::SubscribeController do
let(:user) { Fabricate(:user) }
let(:campaign_user) { Fabricate(:user) }
before { SiteSetting.discourse_subscriptions_enabled = true }
context "when showing products" do
let(:product) do
{

View File

@ -3,6 +3,8 @@
require "rails_helper"
RSpec.describe DiscourseSubscriptions::User::PaymentsController do
before { SiteSetting.discourse_subscriptions_enabled = true }
it "is a subclass of ApplicationController" do
expect(DiscourseSubscriptions::User::PaymentsController < ::ApplicationController).to eq(true)
end

View File

@ -3,6 +3,8 @@
require "rails_helper"
RSpec.describe DiscourseSubscriptions::User::SubscriptionsController do
before { SiteSetting.discourse_subscriptions_enabled = true }
it "is a subclass of ApplicationController" do
expect(DiscourseSubscriptions::User::SubscriptionsController < ::ApplicationController).to eq(
true,

View File

@ -3,7 +3,7 @@
require "rails_helper"
describe SiteSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:user)
let(:guardian) { Guardian.new(user) }
before do

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
describe "Subscription products", type: :system do
fab!(:admin) { Fabricate(:admin) }
fab!(:admin)
fab!(:product) { Fabricate(:product, external_id: "prod_OiKyO6ZMFCIhQa") }
before { SiteSetting.discourse_subscriptions_enabled = true }