Skip to content
Snippets Groups Projects
Commit 38a58978 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Fix GItHub client requests when rate limit is disabled

parent 158786ca
No related branches found
No related tags found
No related merge requests found
Loading
@@ -78,6 +78,11 @@ module Gitlab
Loading
@@ -78,6 +78,11 @@ module Gitlab
   
def rate_limit def rate_limit
api.rate_limit! api.rate_limit!
# GitHub Rate Limit API returns 404 when the rate limit is
# disabled. In this case we just want to return gracefully
# instead of spitting out an error.
rescue Octokit::NotFound
OpenStruct.new(remaining: GITHUB_SAFE_REMAINING_REQUESTS + 1)
end end
   
def rate_limit_exceed? def rate_limit_exceed?
Loading
Loading
Loading
@@ -61,4 +61,13 @@ describe Gitlab::GithubImport::Client, lib: true do
Loading
@@ -61,4 +61,13 @@ describe Gitlab::GithubImport::Client, lib: true do
expect(client.api.api_endpoint).to eq 'https://github.company.com/' expect(client.api.api_endpoint).to eq 'https://github.company.com/'
end end
end end
context 'when rate limit is disabled' do
it 'does not raise error' do
stub_request(:get, /api.github.com/)
allow(client.api).to receive(:rate_limit!).and_raise(Octokit::NotFound)
expect { client.issues }.not_to raise_error
end
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment