Commit dbcd6df7 authored by Alexandru Croitor's avatar Alexandru Croitor

Remove without_project_namespaces scope on children

Children association already filters project namespaces
parent 1dc44ca6
......@@ -69,7 +69,7 @@ module LoadedInGroupList
end
def subgroup_count
@subgroup_count ||= try(:preloaded_subgroup_count) || children.without_project_namespaces.count
@subgroup_count ||= try(:preloaded_subgroup_count) || children.count
end
def member_count
......
......@@ -25,7 +25,7 @@ RSpec.describe LoadedInGroupList do
context 'with project namespaces' do
let_it_be(:group1) { create(:group, parent: parent) }
let_it_be(:group2) { create(:group, parent: parent) }
let_it_be(:project_namespace) { create(:project_namespace, project: project) }
let_it_be(:project_namespace) { project.project_namespace }
it 'does not include project_namespaces in the count of subgroups' do
expect(found_group.preloaded_subgroup_count).to eq(3)
......
......@@ -253,14 +253,18 @@ RSpec.describe Groups::TransferService, :sidekiq_inline do
expect(transfer_service.error).to eq('Transfer failed: The parent group already has a subgroup or a project with the same path.')
end
context 'with project namespace' do
# currently when a project is created it gets a corresponding project namespace
# so we test the case where a project without a project namespace is transferred
# for backward compatibility
context 'without project namespace' do
before do
project_namespace = project.project_namespace
project.update!(project_namespace_id: nil)
project_namespace.destroy!
project.update_column(:project_namespace_id, nil)
project_namespace.delete
end
it 'adds an error on group' do
expect(project.reload.project_namespace).to be_nil
expect(transfer_service.execute(new_parent_group)).to be_falsy
expect(transfer_service.error).to eq('Transfer failed: Validation failed: Group URL has already been taken')
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