diff --git a/.rubocop.yml b/.rubocop.yml index 7cef58f1e..10eb93318 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -224,7 +224,7 @@ Layout/SpaceAroundOperators: Enabled: true Layout/SpaceBeforeBlockBraces: - Enabled: false + Enabled: true Layout/SpaceBeforeComma: Enabled: true diff --git a/app/controllers/api/v1/dossiers_controller.rb b/app/controllers/api/v1/dossiers_controller.rb index b522e3aca..68cc51c41 100644 --- a/app/controllers/api/v1/dossiers_controller.rb +++ b/app/controllers/api/v1/dossiers_controller.rb @@ -6,7 +6,7 @@ class API::V1::DossiersController < APIController def index dossiers = @dossiers.page(params[:page]).per(per_page) - render json: { dossiers: dossiers.map{ |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200 + render json: { dossiers: dossiers.map { |dossier| DossiersSerializer.new(dossier) }, pagination: pagination(dossiers) }, status: 200 rescue ActiveRecord::RecordNotFound render json: {}, status: 404 end diff --git a/app/models/drop_down_list.rb b/app/models/drop_down_list.rb index cc91f8611..b9b4e9a20 100644 --- a/app/models/drop_down_list.rb +++ b/app/models/drop_down_list.rb @@ -7,7 +7,7 @@ class DropDownList < ApplicationRecord end def disabled_options - options.select{ |v| (v =~ /^--.*--$/).present? } + options.select { |v| (v =~ /^--.*--$/).present? } end def selected_options(champ) diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 1798ece76..d06e1ece6 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -46,7 +46,7 @@ class ProcedurePresentation < ApplicationRecord ) end - explanatory_types_de_champ = [:header_section, :explication].map{ |k| TypeDeChamp.type_champs.fetch(k) } + explanatory_types_de_champ = [:header_section, :explication].map { |k| TypeDeChamp.type_champs.fetch(k) } fields.concat procedure.types_de_champ .reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) } diff --git a/app/uploaders/commentaire_file_uploader.rb b/app/uploaders/commentaire_file_uploader.rb index eaa738b14..1249c94c5 100644 --- a/app/uploaders/commentaire_file_uploader.rb +++ b/app/uploaders/commentaire_file_uploader.rb @@ -18,6 +18,6 @@ class CommentaireFileUploader < BaseUploader end def accept_extension_list - extension_white_list.map{ |e| ".#{e}" }.join(",") + extension_white_list.map { |e| ".#{e}" }.join(",") end end diff --git a/lib/tasks/2017_07_18_clean_followed_dossiers.rake b/lib/tasks/2017_07_18_clean_followed_dossiers.rake index 89058da02..2c9a5f4ce 100644 --- a/lib/tasks/2017_07_18_clean_followed_dossiers.rake +++ b/lib/tasks/2017_07_18_clean_followed_dossiers.rake @@ -3,7 +3,7 @@ namespace :'2017_07_18_clean_followed_dossiers' do Follow.where(gestionnaire_id: nil).destroy_all Follow.where(dossier_id: nil).destroy_all - duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select{ |_gestionnaire_id_dossier_id, count| count > 1 }.keys + duplicate_follows = Follow.group('gestionnaire_id', 'dossier_id').count.select { |_gestionnaire_id_dossier_id, count| count > 1 }.keys duplicate_ids = duplicate_follows.map { |gestionnaire_id, dossier_id| Follow.where(gestionnaire_id: gestionnaire_id, dossier_id: dossier_id).pluck(:id) } diff --git a/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake b/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake index 659d37633..caa4c674f 100644 --- a/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake +++ b/lib/tasks/2017_07_26_clean_birthdate_on_individual.rake @@ -3,7 +3,7 @@ require Rails.root.join("lib", "tasks", "task_helper") namespace :'2017_07_26_clean_birthdate_on_individual' do task clean: :environment do # remove duplicates - duplicate_individuals = Individual.group("dossier_id").count.select{ |_dossier_id, count| count > 1 }.keys + duplicate_individuals = Individual.group("dossier_id").count.select { |_dossier_id, count| count > 1 }.keys duplicate_individuals.each { |dossier_id| Individual.where(dossier_id: dossier_id, nom: nil).delete_all } # Match "" => nil diff --git a/lib/tasks/2017_08_01_clean_assign_to.rake b/lib/tasks/2017_08_01_clean_assign_to.rake index fd407a956..bbc2d86dd 100644 --- a/lib/tasks/2017_08_01_clean_assign_to.rake +++ b/lib/tasks/2017_08_01_clean_assign_to.rake @@ -1,6 +1,6 @@ namespace :'2017_08_01_clean_assign_to' do task clean: :environment do - duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select{ |_gestionnaire_id_procedure_id, count| count > 1 }.keys + duplicates = AssignTo.group(:gestionnaire_id, :procedure_id).count.select { |_gestionnaire_id_procedure_id, count| count > 1 }.keys duplicate_ids = duplicates.map { |gestionnaire_id, procedure_id| AssignTo.where(gestionnaire_id: gestionnaire_id, procedure_id: procedure_id).pluck(:id) } diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index d6d7b5ffe..10c7f2828 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -134,7 +134,7 @@ describe Admin::ProceduresController, type: :controller do subject { delete :destroy, params: { id: procedure_not_owned.id } } - it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) } + it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) } end end @@ -511,7 +511,7 @@ describe Admin::ProceduresController, type: :controller do subject { get :new_from_existing } let(:grouped_procedures) { subject; assigns(:grouped_procedures) } - let(:response_procedures) { grouped_procedures.map{ |o, procedures| procedures }.flatten } + let(:response_procedures) { grouped_procedures.map { |o, procedures| procedures }.flatten } describe 'selecting' do let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) } @@ -542,8 +542,8 @@ describe Admin::ProceduresController, type: :controller do it 'groups procedures with services as well as procedures with organisations' do expect(grouped_procedures.length).to eq 2 - expect(grouped_procedures.find{ |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1) - expect(grouped_procedures.find{ |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service) + expect(grouped_procedures.find { |o, p| o == 'DDT des Vosges' }.last).to contain_exactly(procedure_with_service_1) + expect(grouped_procedures.find { |o, p| o == 'DDT du Loiret' }.last).to contain_exactly(procedure_with_service_2, procedure_without_service) end end end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 0fc0ec700..0545d786b 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -5,7 +5,7 @@ describe ApplicationController, type: :controller do it 'is present' do before_actions = ApplicationController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:set_raven_context) diff --git a/spec/controllers/manager/administrateurs_controller_spec.rb b/spec/controllers/manager/administrateurs_controller_spec.rb index 432aa9daa..fb72fb129 100644 --- a/spec/controllers/manager/administrateurs_controller_spec.rb +++ b/spec/controllers/manager/administrateurs_controller_spec.rb @@ -1,5 +1,5 @@ describe Manager::AdministrateursController, type: :controller do - let(:administration){ create(:administration) } + let(:administration) { create(:administration) } describe 'POST #create' do let(:email) { 'plop@plop.com' } diff --git a/spec/controllers/new_administrateur/administrateur_controller_spec.rb b/spec/controllers/new_administrateur/administrateur_controller_spec.rb index 81ac03e93..6dbd65ffd 100644 --- a/spec/controllers/new_administrateur/administrateur_controller_spec.rb +++ b/spec/controllers/new_administrateur/administrateur_controller_spec.rb @@ -3,7 +3,7 @@ describe NewAdministrateur::AdministrateurController, type: :controller do it 'is present' do before_actions = NewAdministrateur::AdministrateurController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_administrateur!) diff --git a/spec/controllers/new_administrateur/services_controller_spec.rb b/spec/controllers/new_administrateur/services_controller_spec.rb index bddd7f679..081603342 100644 --- a/spec/controllers/new_administrateur/services_controller_spec.rb +++ b/spec/controllers/new_administrateur/services_controller_spec.rb @@ -118,7 +118,7 @@ describe NewAdministrateur::ServicesController, type: :controller do delete :destroy, params: { id: service.id, procedure_id: 12 } end - it { expect{ service.reload }.to raise_error(ActiveRecord::RecordNotFound) } + it { expect { service.reload }.to raise_error(ActiveRecord::RecordNotFound) } it { expect(flash.alert).to be_nil } it { expect(flash.notice).to eq("#{service.nom} est supprimé") } it { expect(response).to redirect_to(services_path(procedure_id: 12)) } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 8221c6491..39c9137b5 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -412,7 +412,7 @@ describe NewGestionnaire::DossiersController, type: :controller do subject { delete :purge_champ_piece_justificative, params: { procedure_id: champ.dossier.procedure.id, dossier_id: champ.dossier.id, champ_id: champ.id }, format: :js } context 'when gestionnaire can process dossier' do - let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id, private: true) } it { is_expected.to have_http_status(200) } @@ -422,7 +422,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end context 'but champ is not linked to this dossier' do - let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier), private: true) } + let(:champ) { create(:champ_piece_justificative, dossier: create(:dossier), private: true) } it { is_expected.to redirect_to(root_path) } @@ -434,8 +434,8 @@ describe NewGestionnaire::DossiersController, type: :controller do end context 'when gestionnaire cannot process dossier' do - let(:dossier){ create(:dossier, procedure: create(:procedure)) } - let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id, private: true) } + let(:dossier) { create(:dossier, procedure: create(:procedure)) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id, private: true) } it { is_expected.to redirect_to(root_path) } diff --git a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb index 83c189582..36a31b204 100644 --- a/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/gestionnaire_controller_spec.rb @@ -5,7 +5,7 @@ describe NewGestionnaire::GestionnaireController, type: :controller do it 'is present' do before_actions = NewGestionnaire::GestionnaireController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_gestionnaire!) diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index d89d73871..772a9bcff 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -5,7 +5,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do it "is present" do before_actions = NewGestionnaire::ProceduresController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:ensure_ownership!) @@ -46,7 +46,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do it "is present" do before_actions = NewGestionnaire::ProceduresController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:redirect_to_avis_if_needed) @@ -253,10 +253,10 @@ describe NewGestionnaire::ProceduresController, type: :controller do end describe 'statut' do - let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } } - let!(:new_followed_dossier) { Timecop.freeze(2.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } } - let!(:termine_dossier) { Timecop.freeze(3.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } } - let!(:archived_dossier) { Timecop.freeze(4.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } } + let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } } + let!(:new_followed_dossier) { Timecop.freeze(2.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } } + let!(:termine_dossier) { Timecop.freeze(3.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } } + let!(:archived_dossier) { Timecop.freeze(4.days.ago) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } } before do gestionnaire.followed_dossiers << new_followed_dossier diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb index d404218fc..d2e42693d 100644 --- a/spec/controllers/new_user/dossiers_controller_spec.rb +++ b/spec/controllers/new_user/dossiers_controller_spec.rb @@ -7,7 +7,7 @@ describe NewUser::DossiersController, type: :controller do it 'are present' do before_actions = NewUser::DossiersController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:ensure_ownership!, :ensure_ownership_or_invitation!, :forbid_invite_submission!) @@ -913,8 +913,8 @@ describe NewUser::DossiersController, type: :controller do subject { delete :purge_champ_piece_justificative, params: { id: champ.dossier.id, champ_id: champ.id }, format: :js } context 'when dossier is owned by user' do - let(:dossier){ create(:dossier, user: user) } - let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) } + let(:dossier) { create(:dossier, user: user) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) } it { is_expected.to have_http_status(200) } @@ -924,7 +924,7 @@ describe NewUser::DossiersController, type: :controller do end context 'but champ is not linked to this dossier' do - let(:champ){ create(:champ_piece_justificative, dossier: create(:dossier)) } + let(:champ) { create(:champ_piece_justificative, dossier: create(:dossier)) } it { is_expected.to redirect_to(root_path) } @@ -936,8 +936,8 @@ describe NewUser::DossiersController, type: :controller do end context 'when dossier is not owned by user' do - let(:dossier){ create(:dossier, user: create(:user)) } - let(:champ){ create(:champ_piece_justificative, dossier_id: dossier.id) } + let(:dossier) { create(:dossier, user: create(:user)) } + let(:champ) { create(:champ_piece_justificative, dossier_id: dossier.id) } it { is_expected.to redirect_to(root_path) } diff --git a/spec/controllers/new_user/user_controller_spec.rb b/spec/controllers/new_user/user_controller_spec.rb index b4e93c10c..82908835d 100644 --- a/spec/controllers/new_user/user_controller_spec.rb +++ b/spec/controllers/new_user/user_controller_spec.rb @@ -5,7 +5,7 @@ describe NewUser::UserController, type: :controller do it 'is present' do before_actions = NewUser::UserController ._process_action_callbacks - .find_all{ |process_action_callbacks| process_action_callbacks.kind == :before } + .find_all { |process_action_callbacks| process_action_callbacks.kind == :before } .map(&:filter) expect(before_actions).to include(:authenticate_user!) diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 4f2632724..6fd3f5c2c 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -116,7 +116,7 @@ describe StatsController, type: :controller do create(:procedure, published_at: Time.zone.now, administrateur: administrateur_4) end - let(:association){ Procedure.all } + let(:association) { Procedure.all } subject { StatsController.new.send(:procedures_count_per_administrateur, association) } diff --git a/spec/models/avis_spec.rb b/spec/models/avis_spec.rb index c692f0d60..d55b4afd0 100644 --- a/spec/models/avis_spec.rb +++ b/spec/models/avis_spec.rb @@ -14,21 +14,21 @@ RSpec.describe Avis, type: :model do subject { avis.email_to_display } context 'when gestionnaire is not known' do - it{ is_expected.to eq(invited_email) } + it { is_expected.to eq(invited_email) } end context 'when gestionnaire is known' do let!(:avis) { create(:avis, email: nil, gestionnaire: create(:gestionnaire), dossier: create(:dossier)) } - it{ is_expected.to eq(avis.gestionnaire.email) } + it { is_expected.to eq(avis.gestionnaire.email) } end end describe '.by_latest' do context 'with 3 avis' do - let!(:avis){ create(:avis) } - let!(:avis2){ create(:avis, updated_at: 4.hours.ago) } - let!(:avis3){ create(:avis, updated_at: 3.hours.ago) } + let!(:avis) { create(:avis) } + let!(:avis2) { create(:avis, updated_at: 4.hours.ago) } + let!(:avis3) { create(:avis, updated_at: 3.hours.ago) } subject { Avis.by_latest } @@ -37,13 +37,13 @@ RSpec.describe Avis, type: :model do end describe ".link_avis_to_gestionnaire" do - let(:gestionnaire){ create(:gestionnaire) } + let(:gestionnaire) { create(:gestionnaire) } - subject{ Avis.link_avis_to_gestionnaire(gestionnaire) } + subject { Avis.link_avis_to_gestionnaire(gestionnaire) } context 'when there are 2 avis linked by email to a gestionnaire' do - let!(:avis){ create(:avis, email: gestionnaire.email, gestionnaire: nil) } - let!(:avis2){ create(:avis, email: gestionnaire.email, gestionnaire: nil) } + let!(:avis) { create(:avis, email: gestionnaire.email, gestionnaire: nil) } + let!(:avis2) { create(:avis, email: gestionnaire.email, gestionnaire: nil) } before do subject diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index a47d82206..461aa4fdb 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -385,18 +385,18 @@ describe Champ do context 'and there is a blob' do before { champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain") } - it { expect{ champ.save }.to change(VirusScan, :count).by(1) } + it { expect { champ.save }.to change(VirusScan, :count).by(1) } end context 'and there is no blob' do - it { expect{ champ.save }.to_not change(VirusScan, :count) } + it { expect { champ.save }.to_not change(VirusScan, :count) } end end context 'when type_champ is not type_de_champ_piece_justificative' do let(:type_de_champ) { create(:type_de_champ_textarea) } - it { expect{ champ.save }.to_not change(VirusScan, :count) } + it { expect { champ.save }.to_not change(VirusScan, :count) } end end diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index e24b6d353..d7556d527 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -95,14 +95,14 @@ describe Gestionnaire, type: :model do let(:procedure_to_assign) { procedure_3 } it { is_expected.to be_truthy } - it { expect{ subject }.to change(gestionnaire.procedures, :count) } + it { expect { subject }.to change(gestionnaire.procedures, :count) } end context "with an already assigned procedure" do let(:procedure_to_assign) { procedure } it { is_expected.to be_falsey } - it { expect{ subject }.not_to change(gestionnaire.procedures, :count) } + it { expect { subject }.not_to change(gestionnaire.procedures, :count) } end end diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb index 66eb762b6..1b3929b91 100644 --- a/spec/models/invite_spec.rb +++ b/spec/models/invite_spec.rb @@ -13,7 +13,7 @@ describe Invite do create(:invite, email: email1, dossier: dossier2) end - it { expect{ subject }.to change(Invite, :count).by(2) } + it { expect { subject }.to change(Invite, :count).by(2) } end context 'when an email is invite twice on a dossier' do @@ -22,7 +22,7 @@ describe Invite do create(:invite, email: email1, dossier: dossier1) end - it { expect{ subject }.to raise_error ActiveRecord::RecordInvalid } + it { expect { subject }.to raise_error ActiveRecord::RecordInvalid } end context "email validation" do diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index f4c2df6d7..355aa27e7 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -537,7 +537,7 @@ describe Procedure do end describe '#default_path' do - let(:procedure){ create(:procedure, libelle: 'A long libelle with àccênts, blabla coucou hello un deux trois voila') } + let(:procedure) { create(:procedure, libelle: 'A long libelle with àccênts, blabla coucou hello un deux trois voila') } subject { procedure.default_path } diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index adf6baefb..2a24cc89f 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -44,7 +44,7 @@ describe Service, type: :model do context 'of type_organisme' do it 'should belong to the enum' do - expect{ Service.new(params.merge(type_organisme: 'choucroute')) }.to raise_error(ArgumentError) + expect { Service.new(params.merge(type_organisme: 'choucroute')) }.to raise_error(ArgumentError) end end end