From 54276b9a7d5e31c899acab774aeabe4aff3fff95 Mon Sep 17 00:00:00 2001 From: Jeff Parr Date: Fri, 19 Apr 2024 14:17:45 -0700 Subject: [PATCH] rubocop fix all --- .rubocop.yml | 2 +- .../concerns/logged_invisible_captcha.rb | 4 ++-- app/models/topic_category.rb | 6 ++---- spec/rails_helper.rb | 16 ++++++++-------- spec/requests/action_pages_spec.rb | 12 ++++++------ 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 77493af09..cf8cb7555 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,7 @@ inherit_gem: - config/rails.yml AllCops: - TargetRailsVersion: 6.1 + TargetRailsVersion: 7.0 TargetRubyVersion: 3.0 NewCops: enable SuggestExtensions: false diff --git a/app/controllers/concerns/logged_invisible_captcha.rb b/app/controllers/concerns/logged_invisible_captcha.rb index 13885594d..a2b48f633 100644 --- a/app/controllers/concerns/logged_invisible_captcha.rb +++ b/app/controllers/concerns/logged_invisible_captcha.rb @@ -3,12 +3,12 @@ module LoggedInvisibleCaptcha def on_spam(options = {}) log_failure - super options + super(options) end def on_timestamp_spam(options = {}) log_failure - super options + super(options) end def log_failure diff --git a/app/models/topic_category.rb b/app/models/topic_category.rb index a7884bf96..a6c8aff5b 100644 --- a/app/models/topic_category.rb +++ b/app/models/topic_category.rb @@ -4,11 +4,9 @@ class TopicCategory < ApplicationRecord has_many :congress_message_campaigns def as_2d_array - arr = [] - topic_sets.order(:tier).each do |ts| - arr.push ts.topics.map(&:name) + arr = topic_sets.order(:tier).map do |ts| + ts.topics.map(&:name) end - arr end def best_match(options) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a1324359a..0f3bac286 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,6 +1,6 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= "test" -require_relative '../config/environment' +require_relative "../config/environment" # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require "spec_helper" @@ -31,13 +31,13 @@ Capybara.server = :puma Capybara.register_driver :selenium_chrome_headless do |app| # Capybara::Selenium::Driver.load_selenium - browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts| - opts.args << '--window-size=1920,1080' - opts.args << '--force-device-scale-factor=0.95' - opts.args << '--headless' - opts.args << '--disable-gpu' - opts.args << '--disable-site-isolation-trials' - opts.args << '--no-sandbox' + browser_options = Selenium::WebDriver::Chrome::Options.new.tap do |opts| + opts.args << "--window-size=1920,1080" + opts.args << "--force-device-scale-factor=0.95" + opts.args << "--headless" + opts.args << "--disable-gpu" + opts.args << "--disable-site-isolation-trials" + opts.args << "--no-sandbox" end Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options) end diff --git a/spec/requests/action_pages_spec.rb b/spec/requests/action_pages_spec.rb index d0a591211..ed3d88fea 100644 --- a/spec/requests/action_pages_spec.rb +++ b/spec/requests/action_pages_spec.rb @@ -33,7 +33,7 @@ expect(response.body).to eq "1000" end end - + describe "json" do it "returns json" do FactoryBot.create(:action_page) @@ -51,9 +51,9 @@ expect(response.code).to eq "200" expect(response.parsed_body).to include(a_hash_including({ "title" => "Sample Action Page", - "featured_image"=> a_hash_including({ - "alt"=>"Test.Png", - "url"=> a_string_matching(%r{/action_pages/featured_images/([0-9]+)/([0-9]+)/([0-9]+)/original/test.png}) + "featured_image" => a_hash_including({ + "alt" => "Test.Png", + "url" => a_string_matching(%r{/action_pages/featured_images/([0-9]+)/([0-9]+)/([0-9]+)/original/test.png}) }) })) end @@ -69,8 +69,8 @@ it "returns image attributes in atom" do allow_any_instance_of(ActionPageImageUploader).to receive(:content_type).and_return("image/png") - stub_request(:get, %r{fakeimages/test.png}).to_return(status: 200, body: file_fixture("test-image.png").read, headers: {content_type: "image/png"}) - stub_request(:any, %r{/action_pages/featured_images/([0-9]+)/([0-9]+)/([0-9]+)/original/test.png}).to_return(status: 200, body: file_fixture("test-image.png").read, headers: {content_type: "image/png"}) + stub_request(:get, %r{fakeimages/test.png}).to_return(status: 200, body: file_fixture("test-image.png").read, headers: { content_type: "image/png" }) + stub_request(:any, %r{/action_pages/featured_images/([0-9]+)/([0-9]+)/([0-9]+)/original/test.png}).to_return(status: 200, body: file_fixture("test-image.png").read, headers: { content_type: "image/png" }) FactoryBot.create(:action_page, remote_featured_image_url: "https://example.com/fakeimages/test.png") get "/action.atom"