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
8ad1598f
Commit
8ad1598f
authored
Apr 05, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE Part: Get GITLAB_FEATURES from Project#licensed_features instead of Namespace#features (#5320)
parent
597b0a70
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
79 deletions
+89
-79
ee/app/models/ee/namespace.rb
ee/app/models/ee/namespace.rb
+0
-9
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+9
-0
ee/spec/models/namespace_spec.rb
ee/spec/models/namespace_spec.rb
+0
-70
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+80
-0
No files found.
ee/app/models/ee/namespace.rb
View file @
8ad1598f
...
...
@@ -64,15 +64,6 @@ module EE
succeeded
end
override
:features
def
features
return
super
unless
License
.
current
License
.
current
.
features
.
select
do
|
feature
|
License
.
global_feature?
(
feature
)
||
feature_available?
(
feature
)
end
end
# Checks features (i.e. https://about.gitlab.com/products/) availabily
# for a given Namespace plan. This method should consider ancestor groups
# being licensed.
...
...
ee/app/models/ee/project.rb
View file @
8ad1598f
...
...
@@ -495,6 +495,15 @@ module EE
.
external_authorization_service_default_label
end
override
:licensed_features
def
licensed_features
return
super
unless
License
.
current
License
.
current
.
features
.
select
do
|
feature
|
License
.
global_feature?
(
feature
)
||
licensed_feature_available?
(
feature
)
end
end
private
def
set_override_pull_mirror_available
...
...
ee/spec/models/namespace_spec.rb
View file @
8ad1598f
...
...
@@ -122,76 +122,6 @@ describe Namespace do
end
end
describe
'#features'
do
let
(
:plan_license
)
{
:free_plan
}
let
(
:group
)
{
create
(
:group
,
plan:
plan_license
)
}
let
(
:global_license
)
{
create
(
:license
)
}
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
global_license
)
allow
(
global_license
).
to
receive
(
:features
).
and_return
([
:epics
,
# Gold only
:service_desk
,
# Silver and up
:audit_events
,
# Bronze and up
:geo
,
# Global feature, should not be checked at namespace level
])
end
subject
{
group
.
features
}
context
'when the namespace should be checked'
do
before
do
enable_namespace_license_check!
end
context
'when bronze'
do
let
(
:plan_license
)
{
:bronze_plan
}
it
'filters for bronze features'
do
is_expected
.
to
contain_exactly
(
:audit_events
,
:geo
)
end
end
context
'when silver'
do
let
(
:plan_license
)
{
:silver_plan
}
it
'filters for silver features'
do
is_expected
.
to
contain_exactly
(
:service_desk
,
:audit_events
,
:geo
)
end
end
context
'when gold'
do
let
(
:plan_license
)
{
:gold_plan
}
it
'filters for gold features'
do
is_expected
.
to
contain_exactly
(
:epics
,
:service_desk
,
:audit_events
,
:geo
)
end
end
context
'when free plan'
do
let
(
:plan_license
)
{
:free_plan
}
it
'filters out paid features'
do
is_expected
.
to
contain_exactly
(
:geo
)
end
end
end
context
'when namespace should not be checked'
do
it
'includes all features in global license'
do
is_expected
.
to
contain_exactly
(
:epics
,
:service_desk
,
:audit_events
,
:geo
)
end
end
context
'when there is no license'
do
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
nil
)
end
it
{
is_expected
.
to
be_empty
}
end
end
describe
'#feature_available?'
do
let
(
:plan_license
)
{
:bronze_plan
}
let
(
:group
)
{
create
(
:group
,
plan:
plan_license
)
}
...
...
ee/spec/models/project_spec.rb
View file @
8ad1598f
...
...
@@ -1364,4 +1364,84 @@ describe Project do
end
end
end
describe
'#licensed_features'
do
let
(
:plan_license
)
{
:free_plan
}
let
(
:global_license
)
{
create
(
:license
)
}
let
(
:group
)
{
create
(
:group
,
plan:
plan_license
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
global_license
)
allow
(
global_license
).
to
receive
(
:features
).
and_return
([
:epics
,
# Gold only
:service_desk
,
# Silver and up
:audit_events
,
# Bronze and up
:geo
,
# Global feature, should not be checked at namespace level
])
end
subject
{
project
.
licensed_features
}
context
'when the namespace should be checked'
do
before
do
enable_namespace_license_check!
end
context
'when bronze'
do
let
(
:plan_license
)
{
:bronze_plan
}
it
'filters for bronze features'
do
is_expected
.
to
contain_exactly
(
:audit_events
,
:geo
)
end
end
context
'when silver'
do
let
(
:plan_license
)
{
:silver_plan
}
it
'filters for silver features'
do
is_expected
.
to
contain_exactly
(
:service_desk
,
:audit_events
,
:geo
)
end
end
context
'when gold'
do
let
(
:plan_license
)
{
:gold_plan
}
it
'filters for gold features'
do
is_expected
.
to
contain_exactly
(
:epics
,
:service_desk
,
:audit_events
,
:geo
)
end
end
context
'when free plan'
do
let
(
:plan_license
)
{
:free_plan
}
it
'filters out paid features'
do
is_expected
.
to
contain_exactly
(
:geo
)
end
context
'when public project and namespace'
do
let
(
:group
)
{
create
(
:group
,
:public
,
plan:
plan_license
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
group:
group
)
}
it
'includes all features in global license'
do
is_expected
.
to
contain_exactly
(
:epics
,
:service_desk
,
:audit_events
,
:geo
)
end
end
end
end
context
'when namespace should not be checked'
do
it
'includes all features in global license'
do
is_expected
.
to
contain_exactly
(
:epics
,
:service_desk
,
:audit_events
,
:geo
)
end
end
context
'when there is no license'
do
before
do
allow
(
License
).
to
receive
(
:current
).
and_return
(
nil
)
end
it
{
is_expected
.
to
be_empty
}
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