summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/unreleased/fix-import-param-ordering.yml5
-rw-r--r--lib/gitlab/import_export/members_mapper.rb2
-rw-r--r--spec/lib/gitlab/import_export/members_mapper_spec.rb13
3 files changed, 17 insertions, 3 deletions
diff --git a/changelogs/unreleased/fix-import-param-ordering.yml b/changelogs/unreleased/fix-import-param-ordering.yml
new file mode 100644
index 00000000000..47e32cda977
--- /dev/null
+++ b/changelogs/unreleased/fix-import-param-ordering.yml
@@ -0,0 +1,5 @@
+---
+title: Fix order dependency with user params during imports
+merge_request: 28719
+author:
+type: fixed
diff --git a/lib/gitlab/import_export/members_mapper.rb b/lib/gitlab/import_export/members_mapper.rb
index 5ab5059165e..a154de5419e 100644
--- a/lib/gitlab/import_export/members_mapper.rb
+++ b/lib/gitlab/import_export/members_mapper.rb
@@ -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)
diff --git a/spec/lib/gitlab/import_export/members_mapper_spec.rb b/spec/lib/gitlab/import_export/members_mapper_spec.rb
index c663cf42a83..b95b5dfe791 100644
--- a/spec/lib/gitlab/import_export/members_mapper_spec.rb
+++ b/spec/lib/gitlab/import_export/members_mapper_spec.rb
@@ -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) }