Skip to content

Commit

Permalink
Ajoute les tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kara22 committed Oct 22, 2024
1 parent 80e2c19 commit 430729e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
44 changes: 44 additions & 0 deletions spec/controllers/users/commencer_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }
Expand Down
2 changes: 1 addition & 1 deletion spec/system/users/dossier_prefill_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,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}"
Expand Down
2 changes: 1 addition & 1 deletion spec/system/users/dossier_prefill_post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion spec/system/users/sign_up_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

before do
visit commencer_path(path: procedure.path)
click_on "Créer un compte #{APPLICATION_NAME}"
click_on "Créer un compte sur #{APPLICATION_NAME}"
expect(page).to have_selector('.suspect-email', visible: false)
fill_in 'Adresse électronique', with: '[email protected]'
fill_in 'Mot de passe', with: '1 2 3 4 5 6 '
Expand Down

0 comments on commit 430729e

Please sign in to comment.