Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
402cc95c
Commit
402cc95c
authored
Nov 21, 2016
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Bitbucket importer spec to pass with 2.0 API
parent
0b72994b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
21 deletions
+32
-21
lib/bitbucket/page.rb
lib/bitbucket/page.rb
+2
-2
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+0
-7
spec/lib/gitlab/bitbucket_import/importer_spec.rb
spec/lib/gitlab/bitbucket_import/importer_spec.rb
+30
-12
No files found.
lib/bitbucket/page.rb
View file @
402cc95c
...
...
@@ -22,10 +22,10 @@ module Bitbucket
attrs
.
map
{
|
attr
|
{
attr
.
to_sym
=>
raw
[
attr
]
}
}.
reduce
(
&
:merge
)
end
def
parse_values
(
raw
,
representation
_class
)
def
parse_values
(
raw
,
bitbucket_rep
_class
)
return
[]
unless
raw
[
'values'
]
&&
raw
[
'values'
].
is_a?
(
Array
)
raw
[
'values'
].
map
{
|
hash
|
representation
_class
.
new
(
hash
)
}
raw
[
'values'
].
map
{
|
hash
|
bitbucket_rep
_class
.
new
(
hash
)
}
end
def
representation_class
(
type
)
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
402cc95c
...
...
@@ -62,13 +62,6 @@ module Gitlab
)
end
end
project
.
issues
.
create!
(
description:
body
,
title:
issue
[
"title"
],
state:
%w(resolved invalid duplicate wontfix closed)
.
include?
(
issue
[
"status"
])
?
'closed'
:
'opened'
,
author_id:
gitlab_user_id
(
project
,
reporter
)
)
end
rescue
ActiveRecord
::
RecordInvalid
nil
...
...
spec/lib/gitlab/bitbucket_import/importer_spec.rb
View file @
402cc95c
...
...
@@ -23,10 +23,14 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
statuses
.
map
.
with_index
do
|
status
,
index
|
issues
<<
{
local_
id:
index
,
stat
us
:
status
,
id:
index
,
stat
e
:
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
,
iss
ues:
sample_issues_statuses
val
ues:
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment