summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/bitbucket_import
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-11-21 20:49:40 -0800
committerStan Hu <stanhu@gmail.com>2016-11-21 20:49:40 -0800
commit402cc95c1a1df8168467f74e21c6df7d48359714 (patch)
treef95e6b587a7e996fa81219b269c344a972e939bd /spec/lib/gitlab/bitbucket_import
parent0b72994b63dbbbddaf0e77629249d92890a6e4a4 (diff)
downloadgitlab-ce-402cc95c1a1df8168467f74e21c6df7d48359714.tar.gz
Fix Bitbucket importer spec to pass with 2.0 API
Diffstat (limited to 'spec/lib/gitlab/bitbucket_import')
-rw-r--r--spec/lib/gitlab/bitbucket_import/importer_spec.rb42
1 files changed, 30 insertions, 12 deletions
diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb
index aa00f32becb..99a65f26f99 100644
--- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb
@@ -23,10 +23,14 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
statuses.map.with_index do |status, index|
issues << {
- local_id: index,
- status: status,
+ id: index,
+ state: status,
title: "Issue #{index}",
- content: "Some content to issue #{index}"
+ content: {
+ raw: "Some content to issue #{index}",
+ markup: "markdown",
+ html: "Some content to issue #{index}"
+ }
}
end
@@ -37,8 +41,8 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
let(:data) do
{
'bb_session' => {
- 'bitbucket_access_token' => "123456",
- 'bitbucket_access_token_secret' => "secret"
+ 'bitbucket_token' => "123456",
+ 'bitbucket_refresh_token' => "secret"
}
}
end
@@ -53,7 +57,7 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
let(:issues_statuses_sample_data) do
{
count: sample_issues_statuses.count,
- issues: sample_issues_statuses
+ values: sample_issues_statuses
}
end
@@ -61,26 +65,40 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
before do
stub_request(
:get,
- "https://bitbucket.org/api/1.0/repositories/#{project_identifier}"
- ).to_return(status: 200, body: { has_issues: true }.to_json)
+ "https://api.bitbucket.org/2.0/repositories/#{project_identifier}"
+ ).to_return(status: 200,
+ headers: {"Content-Type" => "application/json"},
+ body: { has_issues: true, full_name: project_identifier }.to_json)
stub_request(
:get,
- "https://bitbucket.org/api/1.0/repositories/#{project_identifier}/issues?limit=50&sort=utc_created_on&start=0"
- ).to_return(status: 200, body: issues_statuses_sample_data.to_json)
+ "https://api.bitbucket.org/2.0/repositories/#{project_identifier}/issues?pagelen=50&sort=created_on"
+ ).to_return(status: 200,
+ headers: {"Content-Type" => "application/json"},
+ body: issues_statuses_sample_data.to_json)
sample_issues_statuses.each_with_index do |issue, index|
stub_request(
:get,
- "https://bitbucket.org/api/1.0/repositories/#{project_identifier}/issues/#{issue[:local_id]}/comments"
+ "https://api.bitbucket.org/2.0/repositories/#{project_identifier}/issues/#{issue[:id]}/comments?pagelen=50&sort=created_on"
).to_return(
status: 200,
- body: [{ author_info: { username: "username" }, utc_created_on: index }].to_json
+ headers: {"Content-Type" => "application/json"},
+ body: { author_info: { username: "username" }, utc_created_on: index }.to_json
)
end
+
+ stub_request(
+ :get,
+ "https://api.bitbucket.org/2.0/repositories/#{project_identifier}/pullrequests?pagelen=50&sort=created_on&state=ALL"
+ ).to_return(status: 200,
+ headers: {"Content-Type" => "application/json"},
+ body: {}.to_json)
end
it 'map statuses to open or closed' do
+ # HACK: Bitbucket::Representation.const_get('Issue') seems to return Issue without this
+ Bitbucket::Representation::Issue
importer.execute
expect(project.issues.where(state: "closed").size).to eq(5)