Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-01 20:29:08 +0300
committerDouwe Maan <douwe@gitlab.com>2015-09-01 20:29:08 +0300
commit2236e9d617af766c1970d851ad8ed0ed98e8e8bc (patch)
tree54dfd2b7ea9e2c87742846950597c04a7f3bbdac /spec
parent2ef16e76609e04a398a88c9704abf41795e452de (diff)
parent2e9c922dd17d13e2cb20b214f00eb875c673dfdf (diff)
Merge branch 'fix-bitbucket-import-issue-order' into 'master'
Import all Bitbucket issues and sort issues by creation date Previously only the first 15 Bitbucket issues would be imported. Other issues in the API return call also calls import errors. Tested by importing 400+ issues from this repo: https://bitbucket.org/ned/coveragepy API reference here: https://bitbucket.org/site/master/issues/3571/api-issues-sorting-bb-3518 Closes https://github.com/gitlabhq/gitlabhq/issues/9519 See merge request !1226
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/bitbucket_import/client_spec.rb34
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