commencer: display a FranceConnect button

Fix #3640
This commit is contained in:
Pierre de La Morinerie 2019-04-02 15:03:35 +02:00 committed by Mathieu Magnin
parent 28dcbcb85b
commit 22f2ca105e
5 changed files with 32 additions and 0 deletions

View file

@ -34,6 +34,11 @@ module Users
redirect_to new_user_registration_path
end
def france_connect
store_user_location!
redirect_to france_connect_particulier_path
end
def procedure_for_help
Procedure.publiees.find_by(path: params[:path]) || Procedure.brouillons.find_by(path: params[:path])
end

View file

@ -8,6 +8,7 @@
%span.optional-on-small-screens
demarches-simplifiees.fr
= link_to 'Jai déjà un compte', commencer_sign_in_path(path: @procedure.path), class: ['button large expand']
= render partial: 'shared/france_connect_login', locals: { url: commencer_france_connect_path(path: @procedure.path) }
- else
- dossiers = current_user.dossiers.where(procedure: @procedure)

View file

@ -270,6 +270,7 @@ Rails.application.routes.draw do
get '/:path', action: 'commencer'
get '/:path/sign_in', action: 'sign_in', as: :sign_in
get '/:path/sign_up', action: 'sign_up', as: :sign_up
get '/:path/france_connect', action: 'france_connect', as: :france_connect
end
resources :dossiers, only: [:index, :show, :new] do

View file

@ -112,4 +112,28 @@ describe Users::CommencerController, type: :controller do
it { expect(subject).to redirect_to(new_user_registration_path) }
end
end
describe '#france_connect' do
context 'for a published procedure' do
subject { get :france_connect, params: { path: published_procedure.path } }
it 'set the path to return after sign-up to the procedure start page' do
subject
expect(controller.stored_location_for(:user)).to eq(commencer_path(path: published_procedure.path))
end
it { expect(subject).to redirect_to(france_connect_particulier_path) }
end
context 'for a draft procedure' do
subject { get :france_connect, 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(france_connect_particulier_path) }
end
end
end

View file

@ -21,6 +21,7 @@ RSpec.describe 'commencer/show.html.haml', type: :view do
subject
expect(rendered).to have_link('Créer un compte')
expect(rendered).to have_link('Jai déjà un compte')
expect(rendered).to have_link('Sidentifier avec FranceConnect')
end
end