diff options
author | Rémy Coutable <remy@rymai.me> | 2017-09-25 15:37:30 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-09-26 19:17:00 +0200 |
commit | 62120acf1d8a7b3abecfff71900ed423c1fdf473 (patch) | |
tree | e129d7b55b0bd407b41977e65d5c5657b39a9c09 | |
parent | e484a06472890424c9f7174a3e80d5a5e43eae57 (diff) | |
download | gitlab-ce-38198-fetch-github-api-per-100.tar.gz |
Add a spec for Github::Client and revert an `if !` to `unless`38198-fetch-github-api-per-100
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | lib/github/import.rb | 2 | ||||
-rw-r--r-- | spec/lib/github/client_spec.rb | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/github/import.rb b/lib/github/import.rb index fdc82ff530d..f5f62dc8b6f 100644 --- a/lib/github/import.rb +++ b/lib/github/import.rb @@ -236,7 +236,7 @@ module Github # for both features, like manipulating assignees, labels # and milestones, are provided within the Issues API. if representation.pull_request? - return if !representation.has_labels? && !representation.has_comments? + return unless representation.has_labels? || representation.has_comments? merge_request = MergeRequest.find_by!(target_project_id: project.id, iid: representation.iid) diff --git a/spec/lib/github/client_spec.rb b/spec/lib/github/client_spec.rb new file mode 100644 index 00000000000..b846096fe25 --- /dev/null +++ b/spec/lib/github/client_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe Github::Client do + let(:connection) { spy } + let(:rate_limit) { double(get: [false, 1]) } + let(:client) { described_class.new({}) } + let(:results) { double } + let(:response) { double } + + before do + allow(Faraday).to receive(:new).and_return(connection) + allow(Github::RateLimit).to receive(:new).with(connection).and_return(rate_limit) + end + + describe '#get' do + before do + allow(Github::Response).to receive(:new).with(results).and_return(response) + end + + it 'uses a default per_page param' do + expect(connection).to receive(:get).with('/foo', per_page: 100).and_return(results) + + expect(client.get('/foo')).to eq(response) + end + + context 'with per_page given' do + it 'overwrites the default per_page' do + expect(connection).to receive(:get).with('/foo', per_page: 30).and_return(results) + + expect(client.get('/foo', per_page: 30)).to eq(response) + end + end + end +end |