Commit f566268a authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '70495-fj-use-group_tree-ancestors_linear_scopes' into 'master'

Use GroupTree ancestors linear scopes

See merge request gitlab-org/gitlab!70503
parents aa8d3dd8 c1f9f330
......@@ -38,8 +38,13 @@ module GroupTree
#
# Pagination needs to be applied before loading the ancestors to
# make sure ancestors are not cut off by pagination.
Gitlab::ObjectHierarchy.new(Group.where(id: filtered_groups.select(:id)))
.base_and_ancestors
filtered_groups_relation = Group.where(id: filtered_groups.select(:id))
if Feature.enabled?(:linear_group_tree_ancestor_scopes, current_user, default_enabled: :yaml)
filtered_groups_relation.self_and_ancestors
else
Gitlab::ObjectHierarchy.new(filtered_groups_relation).base_and_ancestors
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
---
name: linear_group_tree_ancestor_scopes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70503
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/341117
milestone: '14.4'
type: development
group: group::access
default_enabled: false
......@@ -21,6 +21,7 @@ RSpec.describe GroupTree do
end
describe 'GET #index' do
shared_examples 'returns filtered groups' do
it 'filters groups' do
other_group = create(:group, name: 'filter')
other_group.add_owner(user)
......@@ -99,4 +100,15 @@ RSpec.describe GroupTree do
end
end
end
it_behaves_like 'returns filtered groups'
context 'when feature flag :linear_group_tree_ancestor_scopes is disabled' do
before do
stub_feature_flags(linear_group_tree_ancestor_scopes: false)
end
it_behaves_like 'returns filtered groups'
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