Commit 38a58978 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Fix GItHub client requests when rate limit is disabled

parent d796138653a8
......@@ -78,6 +78,11 @@ def github_options
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 @@
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