Fix GItHub client requests when rate limit is disabled

parent 158786ca
......@@ -78,6 +78,11 @@ module Gitlab
def 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
def rate_limit_exceed?
......
......@@ -61,4 +61,13 @@ describe Gitlab::GithubImport::Client, lib: true do
expect(client.api.api_endpoint).to eq 'https://github.company.com/'
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment