chore(rubocop): fix Rails/RootPathnameMethods and assimiled cops
This commit is contained in:
parent
6a3fd8fc4d
commit
b273e7b67e
8 changed files with 19 additions and 8 deletions
|
@ -1152,6 +1152,12 @@ Style/EvenOdd:
|
|||
Style/ExpandPathArguments:
|
||||
Enabled: true
|
||||
|
||||
Style/FileRead:
|
||||
Enabled: true
|
||||
|
||||
Style/FileWrite:
|
||||
Enabled: true
|
||||
|
||||
Style/For:
|
||||
Enabled: true
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class PingController < ApplicationController
|
||||
def index
|
||||
Rails.logger.silence do
|
||||
status_code = if File.file?(Rails.root.join("maintenance"))
|
||||
status_code = if Rails.root.join("maintenance").file?
|
||||
# See https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-http-check%20disable-on-404
|
||||
:not_found
|
||||
elsif (ActiveRecord::Base.connection.execute('select 1 as test;').first['test'] == 1)
|
||||
|
|
|
@ -19,7 +19,7 @@ class ZxcvbnService
|
|||
#
|
||||
# This is slow: loading and parsing the dictionary may take around 1s.
|
||||
def build_tester
|
||||
dictionaries = YAML.safe_load(File.read(Rails.root.join("config", "initializers", "zxcvbn_dictionnaries.yaml")))
|
||||
dictionaries = YAML.safe_load(Rails.root.join("config", "initializers", "zxcvbn_dictionnaries.yaml").read)
|
||||
|
||||
tester = Zxcvbn::Tester.new
|
||||
tester.add_word_lists(dictionaries)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
Dir[File.join(Rails.root, "lib", "core_ext", "*.rb")].each do |core_ext_file|
|
||||
Dir[Rails.root.join("lib", "core_ext", "*.rb")].each do |core_ext_file|
|
||||
require core_ext_file
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace :after_party do
|
|||
coll_label = collectivite.labels.find_or_initialize_by(designated_on: Date.parse('1977-07-30'))
|
||||
coll_label.update(name: 'Collectivité territoriale')
|
||||
|
||||
config = Psych.safe_load(File.read(Rails.root.join("config", "zones.yml")))
|
||||
config = Psych.safe_load(Rails.root.join("config", "zones.yml").read)
|
||||
config["ministeres"].each do |ministere|
|
||||
acronym = ministere.keys.first
|
||||
zone = Zone.find_or_create_by!(acronym: acronym)
|
||||
|
|
|
@ -13,8 +13,13 @@ describe PingController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when a maintenance file is present' do
|
||||
let(:filepath) { Rails.root.join('maintenance') }
|
||||
before do
|
||||
allow(File).to receive(:file?).and_return(true)
|
||||
filepath.write("")
|
||||
end
|
||||
|
||||
after do
|
||||
filepath.delete
|
||||
end
|
||||
|
||||
it 'tells HAProxy that the app is in maintenance, but will be available again soon' do
|
||||
|
|
|
@ -6,7 +6,7 @@ describe WebhookController, type: :controller do
|
|||
|
||||
describe '#helpscout_support_dev' do
|
||||
subject(:response) { post :helpscout_support_dev, params: payload }
|
||||
let(:payload) { JSON.parse(File.read(Rails.root.join('spec', 'fixtures', 'files', 'helpscout', 'tagged-dev.json'))) }
|
||||
let(:payload) { JSON.parse(Rails.root.join('spec', 'fixtures', 'files', 'helpscout', 'tagged-dev.json').read) }
|
||||
let(:webhook_url) { "https://notification_url" }
|
||||
it 'works' do
|
||||
allow(Rails.application.secrets).to receive(:dig).with(:mattermost, :support_webhook_url).and_return(webhook_url)
|
||||
|
@ -68,7 +68,7 @@ describe WebhookController, type: :controller do
|
|||
|
||||
describe '#sendinblue' do
|
||||
subject(:response) { post :sendinblue, params: payload }
|
||||
let(:payload) { JSON.parse(File.read(Rails.root.join('spec', 'fixtures', 'files', 'sendinblue', 'incident.json'))) }
|
||||
let(:payload) { JSON.parse(Rails.root.join('spec', 'fixtures', 'files', 'sendinblue', 'incident.json').read) }
|
||||
|
||||
it 'sends notification to mattermost' do
|
||||
notification_url = "https://notification_url"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
describe 'graphql' do
|
||||
let(:current_defn) { API::V2::Schema.to_definition }
|
||||
let(:printout_defn) { File.read(Rails.root.join('app', 'graphql', 'schema.graphql')) }
|
||||
let(:printout_defn) { Rails.root.join('app', 'graphql', 'schema.graphql').read }
|
||||
|
||||
it "update the printed schema with `bin/rake graphql:schema:idl`" do
|
||||
result = GraphQL::SchemaComparator.compare(current_defn, printout_defn)
|
||||
|
|
Loading…
Reference in a new issue