Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
44d68159
Commit
44d68159
authored
Jun 02, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow login_as helper to accept a User object
parent
821fc4b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
+20
-4
spec/support/login_helpers.rb
spec/support/login_helpers.rb
+20
-4
No files found.
spec/support/login_helpers.rb
View file @
44d68159
module
LoginHelpers
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)
# user_or_role - User object, or a role to create (e.g., :admin, :user)
def
login_as
(
role
)
#
@user
=
create
(
role
)
# 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
)
login_with
(
@user
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment