Commit efdca2e6 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'fix-import-member-access' into 'master'

Fix issue importing members with owner access

Closes #61715

See merge request gitlab-org/gitlab-ce!28636
parents bd1ef521 30d91511
---
title: Fix issue importing members with owner access
merge_request: 28636
author:
type: fixed
......@@ -23,6 +23,7 @@
> in the import side is required to map the users, based on email or username.
> Otherwise, a supplementary comment is left to mention the original author and
> the MRs, notes or issues will be owned by the importer.
> - Project members with owner access will get imported as maintainers.
> - Control project Import/Export with the [API](../../../api/project_import_export.md).
> - If an imported project contains merge requests originated from forks,
> then new branches associated with such merge requests will be created
......
......@@ -59,7 +59,11 @@ module Gitlab
end
def member_hash(member)
parsed_hash(member).merge('source_id' => @project.id, 'importing' => true)
parsed_hash(member).merge(
'source_id' => @project.id,
'importing' => true,
'access_level' => [member['access_level'], ProjectMember::MAINTAINER].min
)
end
def parsed_hash(member)
......
......@@ -73,6 +73,13 @@ describe Gitlab::ImportExport::MembersMapper do
expect(user2.authorized_project?(project)).to be true
end
it 'maps an owner as a maintainer' do
exported_members.first['access_level'] = ProjectMember::OWNER
expect(members_mapper.map[exported_user_id]).to eq(user2.id)
expect(ProjectMember.find_by_user_id(user2.id).access_level).to eq(ProjectMember::MAINTAINER)
end
context 'user is not an admin' do
let(:user) { create(:user) }
......
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