From 9f855afdfe828ba2ebda819bb910999439360d9a Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Jan 2018 15:34:26 +0100 Subject: [PATCH] Enable the Layout/FirstHashElementLineBreak cop --- .rubocop.yml | 2 +- .../concerns/tags_substitution_concern.rb | 24 +++++++---- ...94750_create_france_connect_information.rb | 30 +++++++------ .../attestation_templates_controller_spec.rb | 30 ++++++++----- .../admin/mail_templates_controller_spec.rb | 9 ++-- .../admin/types_de_champ_controller_spec.rb | 41 +++++++++--------- .../types_de_champ_private_controller_spec.rb | 43 +++++++++---------- .../new_gestionnaire/avis_controller_spec.rb | 12 +++--- .../dossiers_controller_spec.rb | 10 +++-- .../description_controller_shared_example.rb | 34 +++++++++------ 10 files changed, 135 insertions(+), 100 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 89c9c3630..7653b091c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -86,7 +86,7 @@ Layout/FirstArrayElementLineBreak: Enabled: true Layout/FirstHashElementLineBreak: - Enabled: false + Enabled: true Layout/FirstMethodArgumentLineBreak: Enabled: false diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb index 74e549508..0fc3b059e 100644 --- a/app/models/concerns/tags_substitution_concern.rb +++ b/app/models/concerns/tags_substitution_concern.rb @@ -29,20 +29,28 @@ module TagsSubstitutionConcern def dossier_tags [ - { libelle: 'motivation', + { + libelle: 'motivation', description: 'Motivation facultative associée à la décision finale d’acceptation, refus ou classement sans suite', target: :motivation, - dossier_termine_only: true }, - { libelle: 'date de dépôt', + dossier_termine_only: true + }, + { + libelle: 'date de dépôt', description: 'Date du passage en construction du dossier par l’usager', - lambda: -> (d) { format_date(d.en_construction_at) } }, - { libelle: 'date de passage en instruction', + lambda: -> (d) { format_date(d.en_construction_at) } + }, + { + libelle: 'date de passage en instruction', description: '', - lambda: -> (d) { format_date(d.en_instruction_at) } }, - { libelle: 'date de décision', + lambda: -> (d) { format_date(d.en_instruction_at) } + }, + { + libelle: 'date de décision', description: 'Date de la décision d’acceptation, refus, ou classement sans suite', lambda: -> (d) { format_date(d.processed_at) }, - dossier_termine_only: true }, + dossier_termine_only: true + }, { libelle: 'libellé procédure', description: '', lambda: -> (d) { d.procedure.libelle } }, { libelle: 'numéro du dossier', description: '', target: :id } ] diff --git a/db/migrate/20160120094750_create_france_connect_information.rb b/db/migrate/20160120094750_create_france_connect_information.rb index 9e16a3343..88f7f1128 100644 --- a/db/migrate/20160120094750_create_france_connect_information.rb +++ b/db/migrate/20160120094750_create_france_connect_information.rb @@ -18,13 +18,15 @@ class CreateFranceConnectInformation < ActiveRecord::Migration add_reference :france_connect_informations, :user, references: :users User.all.each do |user| - FranceConnectInformation.create({gender: user.gender, - given_name: user.given_name, - family_name: user.family_name, - birthdate: user.birthdate, - birthplace: user.birthplace, - france_connect_particulier_id: user.france_connect_particulier_id, - user_id: user.id}) if user.france_connect_particulier_id.present? + FranceConnectInformation.create({ + gender: user.gender, + given_name: user.given_name, + family_name: user.family_name, + birthdate: user.birthdate, + birthplace: user.birthplace, + france_connect_particulier_id: user.france_connect_particulier_id, + user_id: user.id + }) if user.france_connect_particulier_id.present? end remove_column :users, :gender @@ -44,12 +46,14 @@ class CreateFranceConnectInformation < ActiveRecord::Migration add_column :users, :france_connect_particulier_id, :string FranceConnectInformation.all.each do |fci| - User.find(fci.user_id).update_attributes({gender: fci.gender, - given_name: fci.given_name, - family_name: fci.family_name, - birthdate: fci.birthdate, - birthplace: fci.birthplace, - france_connect_particulier_id: fci.france_connect_particulier_id}) + User.find(fci.user_id).update_attributes({ + gender: fci.gender, + given_name: fci.given_name, + family_name: fci.family_name, + birthdate: fci.birthdate, + birthplace: fci.birthplace, + france_connect_particulier_id: fci.france_connect_particulier_id + }) end drop_table :france_connect_informations diff --git a/spec/controllers/admin/attestation_templates_controller_spec.rb b/spec/controllers/admin/attestation_templates_controller_spec.rb index 046b58920..6da56b933 100644 --- a/spec/controllers/admin/attestation_templates_controller_spec.rb +++ b/spec/controllers/admin/attestation_templates_controller_spec.rb @@ -19,8 +19,10 @@ describe Admin::AttestationTemplatesController, type: :controller do before do post :preview, - params: { procedure_id: procedure.id, - attestation_template: upload_params } + params: { + procedure_id: procedure.id, + attestation_template: upload_params + } end context 'with an interlaced png' do @@ -73,8 +75,10 @@ describe Admin::AttestationTemplatesController, type: :controller do context 'nominal' do before do post :create, - params: { procedure_id: procedure.id, - attestation_template: attestation_params.merge(logo: logo, signature: signature) } + params: { + procedure_id: procedure.id, + attestation_template: attestation_params.merge(logo: logo, signature: signature) + } procedure.reload end @@ -96,8 +100,10 @@ describe Admin::AttestationTemplatesController, type: :controller do .and_return(double(full_messages: ['nop'])) post :create, - params: { procedure_id: procedure.id, - attestation_template: attestation_params } + params: { + procedure_id: procedure.id, + attestation_template: attestation_params + } procedure.reload end @@ -113,8 +119,10 @@ describe Admin::AttestationTemplatesController, type: :controller do context 'nominal' do before do patch :update, - params: { procedure_id: procedure.id, - attestation_template: attestation_params_with_images } + params: { + procedure_id: procedure.id, + attestation_template: attestation_params_with_images + } procedure.reload end @@ -134,8 +142,10 @@ describe Admin::AttestationTemplatesController, type: :controller do .and_return(double(full_messages: ['nop'])) patch :update, - params: { procedure_id: procedure.id, - attestation_template: attestation_params_with_images } + params: { + procedure_id: procedure.id, + attestation_template: attestation_params_with_images + } procedure.reload end diff --git a/spec/controllers/admin/mail_templates_controller_spec.rb b/spec/controllers/admin/mail_templates_controller_spec.rb index faffe624d..313dd93ad 100644 --- a/spec/controllers/admin/mail_templates_controller_spec.rb +++ b/spec/controllers/admin/mail_templates_controller_spec.rb @@ -24,10 +24,11 @@ describe Admin::MailTemplatesController, type: :controller do before :each do patch :update, - params: { procedure_id: procedure.id, - id: initiated_mail.class.const_get(:SLUG), - mail_template: { subject: mail_subject, body: mail_body } - } + params: { + procedure_id: procedure.id, + id: initiated_mail.class.const_get(:SLUG), + mail_template: { subject: mail_subject, body: mail_body } + } end it { expect(response).to redirect_to admin_procedure_mail_templates_path(procedure) } diff --git a/spec/controllers/admin/types_de_champ_controller_spec.rb b/spec/controllers/admin/types_de_champ_controller_spec.rb index 270d125f9..3b68c6de6 100644 --- a/spec/controllers/admin/types_de_champ_controller_spec.rb +++ b/spec/controllers/admin/types_de_champ_controller_spec.rb @@ -41,27 +41,26 @@ describe Admin::TypesDeChampController, type: :controller do let(:mandatory) { 'on' } let(:procedure_params) do - {types_de_champ_attributes: - {'0' => - { - libelle: libelle, - type_champ: type_champ, - description: description, - order_place: order_place, - id: types_de_champ_id, - mandatory: mandatory - }, - '1' => - { - libelle: '', - type_champ: 'text', - description: '', - order_place: '1', - id: '', - mandatory: false, - type: 'TypeDeChampPublic' - } - } + { + types_de_champ_attributes: { + '0' => { + libelle: libelle, + type_champ: type_champ, + description: description, + order_place: order_place, + id: types_de_champ_id, + mandatory: mandatory + }, + '1' => { + libelle: '', + type_champ: 'text', + description: '', + order_place: '1', + id: '', + mandatory: false, + type: 'TypeDeChampPublic' + } + } } end diff --git a/spec/controllers/admin/types_de_champ_private_controller_spec.rb b/spec/controllers/admin/types_de_champ_private_controller_spec.rb index 1dbb9c0b4..701bb2c91 100644 --- a/spec/controllers/admin/types_de_champ_private_controller_spec.rb +++ b/spec/controllers/admin/types_de_champ_private_controller_spec.rb @@ -41,28 +41,27 @@ describe Admin::TypesDeChampPrivateController, type: :controller do let(:mandatory) { 'on' } let(:procedure_params) do - {types_de_champ_private_attributes: - {'0' => - { - libelle: libelle, - type_champ: type_champ, - description: description, - order_place: order_place, - id: types_de_champ_id, - mandatory: mandatory, - type: 'TypeDeChampPrivate' - }, - '1' => - { - libelle: '', - type_champ: 'text', - description: '', - order_place: '1', - id: '', - mandatory: false, - type: 'TypeDeChampPrivate' - } - } + { + types_de_champ_private_attributes: { + '0' => { + libelle: libelle, + type_champ: type_champ, + description: description, + order_place: order_place, + id: types_de_champ_id, + mandatory: mandatory, + type: 'TypeDeChampPrivate' + }, + '1' => { + libelle: '', + type_champ: 'text', + description: '', + order_place: '1', + id: '', + mandatory: false, + type: 'TypeDeChampPrivate' + } + } } end diff --git a/spec/controllers/new_gestionnaire/avis_controller_spec.rb b/spec/controllers/new_gestionnaire/avis_controller_spec.rb index 5c63450d2..094d384ba 100644 --- a/spec/controllers/new_gestionnaire/avis_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/avis_controller_spec.rb @@ -220,11 +220,13 @@ describe NewGestionnaire::AvisController, type: :controller do .with(avis_id.to_s, invited_email) .and_return(invitations_email) - post :create_gestionnaire, params: { id: avis_id, - email: invited_email, - gestionnaire: { - password: password - } } + post :create_gestionnaire, params: { + id: avis_id, + email: invited_email, + gestionnaire: { + password: password + } + } end context 'when the email does not belong to the invitation' do diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 2bb35d7a4..4249ecfaa 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -230,10 +230,12 @@ describe NewGestionnaire::DossiersController, type: :controller do let(:procedure) { create(:procedure, :published, attestation_template: template, gestionnaires: [gestionnaire]) } subject do - post :terminer, params: { process_action: "accepter", - procedure_id: procedure.id, - dossier_id: dossier.id, - dossier: { motivation: "Yallah" }} + post :terminer, params: { + process_action: "accepter", + procedure_id: procedure.id, + dossier_id: dossier.id, + dossier: { motivation: "Yallah" } + } end before do diff --git a/spec/controllers/users/description_controller_shared_example.rb b/spec/controllers/users/description_controller_shared_example.rb index 785b0e27d..6993e7d47 100644 --- a/spec/controllers/users/description_controller_shared_example.rb +++ b/spec/controllers/users/description_controller_shared_example.rb @@ -300,9 +300,11 @@ shared_examples 'description_controller_spec' do context 'Sauvegarde des pièces justificatives', vcr: { cassette_name: 'controllers_users_description_controller_sauvegarde_pj' } do let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids } before do - post :update, params: { dossier_id: dossier_id, - 'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0, - 'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 } + post :update, params: { + dossier_id: dossier_id, + 'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0, + 'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 + } dossier.reload end @@ -310,9 +312,11 @@ shared_examples 'description_controller_spec' do it 'ClamavService safe_file? is call' do expect(ClamavService).to receive(:safe_file?).twice - post :update, params: { dossier_id: dossier_id, - 'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0, - 'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 } + post :update, params: { + dossier_id: dossier_id, + 'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0, + 'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 + } end end @@ -348,9 +352,12 @@ shared_examples 'description_controller_spec' do describe 'POST #pieces_justificatives', vcr: { cassette_name: 'controllers_users_description_controller_pieces_justificatives' } do let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids } - subject { patch :pieces_justificatives, params: { dossier_id: dossier.id, - 'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0, - 'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 } + subject { + patch :pieces_justificatives, params: { + dossier_id: dossier.id, + 'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0, + 'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 + } } context 'when user is a guest' do @@ -424,9 +431,12 @@ end shared_examples 'description_controller_spec_POST_piece_justificatives_for_owner' do let(:all_pj_type) { dossier.procedure.type_de_piece_justificative_ids } - subject { patch :pieces_justificatives, params: { dossier_id: dossier.id, - 'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0, - 'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 } + subject { + patch :pieces_justificatives, params: { + dossier_id: dossier.id, + 'piece_justificative_' + all_pj_type[0].to_s => piece_justificative_0, + 'piece_justificative_' + all_pj_type[1].to_s => piece_justificative_1 + } } context 'when user is the owner', vcr: { cassette_name: 'controllers_users_description_controller_pieces_justificatives' } do