Fix order dependency with user params during imports

This commit is contained in:
Liam McAndrew 2019-05-28 10:31:51 +00:00 committed by James Lopez
parent 5fd4415537
commit 5ddb32f382
3 changed files with 17 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
title: Fix order dependency with user params during imports
merge_request: 28719
author:
type: fixed

View file

@ -63,7 +63,7 @@ module Gitlab
'source_id' => @project.id,
'importing' => true,
'access_level' => [member['access_level'], ProjectMember::MAINTAINER].min
)
).except('user_id')
end
def parsed_hash(member)

View file

@ -12,7 +12,6 @@ describe Gitlab::ImportExport::MembersMapper do
"access_level" => 40,
"source_id" => 14,
"source_type" => "Project",
"user_id" => 19,
"notification_level" => 3,
"created_at" => "2016-03-11T10:21:44.822Z",
"updated_at" => "2016-03-11T10:21:44.822Z",
@ -25,7 +24,8 @@ describe Gitlab::ImportExport::MembersMapper do
"id" => exported_user_id,
"email" => user2.email,
"username" => 'test'
}
},
"user_id" => 19
},
{
"id" => 3,
@ -80,6 +80,15 @@ describe Gitlab::ImportExport::MembersMapper do
expect(ProjectMember.find_by_user_id(user2.id).access_level).to eq(ProjectMember::MAINTAINER)
end
it 'removes old user_id from member_hash to avoid conflict with user key' do
expect(ProjectMember).to receive(:create)
.twice
.with(hash_excluding('user_id'))
.and_call_original
members_mapper.map
end
context 'user is not an admin' do
let(:user) { create(:user) }