Commit 59672bed authored by Corinna Wiesner's avatar Corinna Wiesner

Add spec for user namespace and refactor specs

parent 5ee6d0fb
......@@ -855,42 +855,48 @@ RSpec.describe Namespace do
end
describe '#all_projects' do
shared_examples 'all projects for a namespace' do
let(:namespace) { create(:namespace) }
let(:child) { create(:group, parent: namespace) }
let!(:project1) { create(:project_empty_repo, namespace: namespace) }
let!(:project2) { create(:project_empty_repo, namespace: child) }
shared_examples 'all projects for a 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]) }
end
context 'with recursive approach' do
before do
stub_feature_flags(recursive_approach_for_all_projects: true)
end
shared_examples 'all project examples' do
include_examples 'all projects for a namespace'
context 'when namespace is a group' do
let(:namespace) { create(:group) }
let_it_be(:namespace) { create(:group) }
include_examples 'all projects for a namespace'
end
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
end
context 'with route path wildcard approach' do
context 'with recursive approach' do
before do
stub_feature_flags(recursive_approach_for_all_projects: false)
stub_feature_flags(recursive_approach_for_all_projects: true)
end
include_examples 'all projects for a namespace'
context 'when namespace is a group' do
let_it_be(:namespace) { create(:group) }
include_examples 'all project examples'
end
include_examples 'all projects for a namespace'
context 'with route path wildcard approach' do
before do
stub_feature_flags(recursive_approach_for_all_projects: false)
end
include_examples 'all project examples'
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