diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 09:40:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-20 09:40:42 +0000 |
commit | ee664acb356f8123f4f6b00b73c1e1cf0866c7fb (patch) | |
tree | f8479f94a28f66654c6a4f6fb99bad6b4e86a40e /spec/lib/gitlab/github_import/client_spec.rb | |
parent | 62f7d5c5b69180e82ae8196b7b429eeffc8e7b4f (diff) | |
download | gitlab-ce-ee664acb356f8123f4f6b00b73c1e1cf0866c7fb.tar.gz |
Add latest changes from gitlab-org/gitlab@15-5-stable-eev15.5.0-rc42
Diffstat (limited to 'spec/lib/gitlab/github_import/client_spec.rb')
-rw-r--r-- | spec/lib/gitlab/github_import/client_spec.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/spec/lib/gitlab/github_import/client_spec.rb b/spec/lib/gitlab/github_import/client_spec.rb index c88bb6de859..3361b039a27 100644 --- a/spec/lib/gitlab/github_import/client_spec.rb +++ b/spec/lib/gitlab/github_import/client_spec.rb @@ -148,7 +148,25 @@ RSpec.describe Gitlab::GithubImport::Client do .to receive(:branch_protection).with('org/repo', 'bar') expect(client).to receive(:with_rate_limit).and_yield - client.branch_protection('org/repo', 'bar') + branch_protection = client.branch_protection('org/repo', 'bar') + + expect(branch_protection).to be_a(Hash) + end + end + + describe '#each_object' do + it 'converts each object into a hash' do + client = described_class.new('foo') + + 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/repos/foo/bar/releases?per_page=100') + .to_return(status: 200, body: [{ id: 1 }].to_json, headers: { 'Content-Type' => 'application/json' }) + + client.each_object(:releases, 'foo/bar') do |release| + expect(release).to eq({ id: 1 }) + end end end @@ -575,11 +593,11 @@ RSpec.describe Gitlab::GithubImport::Client do describe 'search' do let(:client) { described_class.new('foo') } - let(:user) { double(:user, login: 'user') } - let(:org1) { double(:org, login: 'org1') } - let(:org2) { double(:org, login: 'org2') } - let(:repo1) { double(:repo, full_name: 'repo1') } - let(:repo2) { double(:repo, full_name: 'repo2') } + let(:user) { { login: 'user' } } + let(:org1) { { login: 'org1' } } + let(:org2) { { login: 'org2' } } + let(:repo1) { { full_name: 'repo1' } } + let(:repo2) { { full_name: 'repo2' } } before do allow(client) |