diff options
Diffstat (limited to 'spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb')
-rw-r--r-- | spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb b/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb index 4057aa4ba9e..00b93984f98 100644 --- a/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb +++ b/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb @@ -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) |