Commit 5ddb32f3 authored by Liam McAndrew's avatar Liam McAndrew Committed by James Lopez

Fix order dependency with user params during imports

parent 5fd44155
---
title: Fix order dependency with user params during imports
merge_request: 28719
author:
type: fixed
......@@ -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)
......
......@@ -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) }
......
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