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
Show 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
# frozen_string_literal: true
class
GroupsWithTemplatesFinder
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
)
def
initialize
(
group_id
=
nil
)
@group_id
=
group_id
@group_id
=
group_id
end
end
def
execute
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
groups
=
extended_group_search
simple_group_search
(
groups
)
simple_group_search
(
groups
)
else
else
...
...
ee/app/models/ee/group.rb
View file @
3f7a5f29
...
@@ -217,8 +217,7 @@ module EE
...
@@ -217,8 +217,7 @@ module EE
end
end
def
group_project_template_available?
def
group_project_template_available?
feature_available?
(
:group_project_templates
)
||
feature_available?
(
:group_project_templates
)
(
custom_project_templates_group_id?
&&
Time
.
zone
.
now
<=
GroupsWithTemplatesFinder
::
CUT_OFF_DATE
)
end
end
def
actual_size_limit
def
actual_size_limit
...
...
ee/spec/features/projects/new_project_spec.rb
View file @
3f7a5f29
...
@@ -373,35 +373,9 @@ RSpec.describe 'New project' do
...
@@ -373,35 +373,9 @@ RSpec.describe 'New project' do
let
(
:template_number
)
{
2
}
let
(
:template_number
)
{
2
}
end
end
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
end
around
do
|
example
|
context
'when not in proper plan'
do
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
let
(
:url
)
{
new_project_path
(
namespace_id:
group1
.
id
)
}
let
(
:url
)
{
new_project_path
(
namespace_id:
group1
.
id
)
}
before
do
before
do
...
@@ -409,12 +383,6 @@ RSpec.describe 'New project' do
...
@@ -409,12 +383,6 @@ RSpec.describe 'New project' do
create
(
:gitlab_subscription
,
:bronze
,
namespace:
group1
)
create
(
:gitlab_subscription
,
:bronze
,
namespace:
group1
)
end
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
it
'show Group tab in Templates section'
do
visit
url
visit
url
click_link
'Create from template'
click_link
'Create from template'
...
...
ee/spec/finders/groups_with_templates_finder_spec.rb
View file @
3f7a5f29
...
@@ -36,17 +36,9 @@ RSpec.describe GroupsWithTemplatesFinder do
...
@@ -36,17 +36,9 @@ RSpec.describe GroupsWithTemplatesFinder do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
end
end
it
'returns all groups before cut-off date'
do
it
'returns groups on gold/silver plan'
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
)
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
)
end
end
end
context
'with subgroup with template'
do
context
'with subgroup with template'
do
before
do
before
do
...
@@ -54,14 +46,12 @@ RSpec.describe GroupsWithTemplatesFinder do
...
@@ -54,14 +46,12 @@ RSpec.describe GroupsWithTemplatesFinder do
create
(
:project
,
namespace:
subgroup_5
)
create
(
:project
,
namespace:
subgroup_5
)
end
end
it
'returns groups on gold/silver plan after cut-off date'
do
it
'returns groups on gold/silver plan'
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
)
expect
(
described_class
.
new
.
execute
).
to
contain_exactly
(
group_1
,
group_2
,
subgroup_4
)
end
end
end
end
end
end
end
end
end
describe
'with group id'
do
describe
'with group id'
do
it
'returns given group with it descendants'
do
it
'returns given group with it descendants'
do
...
@@ -84,17 +74,9 @@ RSpec.describe GroupsWithTemplatesFinder do
...
@@ -84,17 +74,9 @@ RSpec.describe GroupsWithTemplatesFinder do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:should_check_namespace_plan?
)
{
true
}
end
end
it
'returns given group with it descendants before cut-off date'
do
it
'does not return the group'
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
expect
(
described_class
.
new
(
group_3
.
id
).
execute
).
to
be_empty
end
end
end
context
'with subgroup with template'
do
context
'with subgroup with template'
do
before
do
before
do
...
@@ -103,17 +85,13 @@ RSpec.describe GroupsWithTemplatesFinder do
...
@@ -103,17 +85,13 @@ RSpec.describe GroupsWithTemplatesFinder do
end
end
it
'returns only chosen group'
do
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
)
expect
(
described_class
.
new
(
group_1
.
id
).
execute
).
to
contain_exactly
(
group_1
)
end
end
end
it
'returns only chosen subgroup'
do
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
)
expect
(
described_class
.
new
(
subgroup_4
.
id
).
execute
).
to
contain_exactly
(
group_1
,
subgroup_4
)
end
end
end
end
end
end
end
end
end
end
end
ee/spec/models/group_spec.rb
View file @
3f7a5f29
...
@@ -554,24 +554,13 @@ RSpec.describe Group do
...
@@ -554,24 +554,13 @@ RSpec.describe Group do
is_expected
.
to
be
true
is_expected
.
to
be
true
end
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
.
update!
(
custom_project_templates_group_id:
create
(
:group
,
parent:
group
).
id
)
group
.
reload
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
is_expected
.
to
be
false
end
end
end
end
end
context
'unlicensed'
do
context
'unlicensed'
do
before
do
before
do
...
...
ee/spec/models/user_spec.rb
View file @
3f7a5f29
...
@@ -453,7 +453,6 @@ describe User do
...
@@ -453,7 +453,6 @@ describe User do
end
end
it
'returns groups on gold or silver plans'
do
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
.
size
).
to
eq
(
1
)
...
@@ -463,7 +462,6 @@ describe User do
...
@@ -463,7 +462,6 @@ describe User do
end
end
end
end
end
end
end
describe
'#roadmap_layout'
do
describe
'#roadmap_layout'
do
context
'not set'
do
context
'not set'
do
...
...
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