From 2e9c922dd17d13e2cb20b214f00eb875c673dfdf Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 31 Aug 2015 17:03:09 -0700 Subject: Fix bug where only the first 15 Bitbucket issues would be imported. Also fix a number of issues where author/reporter names were not available. --- spec/lib/gitlab/bitbucket_import/client_spec.rb | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'spec/lib') diff --git a/spec/lib/gitlab/bitbucket_import/client_spec.rb b/spec/lib/gitlab/bitbucket_import/client_spec.rb index dd450e9967b..dfe58637eee 100644 --- a/spec/lib/gitlab/bitbucket_import/client_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/client_spec.rb @@ -14,4 +14,38 @@ describe Gitlab::BitbucketImport::Client do expect(key).to be_kind_of(Symbol) end end + + context 'issues' do + let(:per_page) { 50 } + let(:count) { 95 } + let(:sample_issues) do + issues = [] + + count.times do |i| + issues << { local_id: i } + end + + issues + end + let(:first_sample_data) { { count: count, issues: sample_issues[0..per_page - 1] } } + let(:second_sample_data) { { count: count, issues: sample_issues[per_page..count] } } + let(:project_id) { 'namespace/repo' } + + it 'retrieves issues over a number of pages' do + stub_request(:get, + "https://bitbucket.org/api/1.0/repositories/#{project_id}/issues?limit=50&sort=utc_created_on&start=0"). + to_return(status: 200, + body: first_sample_data.to_json, + headers: {}) + + stub_request(:get, + "https://bitbucket.org/api/1.0/repositories/#{project_id}/issues?limit=50&sort=utc_created_on&start=50"). + to_return(status: 200, + body: second_sample_data.to_json, + headers: {}) + + issues = client.issues(project_id) + expect(issues.count).to eq(95) + end + end end -- cgit v1.2.1