From 12ee9ba3ce00f6d69367af4a6798d53be4a6a691 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 24 Sep 2018 16:22:37 +0200 Subject: [PATCH] dossier spec: add `navigate_to_invited_dossier` helper --- spec/features/new_user/invite_spec.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spec/features/new_user/invite_spec.rb b/spec/features/new_user/invite_spec.rb index ea803078b..b2c77565c 100644 --- a/spec/features/new_user/invite_spec.rb +++ b/spec/features/new_user/invite_spec.rb @@ -51,11 +51,9 @@ feature 'Invitations' do end scenario 'an invited user can see and edit the draft', js: true do - visit users_dossiers_invite_path(invite) - expect(page).to have_current_path(new_user_session_path) - - submit_login_form(invited_user.email, invited_user.password) + navigate_to_invited_dossier(invite) expect(page).to have_current_path(brouillon_dossier_path(dossier)) + expect(page).to have_no_selector('.button.invite-user-action') fill_in 'Texte obligatoire', with: 'Some edited value' @@ -65,10 +63,7 @@ feature 'Invitations' do end scenario 'an invited user cannot submit the draft' do - visit users_dossiers_invite_path(invite) - expect(page).to have_current_path(new_user_session_path) - - submit_login_form(invited_user.email, invited_user.password) + navigate_to_invited_dossier(invite) expect(page).to have_current_path(brouillon_dossier_path(dossier)) expect(page).to have_button('Soumettre le dossier', disabled: true) @@ -134,6 +129,12 @@ feature 'Invitations' do expect(page).to have_current_path(brouillon_dossier_path(dossier)) end + def navigate_to_invited_dossier(invite) + visit users_dossiers_invite_path(invite) + expect(page).to have_current_path(new_user_session_path) + submit_login_form(invited_user.email, invited_user.password) + end + def navigate_to_recapitulatif(dossier) expect(page).to have_current_path(dossiers_path) click_on(dossier.id)