diff options
Diffstat (limited to 'spec/requests/api/import_github_spec.rb')
-rw-r--r-- | spec/requests/api/import_github_spec.rb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/requests/api/import_github_spec.rb b/spec/requests/api/import_github_spec.rb index 9b5ae72526c..e394b92c0a2 100644 --- a/spec/requests/api/import_github_spec.rb +++ b/spec/requests/api/import_github_spec.rb @@ -5,7 +5,8 @@ require 'spec_helper' RSpec.describe API::ImportGithub, feature_category: :importers do let(:token) { "asdasd12345" } let(:provider) { :github } - let(:access_params) { { github_access_token: token } } + let(:access_params) { { github_access_token: token, additional_access_tokens: additional_access_tokens } } + let(:additional_access_tokens) { nil } let(:provider_username) { user.username } let(:provider_user) { double('provider', login: provider_username).as_null_object } let(:provider_repo) do @@ -51,7 +52,7 @@ RSpec.describe API::ImportGithub, feature_category: :importers do it 'returns 201 response when the project is imported successfully' do allow(Gitlab::LegacyGithubImport::ProjectCreator) .to receive(:new).with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **access_params) - .and_return(double(execute: project)) + .and_return(double(execute: project)) post api("/import/github", user), params: { target_namespace: user.namespace_path, @@ -120,6 +121,28 @@ RSpec.describe API::ImportGithub, feature_category: :importers do expect(response).to have_gitlab_http_status(:unauthorized) end end + + context 'when additional access tokens are provided' do + let(:additional_access_tokens) { 'token1,token2' } + + it 'returns 201' do + expected_access_params = { github_access_token: token, additional_access_tokens: %w[token1 token2] } + + expect(Gitlab::LegacyGithubImport::ProjectCreator) + .to receive(:new) + .with(provider_repo, provider_repo[:name], user.namespace, user, type: provider, **expected_access_params) + .and_return(double(execute: project)) + + post api("/import/github", user), params: { + target_namespace: user.namespace_path, + personal_access_token: token, + repo_id: non_existing_record_id, + additional_access_tokens: 'token1,token2' + } + + expect(response).to have_gitlab_http_status(:created) + end + end end describe "POST /import/github/cancel" do |