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
Jérome Perrin
gitlab-ce
Commits
8f942a05
Commit
8f942a05
authored
Feb 02, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use policies instead of role checks in ClustersHelper
parent
ad38e120
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
18 deletions
+9
-18
app/helpers/callouts_helper.rb
app/helpers/callouts_helper.rb
+1
-2
spec/helpers/callouts_helper_spec.rb
spec/helpers/callouts_helper_spec.rb
+8
-16
No files found.
app/helpers/callouts_helper.rb
View file @
8f942a05
...
...
@@ -8,8 +8,7 @@ module CalloutsHelper
def
show_gke_cluster_integration_callout?
(
project
)
current_user
&&
!
user_dismissed?
(
GKE_CLUSTER_INTEGRATION
)
&&
(
project
.
team
.
master?
(
current_user
)
||
current_user
==
project
.
owner
)
can?
(
current_user
,
:create_cluster
,
project
)
end
private
...
...
spec/helpers/callouts_helper_spec.rb
View file @
8f942a05
...
...
@@ -17,30 +17,22 @@ describe CalloutsHelper do
allow
(
helper
).
to
receive
(
:user_dismissed?
).
and_return
(
false
)
end
context
'when user
is ma
ster'
do
context
'when user
can create a clu
ster'
do
before
do
allow
(
project
).
to
receive_message_chain
(
:team
,
:master?
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
anything
,
:create_cluster
,
anything
)
.
and_return
(
true
)
end
it
{
is_expected
.
to
be
true
}
end
context
'when user is not master'
do
context
'when the user is owner'
do
before
do
allow
(
project
).
to
receive
(
:owner
).
and_return
(
user
)
end
it
{
is_expected
.
to
be
true
}
context
'when user can not create a cluster'
do
before
do
allow
(
helper
).
to
receive
(
:can?
).
with
(
anything
,
:create_cluster
,
anything
)
.
and_return
(
false
)
end
context
'when the user is not owner'
do
before
do
allow
(
project
).
to
receive_message_chain
(
:team
,
:master?
).
and_return
(
false
)
end
it
{
is_expected
.
to
be
false
}
end
it
{
is_expected
.
to
be
false
}
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