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
a85b85e1
Commit
a85b85e1
authored
Feb 05, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor .show_gke_cluster_integration_callout?
parent
c1e1f807
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
20 deletions
+12
-20
app/helpers/user_callouts_helper.rb
app/helpers/user_callouts_helper.rb
+2
-2
spec/helpers/user_callouts_helper_spec.rb
spec/helpers/user_callouts_helper_spec.rb
+10
-18
No files found.
app/helpers/user_callouts_helper.rb
View file @
a85b85e1
...
@@ -2,8 +2,8 @@ module UserCalloutsHelper
...
@@ -2,8 +2,8 @@ module UserCalloutsHelper
GKE_CLUSTER_INTEGRATION
=
'gke_cluster_integration'
.
freeze
GKE_CLUSTER_INTEGRATION
=
'gke_cluster_integration'
.
freeze
def
show_gke_cluster_integration_callout?
(
project
)
def
show_gke_cluster_integration_callout?
(
project
)
c
urrent_user
&&
!
user_dismissed?
(
GKE_CLUSTER_INTEGRATION
)
&&
c
an?
(
current_user
,
:create_cluster
,
project
)
&&
can?
(
current_user
,
:create_cluster
,
project
)
!
user_dismissed?
(
GKE_CLUSTER_INTEGRATION
)
end
end
private
private
...
...
spec/helpers/user_callouts_helper_spec.rb
View file @
a85b85e1
...
@@ -12,44 +12,36 @@ describe UserCalloutsHelper do
...
@@ -12,44 +12,36 @@ describe UserCalloutsHelper do
subject
{
helper
.
show_gke_cluster_integration_callout?
(
project
)
}
subject
{
helper
.
show_gke_cluster_integration_callout?
(
project
)
}
context
'when user
has not dismissed
'
do
context
'when user
can create a cluster
'
do
before
do
before
do
allow
(
helper
).
to
receive
(
:user_dismissed?
).
and_return
(
false
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
anything
,
:create_cluster
,
anything
)
.
and_return
(
true
)
end
end
context
'when user
can create a cluster
'
do
context
'when user
has not dismissed
'
do
before
do
before
do
allow
(
helper
).
to
receive
(
:can?
).
with
(
anything
,
:create_cluster
,
anything
)
allow
(
helper
).
to
receive
(
:user_dismissed?
).
and_return
(
false
)
.
and_return
(
true
)
end
end
it
{
is_expected
.
to
be
true
}
it
{
is_expected
.
to
be
true
}
end
end
context
'when user
can not create a cluster
'
do
context
'when user
dismissed
'
do
before
do
before
do
allow
(
helper
).
to
receive
(
:can?
).
with
(
anything
,
:create_cluster
,
anything
)
allow
(
helper
).
to
receive
(
:user_dismissed?
).
and_return
(
true
)
.
and_return
(
false
)
end
end
it
{
is_expected
.
to
be
false
}
it
{
is_expected
.
to
be
false
}
end
end
end
end
context
'when user
dismissed
'
do
context
'when user
can not create a cluster
'
do
before
do
before
do
allow
(
helper
).
to
receive
(
:user_dismissed?
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
anything
,
:create_cluster
,
anything
)
.
and_return
(
false
)
end
end
it
{
is_expected
.
to
be
false
}
it
{
is_expected
.
to
be
false
}
end
end
context
'when the user is not logged in'
do
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
nil
)
end
it
{
is_expected
.
to
be_falsey
}
end
end
end
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