invite: mutualize feature helper for signing in

This commit is contained in:
Pierre de La Morinerie 2018-11-06 17:06:45 +01:00
parent d4b2b04875
commit 0fb9c123c9
2 changed files with 8 additions and 8 deletions

View file

@ -102,16 +102,10 @@ feature 'Invitations' do
def log_in(user) def log_in(user)
visit '/' visit '/'
click_on 'Connexion' click_on 'Connexion'
submit_login_form(user.email, user.password) sign_in_with(user.email, user.password)
expect(page).to have_current_path(dossiers_path) expect(page).to have_current_path(dossiers_path)
end end
def submit_login_form(email, password)
fill_in 'user_email', with: email
fill_in 'user_password', with: password
click_on 'Se connecter'
end
def navigate_to_brouillon(dossier) def navigate_to_brouillon(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)
@ -127,7 +121,7 @@ feature 'Invitations' do
def navigate_to_invited_dossier(invite) def navigate_to_invited_dossier(invite)
visit users_dossiers_invite_path(invite) visit users_dossiers_invite_path(invite)
expect(page).to have_current_path(new_user_session_path) expect(page).to have_current_path(new_user_session_path)
submit_login_form(invited_user.email, invited_user.password) sign_in_with(invited_user.email, invited_user.password)
end end
def send_invite_to(invited_email) def send_invite_to(invited_email)

View file

@ -14,6 +14,12 @@ module FeatureHelpers
dossier = FactoryBot.create(:dossier) dossier = FactoryBot.create(:dossier)
dossier dossier
end end
def sign_in_with(email, password)
fill_in :user_email, with: email
fill_in :user_password, with: password
click_on 'Se connecter'
end
end end
RSpec.configure do |config| RSpec.configure do |config|