diff options
author | Stan Hu <stanhu@gmail.com> | 2015-09-01 03:03:09 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-09-01 18:50:20 +0300 |
commit | 2e9c922dd17d13e2cb20b214f00eb875c673dfdf (patch) | |
tree | 0c1d2d0e0b1c81da56b15ffa22ae4c624d7a6f50 /spec | |
parent | 31e4654b1f77ab48e5705f8feb8d628c66d4f962 (diff) |
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.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/bitbucket_import/client_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
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 |