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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e2eb1d8e
Commit
e2eb1d8e
authored
Nov 29, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Break out long checks into new methods
Also add missing specs
parent
00312902
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
147 additions
and
4 deletions
+147
-4
ee/app/helpers/ee/user_callouts_helper.rb
ee/app/helpers/ee/user_callouts_helper.rb
+14
-4
ee/spec/helpers/ee/user_callouts_helper_spec.rb
ee/spec/helpers/ee/user_callouts_helper_spec.rb
+133
-0
No files found.
ee/app/helpers/ee/user_callouts_helper.rb
View file @
e2eb1d8e
...
...
@@ -5,10 +5,20 @@ module EE
GOLD_TRIAL
=
'gold_trial'
def
show_gold_trial?
(
user
=
current_user
)
!
user_dismissed?
(
GOLD_TRIAL
)
&&
(
::
Gitlab
.
com?
||
Rails
.
env
.
development?
)
&&
!
user
.
any_namespace_with_gold?
&&
!
user
.
any_namespace_with_trial?
return
false
if
user_dismissed?
(
GOLD_TRIAL
)
return
false
unless
show_gold_trial_suitable_env?
users_namespaces_clean?
(
user
)
end
def
show_gold_trial_suitable_env?
::
Gitlab
.
com?
||
Rails
.
env
.
development?
end
def
users_namespaces_clean?
(
user
)
return
false
if
user
.
any_namespace_with_gold?
!
user
.
any_namespace_with_trial?
end
end
end
ee/spec/helpers/ee/user_callouts_helper_spec.rb
0 → 100644
View file @
e2eb1d8e
# frozen_string_literal: true
require
'spec_helper'
describe
EE
::
UserCalloutsHelper
do
let
(
:user
)
{
create
(
:user
)
}
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
describe
'.show_gold_trial?'
do
let
(
:suitable_env
)
{
nil
}
before
do
allow
(
helper
).
to
receive
(
:user_dismissed?
).
with
(
described_class
::
GOLD_TRIAL
).
and_return
(
user_dismissed
)
allow
(
helper
).
to
receive
(
:show_gold_trial_suitable_env?
).
and_return
(
suitable_env
)
end
context
'when user has already dismissed the callout'
do
let
(
:user_dismissed
)
{
true
}
it
'returns false'
do
expect
(
helper
.
show_gold_trial?
).
to
be_falsey
end
end
context
'when show_gold_trial_suitable_env? returns false'
do
let
(
:user_dismissed
)
{
false
}
let
(
:suitable_env
)
{
false
}
it
'returns false'
do
expect
(
helper
.
show_gold_trial?
).
to
be_falsey
end
end
context
'when show_gold_trial_namespaces_checked?'
do
let
(
:user_dismissed
)
{
false
}
let
(
:suitable_env
)
{
true
}
before
do
allow
(
helper
).
to
receive
(
:users_namespaces_clean?
).
and_return
(
namespaces_checked
)
end
context
'returns false'
do
let
(
:namespaces_checked
)
{
false
}
it
'returns false'
do
expect
(
helper
.
show_gold_trial?
).
to
be_falsey
end
end
context
'returns true'
do
let
(
:namespaces_checked
)
{
true
}
it
'returns true'
do
expect
(
helper
.
show_gold_trial?
).
to
be_truthy
end
end
end
end
describe
'.show_gold_trial_suitable_env?'
do
before
do
allow
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
gitlab_com
)
allow
(
Rails
.
env
).
to
receive
(
:development?
).
and_return
(
rails_dev_env
)
end
context
"when we're neither GitLab.com or a Rails development env"
do
let
(
:gitlab_com
)
{
false
}
let
(
:rails_dev_env
)
{
false
}
it
'returns true'
do
expect
(
helper
.
show_gold_trial_suitable_env?
).
to
be_falsey
end
end
context
"when we're GitLab.com"
do
let
(
:gitlab_com
)
{
true
}
let
(
:rails_dev_env
)
{
false
}
it
'returns true'
do
expect
(
helper
.
show_gold_trial_suitable_env?
).
to
be_truthy
end
end
context
"when we're a Rails development env"
do
let
(
:gitlab_com
)
{
false
}
let
(
:rails_dev_env
)
{
true
}
it
'returns true'
do
expect
(
helper
.
show_gold_trial_suitable_env?
).
to
be_truthy
end
end
end
describe
'.show_gold_trial_namespaces_checked?'
do
let
(
:a_name_space_has_trial
)
{
nil
}
before
do
allow
(
user
).
to
receive
(
:any_namespace_with_gold?
).
and_return
(
a_name_space_has_gold
)
allow
(
user
).
to
receive
(
:any_namespace_with_trial?
).
and_return
(
a_name_space_has_trial
)
end
context
"when a user's namespace has gold"
do
let
(
:a_name_space_has_gold
)
{
true
}
it
'returns false'
do
expect
(
helper
.
users_namespaces_clean?
(
user
)).
to
be_falsey
end
end
context
"when a user's namespace does not have gold"
do
let
(
:a_name_space_has_gold
)
{
false
}
context
"but a user's namespace has a trial"
do
let
(
:a_name_space_has_trial
)
{
true
}
it
'returns false'
do
expect
(
helper
.
users_namespaces_clean?
(
user
)).
to
be_falsey
end
end
context
"and does not have a trial"
do
let
(
:a_name_space_has_trial
)
{
false
}
it
'returns true'
do
expect
(
helper
.
users_namespaces_clean?
(
user
)).
to
be_truthy
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