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
Jérome Perrin
gitlab-ce
Commits
845b2f1a
Commit
845b2f1a
authored
Oct 11, 2017
by
micael.bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add spec
parent
5a2acfe0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
+22
-7
spec/factories/merge_requests.rb
spec/factories/merge_requests.rb
+6
-0
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+16
-7
No files found.
spec/factories/merge_requests.rb
View file @
845b2f1a
...
@@ -73,6 +73,12 @@ FactoryGirl.define do
...
@@ -73,6 +73,12 @@ FactoryGirl.define do
merge_user
author
merge_user
author
end
end
trait
:remove_source_branch
do
merge_params
do
{
'force_remove_source_branch'
=>
'1'
}
end
end
after
(
:build
)
do
|
merge_request
|
after
(
:build
)
do
|
merge_request
|
target_project
=
merge_request
.
target_project
target_project
=
merge_request
.
target_project
source_project
=
merge_request
.
source_project
source_project
=
merge_request
.
source_project
...
...
spec/services/merge_requests/merge_service_spec.rb
View file @
845b2f1a
...
@@ -185,7 +185,7 @@ describe MergeRequests::MergeService do
...
@@ -185,7 +185,7 @@ describe MergeRequests::MergeService do
context
'source branch removal'
do
context
'source branch removal'
do
context
'when the source branch is protected'
do
context
'when the source branch is protected'
do
let
(
:service
)
do
let
(
:service
)
do
described_class
.
new
(
project
,
user
,
should_remove_source_branch:
'1'
)
described_class
.
new
(
project
,
user
,
'should_remove_source_branch'
=>
true
)
end
end
before
do
before
do
...
@@ -200,7 +200,7 @@ describe MergeRequests::MergeService do
...
@@ -200,7 +200,7 @@ describe MergeRequests::MergeService do
context
'when the source branch is the default branch'
do
context
'when the source branch is the default branch'
do
let
(
:service
)
do
let
(
:service
)
do
described_class
.
new
(
project
,
user
,
should_remove_source_branch:
'1'
)
described_class
.
new
(
project
,
user
,
'should_remove_source_branch'
=>
true
)
end
end
before
do
before
do
...
@@ -215,10 +215,10 @@ describe MergeRequests::MergeService do
...
@@ -215,10 +215,10 @@ describe MergeRequests::MergeService do
context
'when the source branch can be removed'
do
context
'when the source branch can be removed'
do
context
'when MR author set the source branch to be removed'
do
context
'when MR author set the source branch to be removed'
do
let
(
:service
)
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
merge_request
.
merge_params
[
'force_remove_source_branch'
]
=
'1'
merge_request
.
save!
before
do
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
merge_request
.
update_attribute
(
:merge_params
,
{
'force_remove_source_branch'
=>
'1'
}
)
end
end
it
'removes the source branch using the author user'
do
it
'removes the source branch using the author user'
do
...
@@ -227,11 +227,20 @@ describe MergeRequests::MergeService do
...
@@ -227,11 +227,20 @@ describe MergeRequests::MergeService do
.
and_call_original
.
and_call_original
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
)
end
end
context
'when the merger set the source branch not to be removed'
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
,
'should_remove_source_branch'
=>
false
)
}
it
'does not delete the source branch'
do
expect
(
DeleteBranchService
).
not_to
receive
(
:new
)
service
.
execute
(
merge_request
)
end
end
end
end
context
'when MR merger set the source branch to be removed'
do
context
'when MR merger set the source branch to be removed'
do
let
(
:service
)
do
let
(
:service
)
do
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
,
should_remove_source_branch:
'1'
)
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
,
'should_remove_source_branch'
=>
true
)
end
end
it
'removes the source branch using the current user'
do
it
'removes the source branch using the current user'
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