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)