fix tests

This commit is contained in:
Lisa Durand 2023-11-23 16:38:01 +01:00 committed by Kara Diaby
parent f6f18e9c86
commit d0e2f281cc
11 changed files with 31 additions and 31 deletions

View file

@ -128,7 +128,7 @@ module Users
@dossier = dossier @dossier = dossier
@no_description = true @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) @dossier.update!(autorisation_donnees: true, identity_updated_at: Time.zone.now)
flash.notice = t('.identity_saved') flash.notice = t('.identity_saved')
@ -138,7 +138,7 @@ module Users
redirect_to brouillon_dossier_path(@dossier) redirect_to brouillon_dossier_path(@dossier)
end end
else else
flash.now.alert = @dossier.individual.errors.full_messages flash.now.alert = @dossier.individual.errors.full_messages + @dossier.errors.full_messages
render :identite render :identite
end end
end end

View file

@ -164,7 +164,7 @@ describe Users::DossiersController, type: :controller do
let(:dossier) { create(:dossier, user: user, procedure: procedure) } let(:dossier) { create(:dossier, user: user, procedure: procedure) }
let(:now) { Time.zone.parse('01/01/2100') } 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 before do
sign_in(user) sign_in(user)
@ -174,7 +174,7 @@ describe Users::DossiersController, type: :controller do
end end
context 'with correct individual and dossier params' do 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 it do
expect(response).to redirect_to(brouillon_dossier_path(dossier)) expect(response).to redirect_to(brouillon_dossier_path(dossier))
@ -184,7 +184,7 @@ describe Users::DossiersController, type: :controller do
context 'when the identite cannot be updated by the user' do context 'when the identite cannot be updated by the user' do
let(:dossier) { create(:dossier, :with_individual, :en_instruction, user: user, procedure: procedure) } 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 it 'redirects to the dossiers list' do
expect(response).to redirect_to(dossier_path(dossier)) expect(response).to redirect_to(dossier_path(dossier))
@ -193,7 +193,7 @@ describe Users::DossiersController, type: :controller do
end end
context 'with incorrect individual and dossier params' do context 'with incorrect individual and dossier params' do
let(:individual_params) { { gender: '', nom: '', prenom: '' } } let(:dossier_params) { { individual_attributes: { gender: '', nom: '', prenom: '' } } }
it do it do
expect(response).not_to have_http_status(:redirect) expect(response).not_to have_http_status(:redirect)

View file

@ -122,8 +122,8 @@ describe 'wcag rules for usager', js: true do
click_on 'Commencer la démarche' click_on 'Commencer la démarche'
find('label', text: 'Monsieur') find('label', text: 'Monsieur')
fill_in('Prénom', with: 'prenom') fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'nom') fill_in('Nom', with: 'nom', visible: true)
click_on 'Continuer' click_on 'Continuer'
expect(page).to be_axe_clean expect(page).to be_axe_clean

View file

@ -267,8 +267,8 @@ describe 'fetch API Particulier Data', js: true do
click_on 'Commencer la démarche' click_on 'Commencer la démarche'
find('label', text: 'Monsieur').click find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'prenom') fill_in('indiv_first_name', with: 'prenom', visible: true)
fill_in('Nom', with: 'nom') fill_in('indiv_last_name', with: 'nom', visible: true)
click_button('Continuer') click_button('Continuer')
@ -325,8 +325,8 @@ describe 'fetch API Particulier Data', js: true do
click_on 'Commencer la démarche' click_on 'Commencer la démarche'
find('label', text: 'Monsieur').click find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'Georges') fill_in('indiv_first_name', with: 'Georges', visible: true)
fill_in('Nom', with: 'Moustaki') fill_in('indiv_last_name', with: 'Moustaki', visible: true)
click_button('Continuer') click_button('Continuer')
@ -398,8 +398,8 @@ describe 'fetch API Particulier Data', js: true do
click_on 'Commencer la démarche' click_on 'Commencer la démarche'
find('label', text: 'Madame').click find('label', text: 'Madame').click
fill_in('Prénom', with: 'Dubois') fill_in('indiv_first_name', with: 'Dubois', visible: true)
fill_in('Nom', with: 'Angela Claire Louise') fill_in('indiv_last_name', with: 'Angela Claire Louise', visible: true)
click_button('Continuer') click_button('Continuer')
@ -461,8 +461,8 @@ describe 'fetch API Particulier Data', js: true do
click_on 'Commencer la démarche' click_on 'Commencer la démarche'
find('label', text: 'Madame').click find('label', text: 'Madame').click
fill_in('Nom', with: 'FERRI') fill_in('indiv_last_name', with: 'FERRI', visible: true)
fill_in('Prénom', with: 'Karine') fill_in('indiv_first_name', with: 'Karine', visible: true)
click_button('Continuer') click_button('Continuer')

