diff options
Diffstat (limited to 'spec/lib/gitlab/legacy_github_import/client_spec.rb')
-rw-r--r-- | spec/lib/gitlab/legacy_github_import/client_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/lib/gitlab/legacy_github_import/client_spec.rb b/spec/lib/gitlab/legacy_github_import/client_spec.rb index 83ba5858d81..08679b7e9f1 100644 --- a/spec/lib/gitlab/legacy_github_import/client_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/client_spec.rb @@ -98,6 +98,30 @@ RSpec.describe Gitlab::LegacyGithubImport::Client do end end + describe '#repository' do + it 'returns repository data as a hash' do + stub_request(:get, 'https://api.github.com/rate_limit') + .to_return(status: 200, headers: { 'X-RateLimit-Limit' => 5000, 'X-RateLimit-Remaining' => 5000 }) + + stub_request(:get, 'https://api.github.com/repositories/1') + .to_return(status: 200, body: { id: 1 }.to_json, headers: { 'Content-Type' => 'application/json' }) + + expect(client.repository(1)).to eq({ id: 1 }) + end + end + + describe '#repos' do + it 'returns the user\'s repositories as a hash' do + stub_request(:get, 'https://api.github.com/rate_limit') + .to_return(status: 200, headers: { 'X-RateLimit-Limit' => 5000, 'X-RateLimit-Remaining' => 5000 }) + + stub_request(:get, 'https://api.github.com/user/repos') + .to_return(status: 200, body: [{ id: 1 }, { id: 2 }].to_json, headers: { 'Content-Type' => 'application/json' }) + + expect(client.repos).to match_array([{ id: 1 }, { id: 2 }]) + end + end + context 'github rate limit' do it 'does not raise error when rate limit is disabled' do stub_request(:get, /api.github.com/) |