dossier spec: add navigate_to_invited_dossier helper

This commit is contained in:
Pierre de La Morinerie 2018-09-24 16:22:37 +02:00
parent 1c7ad4d37b
commit 12ee9ba3ce

View file

@ -51,11 +51,9 @@ feature 'Invitations' do
end end
scenario 'an invited user can see and edit the draft', js: true do scenario 'an invited user can see and edit the draft', js: true do
visit users_dossiers_invite_path(invite) navigate_to_invited_dossier(invite)
expect(page).to have_current_path(new_user_session_path)
submit_login_form(invited_user.email, invited_user.password)
expect(page).to have_current_path(brouillon_dossier_path(dossier)) expect(page).to have_current_path(brouillon_dossier_path(dossier))
expect(page).to have_no_selector('.button.invite-user-action') expect(page).to have_no_selector('.button.invite-user-action')
fill_in 'Texte obligatoire', with: 'Some edited value' fill_in 'Texte obligatoire', with: 'Some edited value'
@ -65,10 +63,7 @@ feature 'Invitations' do
end end
scenario 'an invited user cannot submit the draft' do scenario 'an invited user cannot submit the draft' do
visit users_dossiers_invite_path(invite) navigate_to_invited_dossier(invite)
expect(page).to have_current_path(new_user_session_path)
submit_login_form(invited_user.email, invited_user.password)
expect(page).to have_current_path(brouillon_dossier_path(dossier)) expect(page).to have_current_path(brouillon_dossier_path(dossier))
expect(page).to have_button('Soumettre le dossier', disabled: true) 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)) expect(page).to have_current_path(brouillon_dossier_path(dossier))
end 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) def navigate_to_recapitulatif(dossier)
expect(page).to have_current_path(dossiers_path) expect(page).to have_current_path(dossiers_path)
click_on(dossier.id) click_on(dossier.id)