Commit 6f8b1979 authored by Alexandru Croitor's avatar Alexandru Croitor

Map jira users for server version by 'key' attribute

In Jira Cloud user identifier is returned in 'accountId' attribute
while in Jira Server it is being returned in 'key' attribute. This
fixes the user mapping for jira issues import from Jira Server instance.

Changelog: fixed
parent 7678d206
...@@ -52,9 +52,10 @@ module Gitlab ...@@ -52,9 +52,10 @@ module Gitlab
end end
def map_user_id(jira_user) def map_user_id(jira_user)
return unless jira_user&.dig('accountId') jira_user_identifier = jira_user&.dig('accountId') || jira_user&.dig('key')
return unless jira_user_identifier
Gitlab::JiraImport.get_user_mapping(project.id, jira_user['accountId']) Gitlab::JiraImport.get_user_mapping(project.id, jira_user_identifier)
end end
def reporter def reporter
......
...@@ -192,6 +192,19 @@ RSpec.describe Gitlab::JiraImport::IssueSerializer do ...@@ -192,6 +192,19 @@ RSpec.describe Gitlab::JiraImport::IssueSerializer do
expect(subject[:assignee_ids]).to be_nil expect(subject[:assignee_ids]).to be_nil
end end
end end
context 'with jira server response' do
let(:assignee) { double(attrs: { 'displayName' => 'Solver', 'key' => '1234' }) }
context 'when assignee maps to a valid GitLab user' do
it 'sets the issue assignees to the mapped user' do
expect(Gitlab::JiraImport).to receive(:get_user_mapping).with(project.id, '1234')
.and_return(user.id)
expect(subject[:assignee_ids]).to eq([user.id])
end
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