View file

@ -263,8 +263,8 @@ describe 'The routing with rules', js: true do
click_on 'Commencer la démarche' click_on 'Commencer la démarche'
find('label', text: 'Monsieur').click find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'Prenom') fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'Nom') fill_in('Nom', with: 'Nom', visible: true)
click_button('Continuer') click_button('Continuer')
# the old system should not be present # the old system should not be present

View file

@ -43,7 +43,7 @@ describe 'Signin in:' do
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last) 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(procedure.libelle)
expect(page).to have_content "Identité du demandeur" expect(page).to have_content "Votre identité"
end end
end end

View file

@ -626,7 +626,7 @@ describe 'The user' do
visit "/commencer/#{procedure.path}" visit "/commencer/#{procedure.path}"
click_on 'Commencer la démarche' click_on 'Commencer la démarche'
expect(page).to have_content("Identité du demandeur") expect(page).to have_content("Votre identité")
expect(page).to have_current_path(identite_dossier_path(user_dossier)) expect(page).to have_current_path(identite_dossier_path(user_dossier))
end end
@ -653,8 +653,8 @@ describe 'The user' do
def fill_individual def fill_individual
find('label', text: 'Monsieur').click find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'prenom') fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'nom') fill_in('Nom', with: 'Nom', visible: true)
click_on 'Continuer' click_on 'Continuer'
expect(page).to have_current_path(brouillon_dossier_path(user_dossier)) expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
end end

View file

@ -22,8 +22,8 @@ describe 'Creating a new dossier:' do
expect(page).to have_title(libelle) expect(page).to have_title(libelle)
find('label', text: 'Monsieur').click find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'Prenom') fill_in('dossier[individual_attributes][prenom]', with: 'prenom', visible: true)
fill_in('Nom', with: 'Nom') fill_in('dossier[individual_attributes][nom]', with: 'prenom', visible: true)
end end
shared_examples 'the user can create a new draft' do shared_examples 'the user can create a new draft' do

View file

@ -75,8 +75,8 @@ describe 'dropdown list with other option activated', js: true do
def fill_individual def fill_individual
find('label', text: 'Monsieur').click find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'prenom') fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'nom') fill_in('Nom', with: 'Nom', visible: true)
click_on 'Continuer' click_on 'Continuer'
expect(page).to have_current_path(brouillon_dossier_path(user_dossier)) expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
end end

View file

@ -75,14 +75,14 @@ describe 'linked dropdown lists' do
expect(page).to have_current_path(commencer_path(path: procedure.path)) expect(page).to have_current_path(commencer_path(path: procedure.path))
click_on 'Commencer la démarche' click_on 'Commencer la démarche'
expect(page).to have_content("Identité du demandeur") expect(page).to have_content("Votre identité")
expect(page).to have_current_path(identite_dossier_path(user_dossier)) expect(page).to have_current_path(identite_dossier_path(user_dossier))
end end
def fill_individual def fill_individual
find('label', text: 'Monsieur').click find('label', text: 'Monsieur').click
fill_in('Prénom', with: 'prenom') fill_in('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'nom') fill_in('Nom', with: 'nom', visible: true)
click_on 'Continuer' click_on 'Continuer'
expect(page).to have_current_path(brouillon_dossier_path(user_dossier)) expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
end end

View file

@ -10,8 +10,8 @@ describe 'users/dossiers/identite', type: :view do
subject! { render } subject! { render }
it 'has identity fields' do it 'has identity fields' do
expect(rendered).to have_field('Prénom') expect(rendered).to have_field(id: 'indiv_first_name')
expect(rendered).to have_field('Nom') expect(rendered).to have_field(id: 'indiv_last_name')
end end
context 'when the demarche asks for the birthdate' do context 'when the demarche asks for the birthdate' do