Commit 71f1e807 authored by James Lopez's avatar James Lopez

Merge branch 'georgekoltsov/always-run-members-mapper' into 'master'

Ensure members mapper always runs on Project Import

See merge request gitlab-org/gitlab!29046
parents 11522d2a ed2f7f84
---
title: Ensure members are always added on Project Import when importing as admin
merge_request: 29046
author:
type: fixed
......@@ -25,6 +25,11 @@ module Gitlab
@project_members = relation_reader.consume_relation(importable_path, 'project_members')
.map(&:first)
# ensure users are mapped before tree restoration
# so that even if there is no content to associate
# users with, they are still added to the project
members_mapper.map
if relation_tree_restorer.restore
import_failure_service.with_retry(action: 'set_latest_merge_request_diff_ids!') do
@project.merge_requests.set_latest_merge_request_diff_ids!
......
......@@ -956,6 +956,37 @@ describe Gitlab::ImportExport::Project::TreeRestorer do
end
end
end
context 'with project members' do
let(:user) { create(:user, :admin) }
let(:user2) { create(:user) }
let(:project_members) do
[
{
"id" => 2,
"access_level" => 40,
"source_type" => "Project",
"notification_level" => 3,
"user" => {
"id" => user2.id,
"email" => user2.email,
"username" => 'test'
}
}
]
end
let(:tree_hash) { { 'project_members' => project_members } }
before do
project.add_maintainer(user)
end
it 'restores project members' do
restorer.restore
expect(project.members.map(&:user)).to contain_exactly(user, user2)
end
end
end
context 'JSON with invalid records' do
......
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