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
3f7a5f29
Commit
3f7a5f29
authored
Jun 05, 2020
by
Lee Tickett
Committed by
Markus Koller
Jun 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed legacy date check from groups_with_templates_finder
parent
ad256ac4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
88 deletions
+16
-88
ee/app/finders/groups_with_templates_finder.rb
ee/app/finders/groups_with_templates_finder.rb
+1
-5
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+1
-2
ee/spec/features/projects/new_project_spec.rb
ee/spec/features/projects/new_project_spec.rb
+1
-33
ee/spec/finders/groups_with_templates_finder_spec.rb
ee/spec/finders/groups_with_templates_finder_spec.rb
+8
-30
ee/spec/models/group_spec.rb
ee/spec/models/group_spec.rb
+2
-13
ee/spec/models/user_spec.rb
ee/spec/models/user_spec.rb
+3
-5
No files found.
ee/app/finders/groups_with_templates_finder.rb
View file @
3f7a5f29
# frozen_string_literal: true
class
GroupsWithTemplatesFinder
# We need to provide grace period for users who are now using group_project_template
# feature in free groups.
CUT_OFF_DATE
=
Date
.
parse
(
'2019/05/22'
)
+
3
.
months
def
initialize
(
group_id
=
nil
)
@group_id
=
group_id
end
def
execute
if
::
Gitlab
::
CurrentSettings
.
should_check_namespace_plan?
&&
Time
.
zone
.
now
>
CUT_OFF_DATE
if
::
Gitlab
::
CurrentSettings
.
should_check_namespace_plan?
groups
=
extended_group_search
simple_group_search
(
groups
)
else
...
...
ee/app/models/ee/group.rb
View file @
3f7a5f29
...
...
@@ -217,8 +217,7 @@ module EE
end
def
group_project_template_available?
feature_available?
(
:group_project_templates
)
||
(
custom_project_templates_group_id?
&&
Time
.
zone
.
now
<=
GroupsWithTemplatesFinder
::
CUT_OFF_DATE
)
feature_available?
(
:group_project_templates
)
end
def
actual_size_limit
...
...
ee/spec/features/projects/new_project_spec.rb
View file @
3f7a5f29
...
...
@@ -373,35 +373,9 @@ RSpec.describe 'New project' do
let
(
:template_number
)
{
2
}
end
end
context
'when creating project with templates'
do
let
(
:url
)
{
new_project_path
(
namespace_id:
group1
.
id
)
}
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
create
(
:gitlab_subscription
,
:bronze
,
namespace:
group1
)
end
around
do
|
example
|
Timecop
.
freeze
(
GroupsWithTemplatesFinder
::
CUT_OFF_DATE
-
1
.
day
)
do
example
.
run
end
end
it
'show Group tab in Templates section'
do
visit
url
click_link
'Create from template'
expect
(
page
).
to
have_css
(
'.custom-group-project-templates-tab'
)
end
it_behaves_like
'group templates displayed'
do
let
(
:template_number
)
{
2
}
end
end
end
context
'when
creating project with templates after grace period
'
do
context
'when
not in proper plan
'
do
let
(
:url
)
{
new_project_path
(
namespace_id:
group1
.
id
)
}
before
do
...
...
@@ -409,12 +383,6 @@ RSpec.describe 'New project' do
create
(
:gitlab_subscription
,
:bronze
,
namespace:
group1
)
end
around
do
|
example
|
Timecop
.
freeze
(
GroupsWithTemplatesFinder
::
CUT_OFF_DATE
+
1
.
day
)
do
example
.
run
end
end
it
'show Group tab in Templates section'
do
visit
url
click_link
'Create from template'
...
...
ee/spec/finders/groups_with_templates_finder_spec.rb
View file @
3f7a5f29
...
...
@@ -36,16 +36,8 @@ RSpec.describe GroupsWithTemplatesFinder do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
end
it
'returns all groups before 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
,
group_3
)
end
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
)
end
it
'returns groups on gold/silver plan'
do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
)
end
context
'with subgroup with template'
do
...
...
@@ -54,10 +46,8 @@ RSpec.describe GroupsWithTemplatesFinder do
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
it
'returns groups on gold/silver plan'
do
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
,
subgroup_4
)
end
end
end
...
...
@@ -84,16 +74,8 @@ RSpec.describe GroupsWithTemplatesFinder do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
end
it
'returns given group with it descendants before cut-off date'
do
Timecop
.
freeze
(
described_class
::
CUT_OFF_DATE
-
1
.
day
)
do
expect
(
described_class
.
new
(
group_3
.
id
).
execute
).
to
contain_exactly
(
group_3
)
end
end
it
'does not return the group after the cut-off date'
do
Timecop
.
freeze
(
described_class
::
CUT_OFF_DATE
+
1
.
day
)
do
expect
(
described_class
.
new
(
group_3
.
id
).
execute
).
to
be_empty
end
it
'does not return the group'
do
expect
(
described_class
.
new
(
group_3
.
id
).
execute
).
to
be_empty
end
context
'with subgroup with template'
do
...
...
@@ -103,15 +85,11 @@ RSpec.describe GroupsWithTemplatesFinder do
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
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
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
expect
(
described_class
.
new
(
subgroup_4
.
id
).
execute
).
to
contain_exactly
(
group_1
,
subgroup_4
)
end
end
end
...
...
ee/spec/models/group_spec.rb
View file @
3f7a5f29
...
...
@@ -554,22 +554,11 @@ RSpec.describe Group do
is_expected
.
to
be
true
end
it
'returns
true for groups with group template already set within grace period
'
do
it
'returns
false for groups with group template already set but not in proper plan
'
do
group
.
update!
(
custom_project_templates_group_id:
create
(
:group
,
parent:
group
).
id
)
group
.
reload
Timecop
.
freeze
(
GroupsWithTemplatesFinder
::
CUT_OFF_DATE
-
1
.
day
)
do
is_expected
.
to
be
true
end
end
it
'returns false for groups with group template already set after grace period'
do
group
.
update!
(
custom_project_templates_group_id:
create
(
:group
,
parent:
group
).
id
)
group
.
reload
Timecop
.
freeze
(
GroupsWithTemplatesFinder
::
CUT_OFF_DATE
+
1
.
day
)
do
is_expected
.
to
be
false
end
is_expected
.
to
be
false
end
end
...
...
ee/spec/models/user_spec.rb
View file @
3f7a5f29
...
...
@@ -453,12 +453,10 @@ describe User do
end
it
'returns groups on gold or silver plans'
do
Timecop
.
freeze
(
GroupsWithTemplatesFinder
::
CUT_OFF_DATE
+
1
.
day
)
do
groups
=
user
.
available_subgroups_with_custom_project_templates
groups
=
user
.
available_subgroups_with_custom_project_templates
expect
(
groups
.
size
).
to
eq
(
1
)
expect
(
groups
.
map
(
&
:name
)).
to
include
(
'subgroup-2'
)
end
expect
(
groups
.
size
).
to
eq
(
1
)
expect
(
groups
.
map
(
&
:name
)).
to
include
(
'subgroup-2'
)
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