From 0a8e5704d13a32db1e516654508a98ed2c5e3883 Mon Sep 17 00:00:00 2001 From: Kara Diaby Date: Tue, 22 Oct 2024 14:29:50 +0200 Subject: [PATCH] Ajoute les tests --- .../users/commencer_controller_spec.rb | 44 +++++++++++++++++++ .../system/users/dossier_prefill_post_spec.rb | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/spec/controllers/users/commencer_controller_spec.rb b/spec/controllers/users/commencer_controller_spec.rb index 50b86994ad4..0a322cad0f6 100644 --- a/spec/controllers/users/commencer_controller_spec.rb +++ b/spec/controllers/users/commencer_controller_spec.rb @@ -382,6 +382,50 @@ end end + describe '#pro_connect' do + context 'for a published procedure' do + subject { get :pro_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(agent_connect_login_path) } + + context 'when a prefill token is given' do + subject { get :pro_connect, params: { path: published_procedure.path, prefill_token: 'prefill_token' } } + + it_behaves_like 'a prefill token storage' + end + end + + context 'for a draft procedure' do + subject { get :pro_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_path(path: draft_procedure.path)) + end + + it { expect(subject).to redirect_to(agent_connect_login_path) } + + context 'when a prefill token is given' do + subject { get :pro_connect, params: { path: draft_procedure.path, prefill_token: 'prefill_token' } } + + it_behaves_like 'a prefill token storage' + end + end + + context 'when the path doesn’t exist' do + subject { get :france_connect, params: { path: 'hello' } } + + it 'redirects with an error message' do + expect(subject).to redirect_to(root_path) + end + end + end + describe '#dossier_vide_pdf' do let(:procedure) { create(:procedure, :published, :with_service, :with_path) } before { get :dossier_vide_pdf, params: { path: procedure.path } } diff --git a/spec/system/users/dossier_prefill_post_spec.rb b/spec/system/users/dossier_prefill_post_spec.rb index 1614a3f6309..420542029c9 100644 --- a/spec/system/users/dossier_prefill_post_spec.rb +++ b/spec/system/users/dossier_prefill_post_spec.rb @@ -110,7 +110,7 @@ let(:user) { User.find_by(email: user_email) } before do - click_on "Créer un compte #{APPLICATION_NAME}" + click_on "Créer un compte sur #{APPLICATION_NAME}" sign_up_with user_email, password expect(page).to have_content "nous avons besoin de vérifier votre adresse électronique #{user_email}"