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
9b584a59
Commit
9b584a59
authored
Jul 19, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for restore and deleting temp branches
parent
835e2363
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
5 deletions
+61
-5
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+61
-5
No files found.
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
View file @
9b584a59
...
@@ -5,12 +5,15 @@ describe Gitlab::BitbucketServerImport::Importer do
...
@@ -5,12 +5,15 @@ describe Gitlab::BitbucketServerImport::Importer do
let
(
:project
)
{
create
(
:project
,
:repository
,
import_url:
'http://my-bitbucket'
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
import_url:
'http://my-bitbucket'
)
}
let
(
:now
)
{
Time
.
now
.
utc
.
change
(
usec:
0
)
}
let
(
:now
)
{
Time
.
now
.
utc
.
change
(
usec:
0
)
}
let
(
:project_key
)
{
'TEST'
}
let
(
:repo_slug
)
{
'rouge'
}
let
(
:sample
)
{
RepoHelpers
.
sample_compare
}
subject
{
described_class
.
new
(
project
)
}
subject
{
described_class
.
new
(
project
)
}
before
do
before
do
data
=
project
.
create_or_update_import_data
(
data
=
project
.
create_or_update_import_data
(
data:
{
project_key:
'TEST'
,
repo_slug:
'rouge'
},
data:
{
project_key:
project_key
,
repo_slug:
repo_slug
},
credentials:
{
base_uri:
'http://my-bitbucket'
,
user:
'bitbucket'
,
password:
'test'
}
credentials:
{
base_uri:
'http://my-bitbucket'
,
user:
'bitbucket'
,
password:
'test'
}
)
)
data
.
save
data
.
save
...
@@ -34,8 +37,6 @@ describe Gitlab::BitbucketServerImport::Importer do
...
@@ -34,8 +37,6 @@ describe Gitlab::BitbucketServerImport::Importer do
end
end
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
)
...
@@ -206,8 +207,63 @@ describe Gitlab::BitbucketServerImport::Importer do
...
@@ -206,8 +207,63 @@ describe Gitlab::BitbucketServerImport::Importer do
end
end
end
end
describe
'#delete_temp_branches'
do
describe
'inaccessible branches'
do
it
'deletes branches'
do
let
(
:id
)
{
10
}
let
(
:temp_branch_from
)
{
"gitlab/import/pull-request/
#{
id
}
/from"
}
let
(
:temp_branch_to
)
{
"gitlab/import/pull-request/
#{
id
}
/to"
}
before
do
pull_request
=
instance_double
(
BitbucketServer
::
Representation
::
PullRequest
,
iid:
id
,
source_branch_sha:
'12345678'
,
source_branch_name:
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
sample
.
source_branch
,
target_branch_sha:
'98765432'
,
target_branch_name:
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
sample
.
target_branch
,
title:
'This is a title'
,
description:
'This is a test pull request'
,
state:
'merged'
,
author:
'Test Author'
,
author_email:
project
.
owner
.
email
,
created_at:
Time
.
now
,
updated_at:
Time
.
now
,
merged?:
true
)
expect
(
subject
.
client
).
to
receive
(
:pull_requests
).
and_return
([
pull_request
])
expect
(
subject
.
client
).
to
receive
(
:activities
).
and_return
([])
expect
(
subject
).
to
receive
(
:import_repository
).
twice
end
it
'#restore_branches'
do
expect
(
subject
).
to
receive
(
:restore_branches
).
and_call_original
expect
(
subject
).
to
receive
(
:delete_temp_branches
)
expect
(
subject
.
client
).
to
receive
(
:create_branch
).
with
(
project_key
,
repo_slug
,
temp_branch_from
,
'12345678'
)
expect
(
subject
.
client
).
to
receive
(
:create_branch
).
with
(
project_key
,
repo_slug
,
temp_branch_to
,
'98765432'
)
expect
{
subject
.
execute
}.
to
change
{
MergeRequest
.
count
}.
by
(
1
)
end
it
'#delete_temp_branches'
do
expect
(
subject
.
client
).
to
receive
(
:create_branch
).
twice
expect
(
subject
).
to
receive
(
:delete_temp_branches
).
and_call_original
expect
(
subject
.
client
).
to
receive
(
:delete_branch
).
with
(
project_key
,
repo_slug
,
temp_branch_from
,
'12345678'
)
expect
(
subject
.
client
).
to
receive
(
:delete_branch
).
with
(
project_key
,
repo_slug
,
temp_branch_to
,
'98765432'
)
expect
(
project
.
repository
).
to
receive
(
:delete_branch
).
with
(
temp_branch_from
)
expect
(
project
.
repository
).
to
receive
(
:delete_branch
).
with
(
temp_branch_to
)
expect
{
subject
.
execute
}.
to
change
{
MergeRequest
.
count
}.
by
(
1
)
end
end
end
end
end
end
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