#3694 Corrige la redirection pour s'inscrire sur une démarche de test

This commit is contained in:
Frederic Merizen 2019-03-28 14:24:35 +01:00 committed by GitHub
commit 1dda3cc812
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 12 deletions

View file

@ -42,7 +42,7 @@ module Users
def store_user_location! def store_user_location!
procedure = Procedure.find_by(path: params[:path]) procedure = Procedure.find_by(path: params[:path])
store_location_for(:user, commencer_path(path: procedure.path)) store_location_for(:user, helpers.procedure_lien(procedure))
end end
end end
end end

View file

@ -18,7 +18,7 @@ describe Users::CommencerController, type: :controller do
end end
end end
context 'when the path is for a non-published procedure' do context 'when the path is for a draft procedure' do
let(:path) { draft_procedure.path } let(:path) { draft_procedure.path }
it 'redirects with an error message' do it 'redirects with an error message' do
@ -66,9 +66,10 @@ describe Users::CommencerController, type: :controller do
end end
describe '#sign_in' do describe '#sign_in' do
context 'for a published procedure' do
subject { get :sign_in, params: { path: published_procedure.path } } subject { get :sign_in, params: { path: published_procedure.path } }
it 'set the path to return after sign-in to the dossier creation path' do it 'set the path to return after sign-in to the procedure start page' do
subject subject
expect(controller.stored_location_for(:user)).to eq(commencer_path(path: published_procedure.path)) expect(controller.stored_location_for(:user)).to eq(commencer_path(path: published_procedure.path))
end end
@ -76,14 +77,39 @@ describe Users::CommencerController, type: :controller do
it { expect(subject).to redirect_to(new_user_session_path) } it { expect(subject).to redirect_to(new_user_session_path) }
end end
context 'for a draft procedure' do
subject { get :sign_in, params: { path: draft_procedure.path } }
it 'set the path to return after sign-in to the draft procedure start page' do
subject
expect(controller.stored_location_for(:user)).to eq(commencer_test_path(path: draft_procedure.path))
end
it { expect(subject).to redirect_to(new_user_session_path) }
end
end
describe '#sign_up' do describe '#sign_up' do
context 'for a published procedure' do
subject { get :sign_up, params: { path: published_procedure.path } } subject { get :sign_up, params: { path: published_procedure.path } }
it 'set the path to return after sign-up to the dossier creation path' do it 'set the path to return after sign-up to the procedure start page' do
subject subject
expect(controller.stored_location_for(:user)).to eq(commencer_path(path: published_procedure.path)) expect(controller.stored_location_for(:user)).to eq(commencer_path(path: published_procedure.path))
end end
it { expect(subject).to redirect_to(new_user_registration_path) } it { expect(subject).to redirect_to(new_user_registration_path) }
end end
context 'for a draft procedure' do
subject { get :sign_up, params: { path: draft_procedure.path } }
it 'set the path to return after sign-up to the draft procedure start page' do
subject
expect(controller.stored_location_for(:user)).to eq(commencer_test_path(path: draft_procedure.path))
end
it { expect(subject).to redirect_to(new_user_registration_path) }
end
end
end end