diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 44d6e3fdd00..c36f6175607 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -128,7 +128,7 @@ def update_identite @dossier = dossier @no_description = true - if @dossier.update(dossier_params) + if @dossier.update(dossier_params) && @dossier.individual.valid? @dossier.update!(autorisation_donnees: true, identity_updated_at: Time.zone.now) flash.notice = t('.identity_saved') @@ -138,7 +138,7 @@ def update_identite redirect_to brouillon_dossier_path(@dossier) end else - flash.now.alert = @dossier.individual.errors.full_messages + flash.now.alert = @dossier.individual.errors.full_messages + @dossier.errors.full_messages render :identite end end diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 29eb3fb49f4..29431f7efb0 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -164,7 +164,7 @@ let(:dossier) { create(:dossier, user: user, procedure: procedure) } let(:now) { Time.zone.parse('01/01/2100') } - subject { post :update_identite, params: { id: dossier.id, individual: individual_params } } + subject { post :update_identite, params: { id: dossier.id, dossier: dossier_params } } before do sign_in(user) @@ -174,7 +174,7 @@ end context 'with correct individual and dossier params' do - let(:individual_params) { { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } } + let(:dossier_params) { { individual_attributes: { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } } } it do expect(response).to redirect_to(brouillon_dossier_path(dossier)) @@ -184,7 +184,7 @@ context 'when the identite cannot be updated by the user' do let(:dossier) { create(:dossier, :with_individual, :en_instruction, user: user, procedure: procedure) } - let(:individual_params) { { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } } + let(:dossier_params) { { individual_attributes: { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } } } it 'redirects to the dossiers list' do expect(response).to redirect_to(dossier_path(dossier)) @@ -193,7 +193,7 @@ end context 'with incorrect individual and dossier params' do - let(:individual_params) { { gender: '', nom: '', prenom: '' } } + let(:dossier_params) { { individual_attributes: { gender: '', nom: '', prenom: '' } } } it do expect(response).not_to have_http_status(:redirect) diff --git a/spec/system/accessibilite/wcag_usager_spec.rb b/spec/system/accessibilite/wcag_usager_spec.rb index e9aec827771..620981c8b0b 100644 --- a/spec/system/accessibilite/wcag_usager_spec.rb +++ b/spec/system/accessibilite/wcag_usager_spec.rb @@ -122,8 +122,8 @@ def expect_axe_clean_without_main_navigation click_on 'Commencer la démarche' find('label', text: 'Monsieur') - fill_in('Prénom', with: 'prenom') - fill_in('Nom', with: 'nom') + fill_in('Prénom', with: 'prenom', visible: true) + fill_in('Nom', with: 'nom', visible: true) click_on 'Continuer' expect(page).to be_axe_clean diff --git a/spec/system/api_particulier/api_particulier_spec.rb b/spec/system/api_particulier/api_particulier_spec.rb index 2c7c1fa9d6b..a60b4e4b44b 100644 --- a/spec/system/api_particulier/api_particulier_spec.rb +++ b/spec/system/api_particulier/api_particulier_spec.rb @@ -267,8 +267,8 @@ click_on 'Commencer la démarche' find('label', text: 'Monsieur').click - fill_in('Prénom', with: 'prenom') - fill_in('Nom', with: 'nom') + fill_in('Prénom', with: 'prenom', visible: true) + fill_in('Nom', with: 'nom', visible: true) click_button('Continuer') @@ -325,8 +325,8 @@ click_on 'Commencer la démarche' find('label', text: 'Monsieur').click - fill_in('Prénom', with: 'Georges') - fill_in('Nom', with: 'Moustaki') + fill_in('Prénom', with: 'Georges', visible: true) + fill_in('Nom', with: 'Moustaki', visible: true) click_button('Continuer') @@ -398,8 +398,8 @@ click_on 'Commencer la démarche' find('label', text: 'Madame').click - fill_in('Prénom', with: 'Dubois') - fill_in('Nom', with: 'Angela Claire Louise') + fill_in('Prénom', with: 'Dubois', visible: true) + fill_in('Nom', with: 'Angela Claire Louise', visible: true) click_button('Continuer') @@ -461,8 +461,8 @@ click_on 'Commencer la démarche' find('label', text: 'Madame').click - fill_in('Nom', with: 'FERRI') - fill_in('Prénom', with: 'Karine') + fill_in('Nom', with: 'FERRI', visible: true) + fill_in('Prénom', with: 'Karine', visible: true) click_button('Continuer') diff --git a/spec/system/routing/rules_full_scenario_spec.rb b/spec/system/routing/rules_full_scenario_spec.rb index 1beba5ccd18..2aff2917bc0 100644 --- a/spec/system/routing/rules_full_scenario_spec.rb +++ b/spec/system/routing/rules_full_scenario_spec.rb @@ -263,8 +263,8 @@ def user_send_dossier(user, groupe) click_on 'Commencer la démarche' find('label', text: 'Monsieur').click - fill_in('Prénom', with: 'Prenom') - fill_in('Nom', with: 'Nom') + fill_in('Prénom', with: 'prenom', visible: true) + fill_in('Nom', with: 'Nom', visible: true) click_button('Continuer') # the old system should not be present diff --git a/spec/system/sessions/sign_in_spec.rb b/spec/system/sessions/sign_in_spec.rb index 840f7d3fc13..a586dd744ee 100644 --- a/spec/system/sessions/sign_in_spec.rb +++ b/spec/system/sessions/sign_in_spec.rb @@ -43,7 +43,7 @@ expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last) expect(page).to have_content(procedure.libelle) - expect(page).to have_content "Identité du demandeur" + expect(page).to have_content "Mon identité" end end diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index 82891203da5..24273a35487 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -653,8 +653,8 @@ def champ_for(libelle) def fill_individual find('label', text: 'Monsieur').click - fill_in('Prénom', with: 'prenom') - fill_in('Nom', with: 'nom') + fill_in('Prénom', with: 'prenom', visible: true) + fill_in('Nom', with: 'Nom', visible: true) click_on 'Continuer' expect(page).to have_current_path(brouillon_dossier_path(user_dossier)) end diff --git a/spec/system/users/dossier_creation_spec.rb b/spec/system/users/dossier_creation_spec.rb index 07e70f33196..2e026843a64 100644 --- a/spec/system/users/dossier_creation_spec.rb +++ b/spec/system/users/dossier_creation_spec.rb @@ -22,8 +22,8 @@ expect(page).to have_title(libelle) find('label', text: 'Monsieur').click - fill_in('Prénom', with: 'Prenom') - fill_in('Nom', with: 'Nom') + fill_in('dossier[individual_attributes][prenom]', with: 'prenom', visible: true) + fill_in('dossier[individual_attributes][nom]', with: 'prenom', visible: true) end shared_examples 'the user can create a new draft' do diff --git a/spec/system/users/dropdown_spec.rb b/spec/system/users/dropdown_spec.rb index 58f363342ce..5966f1cabb3 100644 --- a/spec/system/users/dropdown_spec.rb +++ b/spec/system/users/dropdown_spec.rb @@ -75,8 +75,8 @@ def fill_individual find('label', text: 'Monsieur').click - fill_in('Prénom', with: 'prenom') - fill_in('Nom', with: 'nom') + fill_in('Prénom', with: 'prenom', visible: true) + fill_in('Nom', with: 'Nom', visible: true) click_on 'Continuer' expect(page).to have_current_path(brouillon_dossier_path(user_dossier)) end diff --git a/spec/system/users/linked_dropdown_spec.rb b/spec/system/users/linked_dropdown_spec.rb index 28a6ce2775f..2fb16413c06 100644 --- a/spec/system/users/linked_dropdown_spec.rb +++ b/spec/system/users/linked_dropdown_spec.rb @@ -75,14 +75,14 @@ def log_in(email, password, procedure) expect(page).to have_current_path(commencer_path(path: procedure.path)) click_on 'Commencer la démarche' - expect(page).to have_content("Identité du demandeur") + expect(page).to have_content("Mon identité") expect(page).to have_current_path(identite_dossier_path(user_dossier)) end def fill_individual find('label', text: 'Monsieur').click - fill_in('Prénom', with: 'prenom') - fill_in('Nom', with: 'nom') + fill_in('Prénom', with: 'prenom', visible: true) + fill_in('Nom', with: 'nom', visible: true) click_on 'Continuer' expect(page).to have_current_path(brouillon_dossier_path(user_dossier)) end