Commit fa101583 authored by Stan Hu's avatar Stan Hu

Merge branch 'cngo-fix-jira-import-users-startat' into 'master'

Fix jira import users startAt parameter

See merge request gitlab-org/gitlab!37492
parents 6d638edf 035453e3
......@@ -104,7 +104,6 @@ export default {
variables: {
input: {
projectPath: this.projectPath,
startAt: 1,
},
},
})
......
......@@ -19,10 +19,10 @@ module Mutations
required: false,
description: 'The index of the record the import should started at, default 0 (50 records returned)'
def resolve(project_path:, start_at:)
def resolve(project_path:, start_at: 0)
project = authorized_find!(full_path: project_path)
service_response = ::JiraImport::UsersImporter.new(context[:current_user], project, start_at).execute
service_response = ::JiraImport::UsersImporter.new(context[:current_user], project, start_at.to_i).execute
{
jira_users: service_response.payload,
......
---
title: Fix JiraImportUsersInput startAt field
merge_request: 37492
author:
type: fixed
......@@ -306,7 +306,6 @@ describe('JiraImportApp', () => {
variables: {
input: {
projectPath: 'gitlab-org/gitlab-test',
startAt: 1,
},
},
};
......
......@@ -8,15 +8,17 @@ RSpec.describe 'Importing Jira Users' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let(:importer) { instance_double(JiraImport::UsersImporter) }
let(:project_path) { project.full_path }
let(:start_at) { 7 }
let(:mutation) do
variables = {
let(:variables) do
{
start_at: start_at,
project_path: project_path
}
end
let(:mutation) do
graphql_mutation(:jira_import_users, variables)
end
......@@ -65,9 +67,38 @@ RSpec.describe 'Importing Jira Users' do
end
end
context 'when all params and permissions are ok' do
let(:importer) { instance_double(JiraImport::UsersImporter) }
context 'with start_at' do
RSpec.shared_examples 'start users import at zero' do
it 'returns imported users' do
users = [{ jira_account_id: '12a', jira_display_name: 'user 1' }]
result = ServiceResponse.success(payload: users)
expect(importer).to receive(:execute).and_return(result)
expect(JiraImport::UsersImporter).to receive(:new).with(current_user, project, 0).and_return(importer)
post_graphql_mutation(mutation, current_user: current_user)
end
end
context 'when nil' do
let(:variables) do
{
start_at: nil,
project_path: project_path
}
end
it_behaves_like 'start users import at zero'
end
context 'when not provided' do
let(:variables) { { project_path: project_path } }
it_behaves_like 'start users import at zero'
end
end
context 'when all params and permissions are ok' do
before do
expect(JiraImport::UsersImporter).to receive(:new).with(current_user, project, 7)
.and_return(importer)
......
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