2020-05-29 17:08:35 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe JiraImport::UsersMapper do
|
2020-05-29 17:08:35 -04:00
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
|
|
|
|
subject { described_class.new(project, jira_users).execute }
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
context 'jira_users is nil' do
|
|
|
|
let(:jira_users) { nil }
|
|
|
|
|
|
|
|
it 'returns an empty array' do
|
|
|
|
expect(subject).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when jira_users is present' do
|
|
|
|
let(:jira_users) do
|
|
|
|
[
|
|
|
|
{ 'accountId' => 'abcd', 'displayName' => 'user1' },
|
|
|
|
{ 'accountId' => 'efg' },
|
|
|
|
{ 'accountId' => 'hij', 'displayName' => 'user3', 'emailAddress' => 'user3@example.com' }
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
# TODO: now we only create an array in a proper format
|
|
|
|
# mapping is tracked in https://gitlab.com/gitlab-org/gitlab/-/issues/219023
|
|
|
|
let(:mapped_users) do
|
|
|
|
[
|
2020-07-13 20:09:46 -04:00
|
|
|
{ jira_account_id: 'abcd', jira_display_name: 'user1', jira_email: nil, gitlab_id: nil, gitlab_username: nil, gitlab_name: nil },
|
|
|
|
{ jira_account_id: 'efg', jira_display_name: nil, jira_email: nil, gitlab_id: nil, gitlab_username: nil, gitlab_name: nil },
|
|
|
|
{ jira_account_id: 'hij', jira_display_name: 'user3', jira_email: 'user3@example.com', gitlab_id: nil, gitlab_username: nil, gitlab_name: nil }
|
2020-05-29 17:08:35 -04:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns users mapped to Gitlab' do
|
|
|
|
expect(subject).to eq(mapped_users)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|