diff options
Diffstat (limited to 'spec/models/namespace_spec.rb')
-rw-r--r-- | spec/models/namespace_spec.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 56afe49e15f..b9cfd95f89c 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -1010,7 +1010,7 @@ RSpec.describe Namespace do end end - describe '#all_projects' do + shared_examples '#all_projects' do context 'when namespace is a group' do let(:namespace) { create(:group) } let(:child) { create(:group, parent: namespace) } @@ -1019,12 +1019,6 @@ 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 context 'when namespace is a user namespace' do @@ -1033,12 +1027,20 @@ RSpec.describe Namespace do let_it_be(:project) { create(:project, namespace: user_namespace) } it { expect(user_namespace.all_projects.to_a).to match_array([project]) } + end + end - it 'only queries for the namespace itself' do - expect(Project).to receive(:where).with(namespace: user_namespace) + describe '#all_projects' do + context 'when recursive approach is enabled' do + include_examples '#all_projects' + end - user_namespace.all_projects + context 'when recursive approach is disabled' do + before do + stub_feature_flags(recursive_approach_for_all_projects: false) end + + include_examples '#all_projects' end end |