diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-11-08 21:37:01 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-11-08 21:37:01 +0100 |
commit | f37fe2edc80b83513cb9d30b6c97e85c9ccca29c (patch) | |
tree | 85707b99f07dd46fd48ba547af64e4e71ce59950 /spec/lib | |
parent | 48cb1c509686fc40f65ad153f36ab5d22feb63ac (diff) | |
download | gitlab-ce-f37fe2edc80b83513cb9d30b6c97e85c9ccca29c.tar.gz |
Support importing GH projects without rate limitsgithub-rake-task-rate-limiting
GitHub Enterprise disables rate limiting for the API, resulting in HTTP
404 errors when requesting rate limiting details. This changes
Gitlab::GithubImport::Client so it can deal with rate limiting being
disabled.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/github_import/client_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/github_import/client_spec.rb b/spec/lib/gitlab/github_import/client_spec.rb index 9cbd9bcc14e..5b2642d9473 100644 --- a/spec/lib/gitlab/github_import/client_spec.rb +++ b/spec/lib/gitlab/github_import/client_spec.rb @@ -185,6 +185,17 @@ describe Gitlab::GithubImport::Client do client.with_rate_limit { } end + + it 'ignores rate limiting when disabled' do + expect(client) + .to receive(:rate_limiting_enabled?) + .and_return(false) + + expect(client) + .not_to receive(:requests_remaining?) + + expect(client.with_rate_limit { 10 }).to eq(10) + end end describe '#requests_remaining?' do @@ -362,4 +373,20 @@ describe Gitlab::GithubImport::Client do end end end + + describe '#rate_limiting_enabled?' do + let(:client) { described_class.new('foo') } + + it 'returns true when using GitHub.com' do + expect(client.rate_limiting_enabled?).to eq(true) + end + + it 'returns false for GitHub enterprise installations' do + expect(client) + .to receive(:api_endpoint) + .and_return('https://github.kittens.com/') + + expect(client.rate_limiting_enabled?).to eq(false) + end + end end |