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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
88d6bdcf
Commit
88d6bdcf
authored
Feb 26, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce differences in spec/support/matchers/access_matchers.rb
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
be44024c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
spec/support/matchers/access_matchers.rb
spec/support/matchers/access_matchers.rb
+17
-18
No files found.
spec/support/matchers/access_matchers.rb
View file @
88d6bdcf
...
...
@@ -7,29 +7,28 @@ module AccessMatchers
extend
RSpec
::
Matchers
::
DSL
include
Warden
::
Test
::
Helpers
def
emulate_user
(
user
,
membership
=
nil
)
case
user
when
:user
login_as
(
create
(
:user
))
def
emulate_user
(
user_type_or_trait
,
membership
=
nil
)
case
user_type_or_trait
when
:user
,
:admin
login_as
(
create
(
user_type_or_trait
))
when
:external
,
:auditor
login_as
(
create
(
:user
,
user_type_or_trait
))
when
:visitor
logout
when
:admin
login_as
(
create
(
:admin
))
when
:external
login_as
(
create
(
:user
,
external:
true
))
when
User
login_as
(
user
)
login_as
(
user
_type_or_trait
)
when
*
Gitlab
::
Access
.
sym_options_with_owner
.
keys
raise
ArgumentError
,
"cannot emulate
#{
user
}
without membership parent"
unless
membership
role
=
user
raise
ArgumentError
,
"cannot emulate
#{
user_type_or_trait
}
without membership parent"
unless
membership
if
role
==
:owner
&&
membership
.
owner
user
=
membership
.
owner
else
user
=
create
(
:user
)
membership
.
public_send
(
:"add_
#{
role
}
"
,
user
)
end
role
=
user_type_or_trait
user
=
if
role
==
:owner
&&
membership
.
owner
membership
.
owner
else
create
(
:user
).
tap
do
|
new_user
|
membership
.
public_send
(
:"add_
#{
role
}
"
,
new_user
)
end
end
login_as
(
user
)
else
...
...
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