amelioration(expert.sign-in): ETQ expert, je suis redirigé vers la page listant les avis a donner ap connexion

This commit is contained in:
Martin 2023-12-14 10:07:34 +01:00
parent b56d5199e2
commit 4380fecd73
3 changed files with 15 additions and 4 deletions

View file

@ -6,6 +6,8 @@ class RootController < ApplicationController
return redirect_to admin_procedures_path
elsif instructeur_signed_in?
return redirect_to instructeur_procedures_path
elsif expert_signed_in?
return redirect_to expert_all_avis_path
elsif user_signed_in?
return redirect_to dossiers_path
elsif super_admin_signed_in?

View file

@ -9,6 +9,16 @@ describe RootController, type: :controller do
it { expect(subject).to redirect_to(dossiers_path) }
end
context 'when Expert is connected' do
let(:expert) { create(:expert) }
before do
sign_in(expert.user)
end
it { expect(subject).to redirect_to(expert_all_avis_path) }
end
context 'when Instructeur is connected' do
let(:instructeur) { create(:instructeur) }
let(:procedure) { create(:procedure, :published) }

View file

@ -37,7 +37,7 @@ describe 'Inviting an expert:' do
sign_in_with avis.expert.email, password
expect(page).to have_content('Connecté(e).')
expect(page).to have_current_path(dossiers_path) # Ideally we'd want `expert_all_avis_path` instead
expect(page).to have_current_path(expert_all_avis_path)
end
end
@ -52,9 +52,8 @@ describe 'Inviting an expert:' do
expect(page).to have_current_path(new_user_session_path)
login_as avis.expert.user, scope: :user
sign_in_with(avis.expert.email, 'This is a very complicated password !')
click_on 'Passer en expert'
expect(page).to have_current_path(expert_all_avis_path)
expect(page).to have_text('1 avis à donner')
click_on 'Passer en usager'
expect(page).to have_current_path(dossiers_path)
end
end