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
8df03494
Commit
8df03494
authored
Mar 07, 2019
by
Rémy Coutable
Committed by
Lin Jen-Shin
Mar 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the Insights feature availability check
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
dbad902a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
97 additions
and
3 deletions
+97
-3
doc/user/group/index.md
doc/user/group/index.md
+1
-1
ee/app/controllers/ee/groups_controller.rb
ee/app/controllers/ee/groups_controller.rb
+1
-1
ee/app/models/concerns/insights_feature.rb
ee/app/models/concerns/insights_feature.rb
+15
-0
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+1
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+1
-0
ee/app/views/groups/_insights.html.haml
ee/app/views/groups/_insights.html.haml
+1
-1
ee/spec/models/group_spec.rb
ee/spec/models/group_spec.rb
+6
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+6
-0
ee/spec/support/shared_examples/models/insights_shared_examples.rb
...upport/shared_examples/models/insights_shared_examples.rb
+65
-0
No files found.
doc/user/group/index.md
View file @
8df03494
...
...
@@ -203,7 +203,7 @@ Get an overview of the vulnerabilities of all the projects in a group and its su
## Insights **[ULTIMATE]**
Placeholder
.
> Introduced in [GitLab Ultimate][ee] 11.9 behind the `insights` feature flag
.
## Transfer groups to another group
...
...
ee/app/controllers/ee/groups_controller.rb
View file @
8df03494
...
...
@@ -15,7 +15,7 @@ module EE
:membership_lock
,
:repository_size_limit
].
tap
do
|
params_ee
|
params_ee
<<
{
insight_attributes: :project_id
}
if
::
Feature
.
enabled?
(
:group_insights
)
&&
current_group
&
.
feature_available?
(
:insights
)
params_ee
<<
{
insight_attributes: :project_id
}
if
current_group
&
.
insights_available?
params_ee
<<
:project_creation_level
if
current_group
&
.
feature_available?
(
:project_creation_level
)
params_ee
<<
:file_template_project_id
if
current_group
&
.
feature_available?
(
:custom_file_templates_for_namespace
)
params_ee
<<
:custom_project_templates_group_id
if
License
.
feature_available?
(
:custom_project_templates
)
...
...
ee/app/models/concerns/insights_feature.rb
0 → 100644
View file @
8df03494
# frozen_string_literal: true
module
InsightsFeature
extend
ActiveSupport
::
Concern
# This allows to:
# 1. Disable the :insights by default even if the license allows it
# 1. Enable the Insights feature for an arbitrary group/project
# Once we're ready to release the feature, we could just replace
# `{group,project}.insights_available?` with
# `{group,project}.feature_available?(:insights)` and remove this module.
def
insights_available?
::
Feature
.
enabled?
(
:insights
,
self
)
&&
feature_available?
(
:insights
)
end
end
ee/app/models/ee/group.rb
View file @
8df03494
...
...
@@ -11,6 +11,7 @@ module EE
prepended
do
include
TokenAuthenticatable
include
InsightsFeature
add_authentication_token_field
:saml_discovery_token
,
unique:
false
,
token_generator:
->
{
Devise
.
friendly_token
(
8
)
}
...
...
ee/app/models/ee/project.rb
View file @
8df03494
...
...
@@ -18,6 +18,7 @@ module EE
include
Elastic
::
ProjectsSearch
include
EE
::
DeploymentPlatform
# rubocop: disable Cop/InjectEnterpriseEditionModule
include
EachBatch
include
InsightsFeature
ignore_column
:mirror_last_update_at
,
:mirror_last_successful_update_at
,
...
...
ee/app/views/groups/_insights.html.haml
View file @
8df03494
-
return
unless
Feature
.
enabled?
(
:group_insights
)
&&
@group
.
feature_available?
(
:insights
)
-
return
unless
@group
.
insights_available?
%section
.settings.gs-advanced.no-animate
#js-templates
{
class:
(
'expanded'
if
expanded
)
}
.settings-header
...
...
ee/spec/models/group_spec.rb
View file @
8df03494
...
...
@@ -394,4 +394,10 @@ describe Group do
end
end
end
describe
'#insights_available?'
do
it_behaves_like
'an entity with the Insights feature'
do
let
(
:entity
)
{
group
}
end
end
end
ee/spec/models/project_spec.rb
View file @
8df03494
...
...
@@ -1718,6 +1718,12 @@ describe Project do
end
end
describe
'#insights_available?'
do
it_behaves_like
'an entity with the Insights feature'
do
let
(
:entity
)
{
create
(
:project
)
}
end
end
# Despite stubbing the current node as the primary or secondary, the
# behaviour for EE::Project#lfs_http_url_to_repo() is to call
# Project#lfs_http_url_to_repo() which does not have a Geo context.
...
...
ee/spec/support/shared_examples/models/insights_shared_examples.rb
0 → 100644
View file @
8df03494
# This needs an `entity` object: Project or Group.
RSpec
.
shared_examples
'an entity with the Insights feature'
do
before
do
# This is needed because all feature flags are enabled by default in tests
allow
(
Feature
).
to
receive
(
:enabled?
)
.
with
(
:insights
,
entity
)
.
and_return
(
false
)
end
context
'when license does not allow it'
do
before
do
stub_licensed_features
(
insights:
false
)
end
it
{
expect
(
entity
).
not_to
be_insights_available
}
context
'when the feature flag is enabled globally'
do
before
do
stub_feature_flags
(
insights:
true
)
end
it
{
expect
(
entity
).
not_to
be_insights_available
}
end
context
'when the feature flag is enabled for the entity'
do
before
do
stub_feature_flags
(
insights:
{
enabled:
true
,
thing:
entity
})
end
it
{
expect
(
entity
).
not_to
be_insights_available
}
end
end
context
'when license allows it'
do
before
do
stub_licensed_features
(
insights:
true
)
end
it
{
expect
(
entity
).
not_to
be_insights_available
}
context
'when the feature flag is disabled globally'
do
before
do
stub_feature_flags
(
insights:
false
)
end
it
{
expect
(
entity
).
not_to
be_insights_available
}
end
context
'when the feature flag is enabled globally'
do
before
do
stub_feature_flags
(
insights:
true
)
end
it
{
expect
(
entity
).
to
be_insights_available
}
end
context
'when the feature flag is enabled for the entity'
do
before
do
stub_feature_flags
(
insights:
{
enabled:
true
,
thing:
entity
})
end
it
{
expect
(
entity
).
to
be_insights_available
}
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