Commit 174b9cdd authored by Markus Koller's avatar Markus Koller

Merge branch 'remove_legacy_date_check_from_groups_with_templates_finder' into 'master'

Removed legacy date check from groups_with_templates_finder

Closes #11266

See merge request gitlab-org/gitlab!33826
parents 0c2cb3c1 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
......
...@@ -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
......
...@@ -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'
......
...@@ -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
...@@ -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
......
...@@ -453,7 +453,6 @@ RSpec.describe User do ...@@ -453,7 +453,6 @@ RSpec.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 @@ RSpec.describe User do ...@@ -463,7 +462,6 @@ RSpec.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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment