diff --git a/.rubocop.yml b/.rubocop.yml index 7f6109c35..fe31ef760 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -131,7 +131,7 @@ Layout/MultilineAssignmentLayout: Enabled: false Layout/MultilineBlockLayout: - Enabled: false + Enabled: true Layout/MultilineHashBraceLayout: Enabled: false diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index d38758eec..f54444e12 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -208,15 +208,20 @@ class Admin::ProceduresController < AdminController end def path_list - render json: ProcedurePath - .joins(', procedures') - .where("procedures.id = procedure_paths.procedure_id") - .where("procedures.archived_at" => nil) - .where("path LIKE ?", "%#{params[:request]}%") - .pluck(:path, :administrateur_id) - .inject([]) { - |acc, value| acc.push({label: value.first, mine: value.second == current_administrateur.id}) - }.to_json + json_path_list = ProcedurePath + .joins(', procedures') + .where("procedures.id = procedure_paths.procedure_id") + .where("procedures.archived_at" => nil) + .where("path LIKE ?", "%#{params[:request]}%") + .pluck(:path, :administrateur_id) + .map do |value| + { + label: value.first, + mine: value.second == current_administrateur.id + } + end.to_json + + render json: json_path_list end private diff --git a/app/controllers/ban/search_controller.rb b/app/controllers/ban/search_controller.rb index 294ad0cc4..ec079347c 100644 --- a/app/controllers/ban/search_controller.rb +++ b/app/controllers/ban/search_controller.rb @@ -2,9 +2,11 @@ class Ban::SearchController < ApplicationController def get request = params[:request] - render json: Carto::Bano::AddressRetriever.new(request).list.inject([]) { - |acc, value| acc.push({label: value}) - }.to_json + json = Carto::Bano::AddressRetriever.new(request).list.map do |value| + { label: value } + end.to_json + + render json: json end def get_address_point diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index fa0fe0008..266babaad 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -200,8 +200,7 @@ describe API::V1::DossiersController do end describe 'champs' do - let(:field_list) { [:url] - } + let(:field_list) { [:url] } subject { super()[:champs] } it { expect(subject.length).to eq 1 } diff --git a/spec/features/france_connect/france_connect_particulier_spec.rb b/spec/features/france_connect/france_connect_particulier_spec.rb index 7f1b263af..41b57d27f 100644 --- a/spec/features/france_connect/france_connect_particulier_spec.rb +++ b/spec/features/france_connect/france_connect_particulier_spec.rb @@ -35,15 +35,16 @@ feature 'France Connect Particulier Connexion' do let(:code) { 'plop' } context 'when authentification is ok' do - let(:france_connect_information) { create(:france_connect_information, - france_connect_particulier_id: france_connect_particulier_id, - given_name: given_name, - family_name: family_name, - birthdate: birthdate, - birthplace: birthplace, - gender: gender, - email_france_connect: email) - } + let(:france_connect_information) do + create(:france_connect_information, + france_connect_particulier_id: france_connect_particulier_id, + given_name: given_name, + family_name: family_name, + birthdate: birthdate, + birthplace: birthplace, + gender: gender, + email_france_connect: email) + end before do allow_any_instance_of(FranceConnectParticulierClient).to receive(:authorization_uri).and_return(france_connect_particulier_callback_path(code: code)) diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index c0b468df5..f293c9205 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -211,11 +211,12 @@ describe Dossier do it { expect(subject).to include(:individual_nom) } it { expect(subject).to include(:individual_prenom) } it { expect(subject).to include(:individual_birthdate) } - it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + - dossier.procedure.types_de_champ.count + - dossier.procedure.types_de_champ_private.count + - dossier.export_entreprise_data.count) - } + it do + expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + + dossier.procedure.types_de_champ.count + + dossier.procedure.types_de_champ_private.count + + dossier.export_entreprise_data.count) + end end describe '#to_sorted_values' do @@ -238,11 +239,12 @@ describe Dossier do it { expect(subject[14]).to be_nil } it { expect(subject[15]).to be_nil } it { expect(subject[16]).to be_nil } - it { expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + - dossier.procedure.types_de_champ.count + - dossier.procedure.types_de_champ_private.count + - dossier.export_entreprise_data.count) - } + it do + expect(subject.count).to eq(DossierTableExportSerializer.new(dossier).attributes.count + + dossier.procedure.types_de_champ.count + + dossier.procedure.types_de_champ_private.count + + dossier.export_entreprise_data.count) + end context 'dossier for individual' do let(:dossier_with_individual) { create(:dossier, :for_individual, user: user, procedure: procedure) } diff --git a/spec/models/drop_down_list_spec.rb b/spec/models/drop_down_list_spec.rb index c75c9c74e..b898201db 100644 --- a/spec/models/drop_down_list_spec.rb +++ b/spec/models/drop_down_list_spec.rb @@ -4,32 +4,39 @@ describe DropDownList do let(:dropdownlist) { create :drop_down_list, value: value } describe '#options' do - let(:value) { "Cohésion sociale -Dév.Eco / Emploi -Cadre de vie / Urb. -Pilotage / Ingénierie -" -} + let(:value) do + <<~EOS + Cohésion sociale + Dév.Eco / Emploi + Cadre de vie / Urb. + Pilotage / Ingénierie + EOS + end it { expect(dropdownlist.options).to eq ['', 'Cohésion sociale', 'Dév.Eco / Emploi', 'Cadre de vie / Urb.', 'Pilotage / Ingénierie'] } context 'when one value is empty' do - let(:value) { "Cohésion sociale -Cadre de vie / Urb. -Pilotage / Ingénierie -" -} + let(:value) do + <<~EOS + Cohésion sociale + Cadre de vie / Urb. + Pilotage / Ingénierie + EOS + end it { expect(dropdownlist.options).to eq ['', 'Cohésion sociale', 'Cadre de vie / Urb.', 'Pilotage / Ingénierie'] } end end describe 'disabled_options' do - let(:value) { "tip ---top-- ---troupt-- -ouaich" -} + let(:value) do + <<~EOS + tip + --top-- + --troupt-- + ouaich + EOS + end it { expect(dropdownlist.disabled_options).to match(['--top--', '--troupt--']) } end