Commit 62b3405b authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'jira-user-mapping-fix' into 'master'

Map jira users for server version by 'key' attribute

See merge request gitlab-org/gitlab!66670
parents dd6a3f50 6f8b1979
...@@ -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