Commit 25697fb4 authored by charlie ablett's avatar charlie ablett

Merge branch '339313-fj-linear-version-group-templates-finder-extended-group-search' into 'master'

Use linear version GroupsWithTemplatesFinder#extended_group_search

See merge request gitlab-org/gitlab!68936
parents b9eeae21 b4ea0323
---
name: linear_groups_template_finder_extended_group_search
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68936
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339439
milestone: '14.3'
type: development
group: group::access
default_enabled: false
...@@ -24,8 +24,13 @@ class GroupsWithTemplatesFinder ...@@ -24,8 +24,13 @@ class GroupsWithTemplatesFinder
.base_and_ancestors .base_and_ancestors
.with_feature_available_in_plan(:group_project_templates) .with_feature_available_in_plan(:group_project_templates)
# We're adding an extra query that will be removed once we remove the feature flag in https://gitlab.com/gitlab-org/gitlab/-/issues/339439
if ::Feature.enabled?(:linear_groups_template_finder_extended_group_search, current_group, default_enabled: :yaml)
groups_with_plan.self_and_descendants
else
Gitlab::ObjectHierarchy.new(groups_with_plan).base_and_descendants Gitlab::ObjectHierarchy.new(groups_with_plan).base_and_descendants
end end
end
def simple_group_search(groups) def simple_group_search(groups)
groups = group_id ? groups.find_by(id: group_id)&.self_and_ancestors : groups # rubocop: disable CodeReuse/ActiveRecord groups = group_id ? groups.find_by(id: group_id)&.self_and_ancestors : groups # rubocop: disable CodeReuse/ActiveRecord
...@@ -33,4 +38,9 @@ class GroupsWithTemplatesFinder ...@@ -33,4 +38,9 @@ class GroupsWithTemplatesFinder
groups.with_project_templates groups.with_project_templates
end end
# This method will be removed https://gitlab.com/gitlab-org/gitlab/-/issues/339439
def current_group
Group.find_by(id: group_id) # rubocop:disable CodeReuse/ActiveRecord
end
end end
...@@ -26,6 +26,7 @@ RSpec.describe GroupsWithTemplatesFinder do ...@@ -26,6 +26,7 @@ RSpec.describe GroupsWithTemplatesFinder do
create(:gitlab_subscription, :premium, namespace: group_2) create(:gitlab_subscription, :premium, namespace: group_2)
end end
shared_examples 'group template finder examples' do
describe 'without group id' do describe 'without group id' do
it 'returns all groups' do it 'returns all groups' do
expect(described_class.new.execute).to contain_exactly(group_1, group_2, group_3) expect(described_class.new.execute).to contain_exactly(group_1, group_2, group_3)
...@@ -94,4 +95,15 @@ RSpec.describe GroupsWithTemplatesFinder do ...@@ -94,4 +95,15 @@ RSpec.describe GroupsWithTemplatesFinder do
end end
end end
end end
end
it_behaves_like 'group template finder examples'
context 'when feature flag :linear_groups_template_finder_extended_group_search is disabled' do
before do
stub_feature_flags(linear_groups_template_finder_extended_group_search: false)
end
it_behaves_like 'group template finder examples'
end
end end
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