diff options
Diffstat (limited to 'spec/support/shared_examples/services/jira_import')
-rw-r--r-- | spec/support/shared_examples/services/jira_import/user_mapper_services_shared_examples.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/spec/support/shared_examples/services/jira_import/user_mapper_services_shared_examples.rb b/spec/support/shared_examples/services/jira_import/user_mapper_services_shared_examples.rb index 7fc7ff8a8de..cbe5c7d89db 100644 --- a/spec/support/shared_examples/services/jira_import/user_mapper_services_shared_examples.rb +++ b/spec/support/shared_examples/services/jira_import/user_mapper_services_shared_examples.rb @@ -3,7 +3,6 @@ RSpec.shared_examples 'mapping jira users' do let(:client) { double } - let_it_be(:project) { create(:project) } let_it_be(:jira_service) { create(:jira_service, project: project, active: true) } before do @@ -11,7 +10,7 @@ RSpec.shared_examples 'mapping jira users' do allow(client).to receive(:get).with(url).and_return(jira_users) end - subject { described_class.new(jira_service, start_at) } + subject { described_class.new(current_user, project, start_at) } context 'jira_users is nil' do let(:jira_users) { nil } @@ -22,18 +21,27 @@ RSpec.shared_examples 'mapping jira users' do end context 'when jira_users is present' do - # 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 [ - { 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 } + { jira_account_id: 'abcd', jira_display_name: 'User-Name1', jira_email: nil, gitlab_id: user_1.id }, + { jira_account_id: 'efg', jira_display_name: 'username-2', jira_email: nil, gitlab_id: user_2.id }, + { jira_account_id: 'hij', jira_display_name: nil, jira_email: nil, gitlab_id: nil }, + { jira_account_id: '123', jira_display_name: 'user-4', jira_email: 'user-4@example.com', gitlab_id: user_4.id }, + { jira_account_id: '456', jira_display_name: 'username5foo', jira_email: 'user-5@example.com', gitlab_id: nil }, + { jira_account_id: '789', jira_display_name: 'user-6', jira_email: 'user-6@example.com', gitlab_id: nil }, + { jira_account_id: 'xyz', jira_display_name: 'username-7', jira_email: 'user-7@example.com', gitlab_id: nil }, + { jira_account_id: 'vhk', jira_display_name: 'user-8', jira_email: 'user8_email@example.com', gitlab_id: user_8.id }, + { jira_account_id: 'uji', jira_display_name: 'user-9', jira_email: 'uji@example.com', gitlab_id: user_1.id } ] end it 'returns users mapped to Gitlab' do expect(subject.execute).to eq(mapped_users) end + + # 1 query for getting matched users, 3 queries for MembersFinder + it 'runs only 4 queries' do + expect { subject }.not_to exceed_query_limit(4) + end end end |