Commit 69adeb37 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'georgekoltsov/64377-add-better-log-msg-to-members-mapper' into 'master'

Add better error message to MembersMapper#ensure_default_member!

See merge request gitlab-org/gitlab-ce!30838
parents 1a3fda63 3463c24d
---
title: When GitLab import fails during importer user mapping step, add an explicit
error message mentioning importer
merge_request: 30838
author:
type: other
...@@ -50,6 +50,8 @@ module Gitlab ...@@ -50,6 +50,8 @@ module Gitlab
@project.project_members.destroy_all # rubocop: disable DestroyAll @project.project_members.destroy_all # rubocop: disable DestroyAll
ProjectMember.create!(user: @user, access_level: ProjectMember::MAINTAINER, source_id: @project.id, importing: true) ProjectMember.create!(user: @user, access_level: ProjectMember::MAINTAINER, source_id: @project.id, importing: true)
rescue => e
raise e, "Error adding importer user to project members. #{e.message}"
end end
def add_team_member(member, existing_user = nil) def add_team_member(member, existing_user = nil)
......
...@@ -154,5 +154,15 @@ describe Gitlab::ImportExport::MembersMapper do ...@@ -154,5 +154,15 @@ describe Gitlab::ImportExport::MembersMapper do
expect(members_mapper.map[exported_user_id]).to eq(user2.id) expect(members_mapper.map[exported_user_id]).to eq(user2.id)
end end
end end
context 'when importer mapping fails' do
let(:exception_message) { 'Something went wrong' }
it 'includes importer specific error message' do
expect(ProjectMember).to receive(:create!).and_raise(StandardError.new(exception_message))
expect { members_mapper.map }.to raise_error(StandardError, "Error adding importer user to project members. #{exception_message}")
end
end
end end
end end
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