-
Notifications
You must be signed in to change notification settings - Fork 0
/
authentication_helper.rb
41 lines (31 loc) · 969 Bytes
/
authentication_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true
module DeviseHelpers
module RequestHelpers
# def sign_in_user(user)
# request.env['devise.mapping'] = Devise.mappings[:user]
# sign_in(user)
# end
end
module SystemHelpers
def sign_in_ui(user = nil)
user ||= Fabricate(:user)
visit root_path
fill_in 'user_email', with: user.email
fill_in 'user_password', with: user.password
click_button 'Sign in'
end
def sign_in(user)
login_as user, scope: :user
end
def sign_up_ui(email, password, password_confirm = nil)
user = Fabricate(:user)
visit new_user_registration_path
fill_in 'user_first_name', with: user.first_name
fill_in 'user_last_name', with: user.last_name
fill_in 'user_email', with: email
fill_in 'user_password', with: password
fill_in 'user_password_confirmation', with: password_confirm || password
click_button 'Sign up'
end
end
end