Commit 3d9c43f1 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '263442_remove_recursive_approach_for_all_projects_feature_flag' into 'master'

Remove recursive_approach_for_all_projects FF [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!55043
parents 01032275 dea6a864
......@@ -259,12 +259,8 @@ class Namespace < ApplicationRecord
# Includes projects from this namespace and projects from all subgroups
# that belongs to this namespace
def all_projects
if Feature.enabled?(:recursive_approach_for_all_projects)
namespace = user? ? self : self_and_descendants
Project.where(namespace: namespace)
else
Project.inside_path(full_path)
end
namespace = user? ? self : self_and_descendants
Project.where(namespace: namespace)
end
# Includes pipelines from this namespace and pipelines from all subgroups
......
---
title: Use recursive approach to query all projects for a namespace
merge_request: 55043
author:
type: performance
---
name: recursive_approach_for_all_projects
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/44740
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/263442
milestone: '13.5'
type: development
group: group::fulfillment
default_enabled: false
......@@ -833,7 +833,7 @@ RSpec.describe Namespace do
end
describe '#all_projects' do
shared_examples 'all projects for a group' do
context 'when namespace is a group' do
let(:namespace) { create(:group) }
let(:child) { create(:group, parent: namespace) }
let!(:project1) { create(:project_empty_repo, namespace: namespace) }
......@@ -841,49 +841,25 @@ RSpec.describe Namespace do
it { expect(namespace.all_projects.to_a).to match_array([project2, project1]) }
it { expect(child.all_projects.to_a).to match_array([project2]) }
it 'queries for the namespace and its descendants' do
expect(Project).to receive(:where).with(namespace: [namespace, child])
namespace.all_projects
end
end
shared_examples 'all projects for personal namespace' do
context 'when namespace is a user namespace' do
let_it_be(:user) { create(:user) }
let_it_be(:user_namespace) { create(:namespace, owner: user) }
let_it_be(:project) { create(:project, namespace: user_namespace) }
it { expect(user_namespace.all_projects.to_a).to match_array([project]) }
end
context 'with recursive approach' do
context 'when namespace is a group' do
include_examples 'all projects for a group'
it 'queries for the namespace and its descendants' do
expect(Project).to receive(:where).with(namespace: [namespace, child])
namespace.all_projects
end
end
context 'when namespace is a user namespace' do
include_examples 'all projects for personal namespace'
it 'only queries for the namespace itself' do
expect(Project).to receive(:where).with(namespace: user_namespace)
user_namespace.all_projects
end
end
end
context 'with route path wildcard approach' do
before do
stub_feature_flags(recursive_approach_for_all_projects: false)
end
context 'when namespace is a group' do
include_examples 'all projects for a group'
end
it 'only queries for the namespace itself' do
expect(Project).to receive(:where).with(namespace: user_namespace)
context 'when namespace is a user namespace' do
include_examples 'all projects for personal namespace'
user_namespace.all_projects
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