2012-08-23 11:19:40 +02:00
|
|
|
module LoginHelpers
|
|
|
|
# Internal: Create and log in as a user of the specified role
|
|
|
|
#
|
|
|
|
# role - User role (e.g., :admin, :user)
|
|
|
|
def login_as(role)
|
2012-11-06 04:31:55 +01:00
|
|
|
@user = create(role)
|
2012-08-23 11:19:40 +02:00
|
|
|
login_with(@user)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Internal: Login as the specified user
|
|
|
|
#
|
|
|
|
# user - User instance to login with
|
|
|
|
def login_with(user)
|
|
|
|
visit new_user_session_path
|
2013-03-25 15:10:14 +01:00
|
|
|
fill_in "user_login", with: user.email
|
2012-08-23 11:19:40 +02:00
|
|
|
fill_in "user_password", with: "123456"
|
|
|
|
click_button "Sign in"
|
|
|
|
end
|
|
|
|
|
|
|
|
def logout
|
|
|
|
click_link "Logout" rescue nil
|
|
|
|
end
|
|
|
|
end
|