Commit 44d68159 authored by Robert Speicher's avatar Robert Speicher

Allow login_as helper to accept a User object

parent 821fc4b0
module LoginHelpers
# Internal: Create and log in as a user of the specified role
# Internal: Log in as a specific user or a new user of a specific role
#
# role - User role (e.g., :admin, :user)
def login_as(role)
@user = create(role)
# user_or_role - User object, or a role to create (e.g., :admin, :user)
#
# Examples:
#
# # Create a user automatically
# login_as(:user)
#
# # Create an admin automatically
# login_as(:admin)
#
# # Provide an existing User record
# user = create(:user)
# login_as(user)
def login_as(user_or_role)
if user_or_role.kind_of?(User)
@user = user_or_role
else
@user = create(user_or_role)
end
login_with(@user)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment