[Fix #2999] Send gestionnaire back to what they were doing after email verification

This commit is contained in:
Frederic Merizen 2018-11-22 18:11:00 +01:00 committed by gregoirenovel
parent f1398f62f8
commit 4699e515ed
3 changed files with 19 additions and 6 deletions

View file

@ -94,11 +94,9 @@ class Users::SessionsController < Sessions::SessionsController
administrateur = Administrateur.find_by(email: gestionnaire.email) administrateur = Administrateur.find_by(email: gestionnaire.email)
[user, gestionnaire, administrateur].compact.each { |resource| sign_in(resource) } [user, gestionnaire, administrateur].compact.each { |resource| sign_in(resource) }
if administrateur.present? # redirect to procedure'url if stored by store_location_for(:user) in dossiers_controller
redirect_to admin_procedures_path # redirect to root_path otherwise
else redirect_to after_sign_in_path_for(:user)
redirect_to gestionnaire_procedures_path
end
else else
flash[:alert] = 'Votre lien est invalide ou expiré, veuillez-vous reconnecter.' flash[:alert] = 'Votre lien est invalide ou expiré, veuillez-vous reconnecter.'
redirect_to new_user_session_path redirect_to new_user_session_path

View file

@ -261,7 +261,9 @@ describe Users::SessionsController, type: :controller do
context 'when the token is valid' do context 'when the token is valid' do
let(:login_token) { gestionnaire.login_token! } let(:login_token) { gestionnaire.login_token! }
it { is_expected.to redirect_to gestionnaire_procedures_path } # TODO when the gestionnaire has no other account, and the token is valid, and the user signing in was not starting a demarche,
# redirect to root_path, then redirect to gestionnaire_procedures_path (see root_controller)
it { is_expected.to redirect_to root_path }
it { expect(controller.current_gestionnaire).to eq(gestionnaire) } it { expect(controller.current_gestionnaire).to eq(gestionnaire) }
it { expect(controller).to have_received(:trust_device) } it { expect(controller).to have_received(:trust_device) }
end end

View file

@ -9,6 +9,19 @@ feature 'The gestionnaire part' do
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) } let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }
context 'when the gestionnaire is also a user' do
let!(:user) { create(:user, email: gestionnaire.email, password: password) }
scenario 'a gestionnaire can fill a dossier' do
visit commencer_path(path: procedure.path)
expect(page).to have_current_path new_user_session_path
sign_in_with(gestionnaire.email, password, true)
expect(page).to have_content(procedure.libelle)
end
end
scenario 'A gestionnaire can accept a dossier', :js do scenario 'A gestionnaire can accept a dossier', :js do
log_in(gestionnaire.email, password) log_in(gestionnaire.email, password)