diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/services/jira_import/cloud_users_mapper_service_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/services/jira_import/cloud_users_mapper_service_spec.rb')
-rw-r--r-- | spec/services/jira_import/cloud_users_mapper_service_spec.rb | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/spec/services/jira_import/cloud_users_mapper_service_spec.rb b/spec/services/jira_import/cloud_users_mapper_service_spec.rb index 591f80f3efc..6b06a982a80 100644 --- a/spec/services/jira_import/cloud_users_mapper_service_spec.rb +++ b/spec/services/jira_import/cloud_users_mapper_service_spec.rb @@ -5,15 +5,44 @@ require 'spec_helper' RSpec.describe JiraImport::CloudUsersMapperService do let(:start_at) { 7 } let(:url) { "/rest/api/2/users?maxResults=50&startAt=#{start_at}" } + + let_it_be(:user_1) { create(:user, username: 'randomuser', name: 'USER-name1', email: 'uji@example.com') } + let_it_be(:user_2) { create(:user, username: 'username-2') } + let_it_be(:user_5) { create(:user, username: 'username-5') } + let_it_be(:user_4) { create(:user, email: 'user-4@example.com') } + let_it_be(:user_6) { create(:user, email: 'user-6@example.com') } + let_it_be(:user_7) { create(:user, username: 'username-7') } + let_it_be(:user_8) do + create(:user).tap { |user| create(:email, user: user, email: 'user8_email@example.com') } + end + + let_it_be(:current_user) { create(:user) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } + let(:jira_users) do [ - { 'accountId' => 'abcd', 'displayName' => 'user1' }, - { 'accountId' => 'efg' }, - { 'accountId' => 'hij', 'displayName' => 'user3', 'emailAddress' => 'user3@example.com' } + { 'accountId' => 'abcd', 'displayName' => 'User-Name1' }, # matched by name + { 'accountId' => 'efg', 'displayName' => 'username-2' }, # matcher by username + { 'accountId' => 'hij' }, # no match + { 'accountId' => '123', 'displayName' => 'user-4', 'emailAddress' => 'user-4@example.com' }, # matched by email + { 'accountId' => '456', 'displayName' => 'username5foo', 'emailAddress' => 'user-5@example.com' }, # no match + { 'accountId' => '789', 'displayName' => 'user-6', 'emailAddress' => 'user-6@example.com' }, # matched by email, no project member + { 'accountId' => 'xyz', 'displayName' => 'username-7', 'emailAddress' => 'user-7@example.com' }, # matched by username, no project member + { 'accountId' => 'vhk', 'displayName' => 'user-8', 'emailAddress' => 'user8_email@example.com' }, # matched by secondary email + { 'accountId' => 'uji', 'displayName' => 'user-9', 'emailAddress' => 'uji@example.com' } # matched by email, same as user_1 ] end describe '#execute' do + before do + project.add_developer(current_user) + project.add_developer(user_1) + project.add_developer(user_2) + group.add_developer(user_4) + group.add_guest(user_8) + end + it_behaves_like 'mapping jira users' end end |