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
...
@@ -7,29 +7,28 @@ module AccessMatchers
extend
RSpec
::
Matchers
::
DSL
extend
RSpec
::
Matchers
::
DSL
include
Warden
::
Test
::
Helpers
include
Warden
::
Test
::
Helpers
def
emulate_user
(
user
,
membership
=
nil
)
def
emulate_user
(
user_type_or_trait
,
membership
=
nil
)
case
user
case
user_type_or_trait
when
:user
when
:user
,
:admin
login_as
(
create
(
:user
))
login_as
(
create
(
user_type_or_trait
))
when
:external
,
:auditor
login_as
(
create
(
:user
,
user_type_or_trait
))
when
:visitor
when
:visitor
logout
logout
when
:admin
login_as
(
create
(
:admin
))
when
:external
login_as
(
create
(
:user
,
external:
true
))
when
User
when
User
login_as
(
user
)
login_as
(
user
_type_or_trait
)
when
*
Gitlab
::
Access
.
sym_options_with_owner
.
keys
when
*
Gitlab
::
Access
.
sym_options_with_owner
.
keys
raise
ArgumentError
,
"cannot emulate
#{
user
}
without membership parent"
unless
membership
raise
ArgumentError
,
"cannot emulate
#{
user_type_or_trait
}
without membership parent"
unless
membership
role
=
user
if
role
==
:owner
&&
membership
.
owner
role
=
user_type_or_trait
user
=
membership
.
owner
user
=
else
if
role
==
:owner
&&
membership
.
owner
user
=
create
(
:user
)
membership
.
owner
membership
.
public_send
(
:"add_
#{
role
}
"
,
user
)
else
end
create
(
:user
).
tap
do
|
new_user
|
membership
.
public_send
(
:"add_
#{
role
}
"
,
new_user
)
end
end
login_as
(
user
)
login_as
(
user
)
else
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