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
ec6c5833
Commit
ec6c5833
authored
Jan 27, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CalloutsHelper
parent
d77181d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
app/helpers/callouts_helper.rb
app/helpers/callouts_helper.rb
+11
-0
spec/helpers/callouts_helper_spec.rb
spec/helpers/callouts_helper_spec.rb
+45
-0
No files found.
app/helpers/callouts_helper.rb
0 → 100644
View file @
ec6c5833
module
CalloutsHelper
def
show_gke_cluster_integration_callout?
(
kube_feature_name
,
project
)
!
user_dismissed?
(
kube_feature_name
)
&&
project
.
team
.
master?
(
current_user
)
end
private
def
user_dismissed?
(
feature_name
)
Callout
.
find_by
(
user:
current_user
,
feature_name:
feature_name
).
dismissed_state?
end
end
spec/helpers/callouts_helper_spec.rb
0 → 100644
View file @
ec6c5833
require
"spec_helper"
describe
CalloutsHelper
do
let
(
:user
)
{
create
(
:user
)
}
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
describe
'.show_gke_cluster_integration_callout?'
do
let
(
:project
)
{
create
(
:project
)
}
subject
{
helper
.
show_gke_cluster_integration_callout?
(
'test_name'
,
project
)
}
context
'when user has not dismissed'
do
before
do
allow
(
helper
).
to
receive
(
:user_dismissed?
).
and_return
(
false
)
end
context
'when user is master'
do
before
do
allow
(
project
).
to
receive_message_chain
(
:team
,
:master?
).
and_return
(
true
)
end
it
{
is_expected
.
to
be
true
}
end
context
'when user is not master'
do
before
do
allow
(
project
).
to
receive_message_chain
(
:team
,
:master?
).
and_return
(
false
)
end
it
{
is_expected
.
to
be
false
}
end
end
context
'when user dismissed'
do
before
do
allow
(
helper
).
to
receive
(
:user_dismissed?
).
and_return
(
true
)
end
it
{
is_expected
.
to
be
false
}
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