Commit e349c0c9 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'sh-fix-dedupe-group-importer' into 'master'

Fix importers not assigning a new default group

Closes #50110

See merge request gitlab-org/gitlab-ce!21456
parents d76b23af 965f9113
......@@ -55,7 +55,7 @@ module NamespacesHelper
# group if one exists by that name to prevent duplicates.
def dedup_extra_group(extra_group)
unless extra_group.persisted?
existing_group = Group.find_by(name: extra_group.name)
existing_group = Group.find_by(path: extra_group.path)
extra_group = existing_group if existing_group&.persisted?
end
......
---
title: Fix importers not assigning a new default group
merge_request: 21456
author:
type: fixed
......@@ -50,9 +50,12 @@ describe NamespacesHelper do
end
it 'selects the new group by default' do
# Ensure we don't select a group with the same name
create(:group, name: 'new-group', path: 'another-path')
allow(helper).to receive(:current_user).and_return(user)
options = helper.namespaces_options(:extra_group, display_path: true, extra_group: build(:group, name: 'new-group'))
options = helper.namespaces_options(:extra_group, display_path: true, extra_group: build(:group, name: 'new-group', path: 'new-group'))
expect(options).to include(user_group.name)
expect(options).not_to include(admin_group.name)
......
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