Commit 8d1d6aa3 authored by Doug Stull's avatar Doug Stull

Merge branch '339233-fj-use-application_setting-ancestor-linear-scopes' into 'master'

Use ApplicationSetting ancestors linear scopes

See merge request gitlab-org/gitlab!70579
parents 958b6550 d7aaa809
---
name: linear_application_setting_ancestor_scopes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/70579
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/341346
milestone: '14.4'
type: development
group: group::access
default_enabled: false
......@@ -384,11 +384,14 @@ module EE
private
def elasticsearch_limited_project_exists?(project)
indexed_namespaces = ::Gitlab::ObjectHierarchy
.new(::Namespace.where(id: project.namespace_id))
.base_and_ancestors
.joins(:elasticsearch_indexed_namespace)
project_namespaces = ::Namespace.where(id: project.namespace_id)
indexed_namespaces = if ::Feature.enabled?(:linear_application_setting_ancestor_scopes, default_enabled: :yaml)
project_namespaces.self_and_ancestors
else
::Gitlab::ObjectHierarchy.new(project_namespaces).base_and_ancestors
end
indexed_namespaces = indexed_namespaces.joins(:elasticsearch_indexed_namespace)
indexed_namespaces = ::Project.where('EXISTS (?)', indexed_namespaces)
indexed_projects = ::Project.where('EXISTS (?)', ElasticsearchIndexedProject.where(project_id: project.id))
......
......@@ -427,31 +427,43 @@ RSpec.describe ApplicationSetting do
end
describe '#elasticsearch_indexes_project?' do
context 'when project is in a subgroup' do
let(:root_group) { create(:group) }
let(:subgroup) { create(:group, parent: root_group) }
let(:project) { create(:project, group: subgroup) }
before do
create(:elasticsearch_indexed_namespace, namespace: root_group)
shared_examples 'whether the project is indexed' do
context 'when project is in a subgroup' do
let(:root_group) { create(:group) }
let(:subgroup) { create(:group, parent: root_group) }
let(:project) { create(:project, group: subgroup) }
before do
create(:elasticsearch_indexed_namespace, namespace: root_group)
end
it 'allows project to be indexed' do
expect(setting.elasticsearch_indexes_project?(project)).to be(true)
end
end
it 'allows project to be indexed' do
expect(setting.elasticsearch_indexes_project?(project)).to be(true)
context 'when project is in a namespace' do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, namespace: namespace) }
before do
create(:elasticsearch_indexed_namespace, namespace: namespace)
end
it 'allows project to be indexed' do
expect(setting.elasticsearch_indexes_project?(project)).to be(true)
end
end
end
context 'when project is in a namespace' do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, namespace: namespace) }
it_behaves_like 'whether the project is indexed'
context 'when feature flag :linear_application_setting_ancestor_scopes is disabled' do
before do
create(:elasticsearch_indexed_namespace, namespace: namespace)
stub_feature_flags(linear_application_setting_ancestor_scopes: false)
end
it 'allows project to be indexed' do
expect(setting.elasticsearch_indexes_project?(project)).to be(true)
end
it_behaves_like 'whether the project is indexed'
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