diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/lib/gitlab/github_import_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/lib/gitlab/github_import_spec.rb')
-rw-r--r-- | spec/lib/gitlab/github_import_spec.rb | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/spec/lib/gitlab/github_import_spec.rb b/spec/lib/gitlab/github_import_spec.rb index 662757f66ad..1ea9f003098 100644 --- a/spec/lib/gitlab/github_import_spec.rb +++ b/spec/lib/gitlab/github_import_spec.rb @@ -3,13 +3,17 @@ require 'spec_helper' RSpec.describe Gitlab::GithubImport do + before do + stub_feature_flags(github_importer_lower_per_page_limit: false) + end + context 'github.com' do - let(:project) { double(:project, import_url: 'http://t0ken@github.com/user/repo.git', id: 1) } + let(:project) { double(:project, import_url: 'http://t0ken@github.com/user/repo.git', id: 1, group: nil) } it 'returns a new Client with a custom token' do expect(described_class::Client) .to receive(:new) - .with('123', host: nil, parallel: true) + .with('123', host: nil, parallel: true, per_page: 100) described_class.new_client_for(project, token: '123') end @@ -23,7 +27,7 @@ RSpec.describe Gitlab::GithubImport do expect(described_class::Client) .to receive(:new) - .with('123', host: nil, parallel: true) + .with('123', host: nil, parallel: true, per_page: 100) described_class.new_client_for(project) end @@ -45,12 +49,12 @@ RSpec.describe Gitlab::GithubImport do end context 'GitHub Enterprise' do - let(:project) { double(:project, import_url: 'http://t0ken@github.another-domain.com/repo-org/repo.git') } + let(:project) { double(:project, import_url: 'http://t0ken@github.another-domain.com/repo-org/repo.git', group: nil) } it 'returns a new Client with a custom token' do expect(described_class::Client) .to receive(:new) - .with('123', host: 'http://github.another-domain.com/api/v3', parallel: true) + .with('123', host: 'http://github.another-domain.com/api/v3', parallel: true, per_page: 100) described_class.new_client_for(project, token: '123') end @@ -64,7 +68,7 @@ RSpec.describe Gitlab::GithubImport do expect(described_class::Client) .to receive(:new) - .with('123', host: 'http://github.another-domain.com/api/v3', parallel: true) + .with('123', host: 'http://github.another-domain.com/api/v3', parallel: true, per_page: 100) described_class.new_client_for(project) end @@ -88,4 +92,37 @@ RSpec.describe Gitlab::GithubImport do expect(described_class.formatted_import_url(project)).to eq('http://github.another-domain.com/api/v3') end end + + describe '.per_page' do + context 'when project group is present' do + context 'when github_importer_lower_per_page_limit is enabled' do + it 'returns lower per page value' do + project = create(:project, import_url: 'http://t0ken@github.com/user/repo.git') + group = create(:group, projects: [project]) + + stub_feature_flags(github_importer_lower_per_page_limit: group) + + expect(described_class.per_page(project)).to eq(Gitlab::GithubImport::Client::LOWER_PER_PAGE) + end + end + + context 'when github_importer_lower_per_page_limit is disabled' do + it 'returns default per page value' do + project = double(:project, import_url: 'http://t0ken@github.com/user/repo.git', id: 1, group: create(:group)) + + stub_feature_flags(github_importer_lower_per_page_limit: false) + + expect(described_class.per_page(project)).to eq(Gitlab::GithubImport::Client::DEFAULT_PER_PAGE) + end + end + end + + context 'when project group is missing' do + it 'returns default per page value' do + project = double(:project, import_url: 'http://t0ken@github.com/user/repo.git', id: 1, group: nil) + + expect(described_class.per_page(project)).to eq(Gitlab::GithubImport::Client::DEFAULT_PER_PAGE) + end + end + end end |