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
Boxiang Sun
gitlab-ce
Commits
adc06476
Commit
adc06476
authored
Jul 17, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for importing a DiffNote
parent
28290459
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
9 deletions
+47
-9
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+47
-9
No files found.
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
View file @
adc06476
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
BitbucketServerImport
::
Importer
do
describe
Gitlab
::
BitbucketServerImport
::
Importer
do
include
ImportSpecHelper
include
ImportSpecHelper
s
et
(
:project
)
{
create
(
:project
,
:repository
,
import_url:
'http://my-bitbucket'
)
}
l
et
(
:project
)
{
create
(
:project
,
:repository
,
import_url:
'http://my-bitbucket'
)
}
subject
{
described_class
.
new
(
project
)
}
subject
{
described_class
.
new
(
project
)
}
...
@@ -32,14 +32,14 @@ describe Gitlab::BitbucketServerImport::Importer do
...
@@ -32,14 +32,14 @@ describe Gitlab::BitbucketServerImport::Importer do
end
end
end
end
# XXX We don't handle pull requests across forks
describe
'#import_pull_requests'
do
describe
'#import_pull_requests'
do
let
(
:sample
)
{
RepoHelpers
.
sample_compare
}
before
do
before
do
allow
(
subject
).
to
receive
(
:import_repository
)
allow
(
subject
).
to
receive
(
:import_repository
)
allow
(
subject
).
to
receive
(
:delete_temp_branches
)
allow
(
subject
).
to
receive
(
:delete_temp_branches
)
allow
(
subject
).
to
receive
(
:restore_branches
)
allow
(
subject
).
to
receive
(
:restore_branches
)
sample
=
RepoHelpers
.
sample_compare
pull_request
=
instance_double
(
pull_request
=
instance_double
(
BitbucketServer
::
Representation
::
PullRequest
,
BitbucketServer
::
Representation
::
PullRequest
,
iid:
10
,
iid:
10
,
...
@@ -64,11 +64,6 @@ describe Gitlab::BitbucketServerImport::Importer do
...
@@ -64,11 +64,6 @@ describe Gitlab::BitbucketServerImport::Importer do
merge_event?:
true
,
merge_event?:
true
,
committer_email:
project
.
owner
.
email
,
committer_email:
project
.
owner
.
email
,
merge_timestamp:
Time
.
now
.
utc
.
change
(
usec:
0
))
merge_timestamp:
Time
.
now
.
utc
.
change
(
usec:
0
))
@inline_comment
=
instance_double
(
BitbucketServer
::
Representation
::
Activity
,
comment?:
true
,
inline_comment?:
true
,
merge_event?:
false
)
@pr_note
=
instance_double
(
@pr_note
=
instance_double
(
BitbucketServer
::
Representation
::
Comment
,
BitbucketServer
::
Representation
::
Comment
,
...
@@ -109,7 +104,50 @@ describe Gitlab::BitbucketServerImport::Importer do
...
@@ -109,7 +104,50 @@ describe Gitlab::BitbucketServerImport::Importer do
expect
(
note
.
updated_at
).
to
eq
(
@pr_note
.
created_at
)
expect
(
note
.
updated_at
).
to
eq
(
@pr_note
.
created_at
)
end
end
it
'handles diff comments'
do
it
'imports threaded comments'
do
end
it
'imports diff comments'
do
# https://gitlab.com/gitlab-org/gitlab-test/compare/c1acaa58bbcbc3eafe538cb8274ba387047b69f8...5937ac0a7beb003549fc5fd26fc247ad
inline_note
=
instance_double
(
BitbucketServer
::
Representation
::
PullRequestComment
,
file_type:
'ADDED'
,
from_sha:
sample
.
commits
.
first
,
to_sha:
sample
.
commits
.
last
,
file_path:
'.gitmodules'
,
old_pos:
nil
,
new_pos:
4
,
note:
'Hello world'
,
author_email:
'unknown@gmail.com'
,
comments:
[],
created_at:
Time
.
now
.
utc
.
change
(
usec:
0
),
updated_at:
Time
.
now
.
utc
.
change
(
usec:
0
))
inline_comment
=
instance_double
(
BitbucketServer
::
Representation
::
Activity
,
comment?:
true
,
inline_comment?:
true
,
merge_event?:
false
,
comment:
inline_note
)
expect
(
subject
.
client
).
to
receive
(
:activities
).
and_return
([
inline_comment
])
expect
{
subject
.
execute
}.
to
change
{
MergeRequest
.
count
}.
by
(
1
)
merge_request
=
MergeRequest
.
first
expect
(
merge_request
.
notes
.
count
).
to
eq
(
1
)
note
=
merge_request
.
notes
.
first
expect
(
note
.
type
).
to
eq
(
'DiffNote'
)
expect
(
note
.
note
).
to
eq
(
inline_note
.
note
)
expect
(
note
.
created_at
).
to
eq
(
inline_note
.
created_at
)
expect
(
note
.
updated_at
).
to
eq
(
inline_note
.
updated_at
)
expect
(
note
.
position
.
base_sha
).
to
eq
(
inline_note
.
from_sha
)
expect
(
note
.
position
.
start_sha
).
to
eq
(
inline_note
.
from_sha
)
expect
(
note
.
position
.
head_sha
).
to
eq
(
inline_note
.
to_sha
)
expect
(
note
.
position
.
old_line
).
to
be_nil
expect
(
note
.
position
.
new_line
).
to
eq
(
inline_note
.
new_pos
)
end
end
it
'falls back to comments if diff comments'
do
it
'falls back to comments if diff comments'
do
...
...
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