Skip to content

Commit

Permalink
DEV: Fix new Rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
Flink committed Mar 5, 2024
1 parent 84d9b1a commit c4227de
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 26 deletions.
38 changes: 31 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,45 +1,69 @@
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.1)
concurrent-ruby (~> 1.0)
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.3)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
racc (1.7.3)
rainbow (3.1.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.59.0)
rubocop (1.61.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
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)
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
Expand Down
13 changes: 13 additions & 0 deletions app/controllers/adstxt_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true
#
class AdstxtController < ::ApplicationController
requires_plugin AdPlugin.plugin_name

skip_before_action :preload_json, :check_xhr, :redirect_to_login_if_required

def index
raise Discourse::NotFound unless SiteSetting.ads_txt.present?

render plain: SiteSetting.ads_txt
end
end
22 changes: 6 additions & 16 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def self.pstore_delete(key)
end

after_initialize do
require_dependency File.expand_path("../app/models/house_ad", __FILE__)
require_dependency File.expand_path("../app/models/house_ad_setting", __FILE__)
require_dependency File.expand_path("../app/controllers/house_ads_controller", __FILE__)
require_dependency File.expand_path("../app/controllers/house_ad_settings_controller", __FILE__)
require_dependency File.expand_path("../lib/adplugin/guardian_extensions", __FILE__)
require_dependency "application_controller"
require_relative "app/models/house_ad"
require_relative "app/models/house_ad_setting"
require_relative "app/controllers/house_ads_controller"
require_relative "app/controllers/house_ad_settings_controller"
require_relative "app/controllers/adstxt_controller"
require_relative "lib/adplugin/guardian_extensions"

reloadable_patch { Guardian.prepend ::AdPlugin::GuardianExtensions }

Expand Down Expand Up @@ -75,16 +75,6 @@ def self.pstore_delete(key)
scope.show_to_groups?
end

class ::AdstxtController < ::ApplicationController
skip_before_action :preload_json, :check_xhr, :redirect_to_login_if_required

def index
raise Discourse::NotFound unless SiteSetting.ads_txt.present?

render plain: SiteSetting.ads_txt
end
end

class AdPlugin::Engine < ::Rails::Engine
engine_name "adplugin"
isolate_namespace AdPlugin
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/site_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe SiteController do
fab!(:user) { Fabricate(:user) }
fab!(:user)

let!(:anon_ad) do
AdPlugin::HouseAd.create(
Expand Down
2 changes: 1 addition & 1 deletion spec/serializer/current_user_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
fab!(:tl0_user) { Fabricate(:user, trust_level: 0, refresh_auto_groups: true) }
fab!(:tl2_user) { Fabricate(:user, trust_level: 2, refresh_auto_groups: true) }
fab!(:tl3_user) { Fabricate(:user, trust_level: 3, refresh_auto_groups: true) }
fab!(:admin) { Fabricate(:admin) }
fab!(:admin)

let(:tl0_serializer) { described_class.new(tl0_user, scope: Guardian.new(tl0_user), root: false) }

Expand Down
2 changes: 1 addition & 1 deletion spec/system/admin_house_ad_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

describe "Admin House Ad", type: :system, js: true do
fab!(:admin) { Fabricate(:admin) }
fab!(:admin)
let(:house_ad) do
AdPlugin::HouseAd.create(
name: "some-name",
Expand Down

0 comments on commit c4227de

Please sign in to comment.