Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lisa-durand committed Nov 23, 2023
1 parent e6d9f9b commit 9473e80
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/controllers/users/dossiers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/users/dossiers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions spec/system/accessibilite/wcag_usager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions spec/system/api_particulier/api_particulier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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')

Expand Down
4 changes: 2 additions & 2 deletions spec/system/routing/rules_full_scenario_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/system/sessions/sign_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/system/users/brouillon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/system/users/dossier_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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('Prénom', with: 'prenom', visible: true)
fill_in('Nom', with: 'Nom', visible: true)
end

shared_examples 'the user can create a new draft' do
Expand Down
4 changes: 2 additions & 2 deletions spec/system/users/dropdown_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/system/users/linked_dropdown_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9473e80

Please sign in to comment.