debian-mirror-gitlab/spec/support/login_helpers.rb

27 lines
606 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
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)
@user = create(role)
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
fill_in "user_login", with: user.email
fill_in "user_password", with: "12345678"
click_button "Sign in"
Thread.current[:current_user] = user
end
# Requires Javascript driver.
def logout
2015-04-26 12:48:37 +05:30
find(:css, ".fa.fa-sign-out").click
2014-09-02 18:07:02 +05:30
end
end