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
61eddb69
Commit
61eddb69
authored
Aug 28, 2019
by
Gosia Ksionek
Committed by
James Lopez
Aug 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure groups with templates finder returns subgroups
When subgroup is a descendant of a paid group Fix errors
parent
aebcb96b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
13 deletions
+75
-13
ee/app/finders/groups_with_templates_finder.rb
ee/app/finders/groups_with_templates_finder.rb
+16
-6
ee/changelogs/unreleased/13735-make-templates-available-for-subgroups.yml
...released/13735-make-templates-available-for-subgroups.yml
+5
-0
ee/spec/finders/groups_with_templates_finder_spec.rb
ee/spec/finders/groups_with_templates_finder_spec.rb
+53
-7
ee/spec/models/namespace_spec.rb
ee/spec/models/namespace_spec.rb
+1
-0
No files found.
ee/app/finders/groups_with_templates_finder.rb
View file @
61eddb69
...
...
@@ -9,17 +9,27 @@ class GroupsWithTemplatesFinder
end
def
execute
groups
=
@group_id
?
::
Group
.
find
(
group_id
).
self_and_ancestors
:
::
Group
.
all
groups
=
groups
.
with_project_templates
if
::
Gitlab
::
CurrentSettings
.
should_check_namespace_plan?
&&
Time
.
zone
.
now
>
CUT_OFF_DATE
groups
=
groups
.
with_feature_available_in_plan
(
:group_project_templates
)
groups
=
extended_group_search
simple_group_search
(
groups
)
else
simple_group_search
(
Group
.
all
)
end
groups
end
private
attr_reader
:group_id
def
extended_group_search
groups
=
Group
.
with_feature_available_in_plan
(
:group_project_templates
)
Gitlab
::
ObjectHierarchy
.
new
(
groups
).
base_and_descendants
end
def
simple_group_search
(
groups
)
groups
=
group_id
?
groups
.
find_by
(
id:
group_id
)
&
.
self_and_ancestors
:
groups
# rubocop: disable CodeReuse/ActiveRecord
return
Group
.
none
unless
groups
groups
.
with_project_templates
end
end
ee/changelogs/unreleased/13735-make-templates-available-for-subgroups.yml
0 → 100644
View file @
61eddb69
---
title
:
Make sure groups with templates finder returns subgroups
merge_request
:
15631
author
:
type
:
fixed
ee/spec/finders/groups_with_templates_finder_spec.rb
View file @
61eddb69
...
...
@@ -3,14 +3,17 @@
require
'spec_helper'
describe
GroupsWithTemplatesFinder
do
l
et
(
:group_1
)
{
create
(
:group
,
name:
'group-1'
)
}
l
et
(
:group_2
)
{
create
(
:group
,
name:
'group-2'
)
}
l
et
(
:group_3
)
{
create
(
:group
,
name:
'group-3'
)
}
let!
(
:group_4
)
{
create
(
:group
,
name:
'group-4'
)
}
s
et
(
:group_1
)
{
create
(
:group
,
name:
'group-1'
)
}
s
et
(
:group_2
)
{
create
(
:group
,
name:
'group-2'
)
}
s
et
(
:group_3
)
{
create
(
:group
,
name:
'group-3'
)
}
set
(
:group_4
)
{
create
(
:group
,
name:
'group-4'
)
}
let!
(
:subgroup_1
)
{
create
(
:group
,
parent:
group_1
,
name:
'subgroup-1'
)
}
let!
(
:subgroup_2
)
{
create
(
:group
,
parent:
group_2
,
name:
'subgroup-2'
)
}
let!
(
:subgroup_3
)
{
create
(
:group
,
parent:
group_3
,
name:
'subgroup-3'
)
}
set
(
:subgroup_1
)
{
create
(
:group
,
parent:
group_1
,
name:
'subgroup-1'
)
}
set
(
:subgroup_2
)
{
create
(
:group
,
parent:
group_2
,
name:
'subgroup-2'
)
}
set
(
:subgroup_3
)
{
create
(
:group
,
parent:
group_3
,
name:
'subgroup-3'
)
}
set
(
:subgroup_4
)
{
create
(
:group
,
parent:
group_1
,
name:
'subgroup-4'
)
}
set
(
:subgroup_5
)
{
create
(
:group
,
parent:
subgroup_4
,
name:
'subgroup-5'
)
}
before
do
group_1
.
update!
(
custom_project_templates_group_id:
subgroup_1
.
id
)
...
...
@@ -44,6 +47,19 @@ describe GroupsWithTemplatesFinder do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
)
end
end
context
'with subgroup with template'
do
before
do
subgroup_4
.
update!
(
custom_project_templates_group_id:
subgroup_5
.
id
)
create
(
:project
,
namespace:
subgroup_5
)
end
it
'returns groups on gold/silver plan after cut-off date'
do
Timecop
.
freeze
(
described_class
::
CUT_OFF_DATE
+
1
.
day
)
do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
,
subgroup_4
)
end
end
end
end
end
...
...
@@ -52,6 +68,17 @@ describe GroupsWithTemplatesFinder do
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
end
context
'with subgroup with template'
do
before
do
subgroup_4
.
update!
(
custom_project_templates_group_id:
subgroup_5
.
id
)
create
(
:project
,
namespace:
subgroup_5
)
end
it
'returns only chosen group'
do
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
end
end
context
'when namespace checked'
do
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
...
...
@@ -68,6 +95,25 @@ describe GroupsWithTemplatesFinder do
expect
(
described_class
.
new
(
group_3
.
id
).
execute
).
to
be_empty
end
end
context
'with subgroup with template'
do
before
do
subgroup_4
.
update!
(
custom_project_templates_group_id:
subgroup_5
.
id
)
create
(
:project
,
namespace:
subgroup_5
)
end
it
'returns only chosen group'
do
Timecop
.
freeze
(
described_class
::
CUT_OFF_DATE
+
1
.
day
)
do
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
end
end
it
'returns only chosen subgroup'
do
Timecop
.
freeze
(
described_class
::
CUT_OFF_DATE
+
1
.
day
)
do
expect
(
described_class
.
new
(
subgroup_4
.
id
).
execute
).
to
contain_exactly
(
group_1
,
subgroup_4
)
end
end
end
end
end
end
ee/spec/models/namespace_spec.rb
View file @
61eddb69
...
...
@@ -70,6 +70,7 @@ describe Namespace do
it
'returns namespaces with plan'
do
create
(
:gitlab_subscription
,
:bronze
,
namespace:
namespace
)
create
(
:gitlab_subscription
,
:free
,
namespace:
create
(
:namespace
))
expect
(
described_class
.
with_feature_available_in_plan
(
:audit_events
)).
to
eq
([
namespace
])
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