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
c4720170
Commit
c4720170
authored
Jun 14, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix API bug accepting wrong merge requests parameters
parent
43e1481c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
4 deletions
+28
-4
changelogs/unreleased/issue_33205.yml
changelogs/unreleased/issue_33205.yml
+4
-0
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+1
-1
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+23
-3
No files found.
changelogs/unreleased/issue_33205.yml
0 → 100644
View file @
c4720170
---
title
:
Fix API bug accepting wrong parameter to create merge request
merge_request
:
author
:
lib/api/merge_requests.rb
View file @
c4720170
...
...
@@ -97,7 +97,7 @@ module API
authorize!
:create_merge_request
,
user_project
mr_params
=
declared_params
(
include_missing:
false
)
mr_params
[
:force_remove_source_branch
]
=
mr_params
.
delete
(
:remove_source_branch
)
if
mr_params
[
:remove_source_branch
].
present?
mr_params
[
:force_remove_source_branch
]
=
mr_params
.
delete
(
:remove_source_branch
)
merge_request
=
::
MergeRequests
::
CreateService
.
new
(
user_project
,
current_user
,
mr_params
).
execute
...
...
spec/requests/api/merge_requests_spec.rb
View file @
c4720170
...
...
@@ -334,14 +334,13 @@ describe API::MergeRequests do
target_branch:
'master'
,
author:
user
,
labels:
'label, label2'
,
milestone_id:
milestone
.
id
,
remove_source_branch:
true
milestone_id:
milestone
.
id
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
[
'title'
]).
to
eq
(
'Test merge_request'
)
expect
(
json_response
[
'labels'
]).
to
eq
(
%w(label label2)
)
expect
(
json_response
[
'milestone'
][
'id'
]).
to
eq
(
milestone
.
id
)
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_
truth
y
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_
fals
y
end
it
"returns 422 when source_branch equals target_branch"
do
...
...
@@ -404,6 +403,27 @@ describe API::MergeRequests do
expect
(
response
).
to
have_http_status
(
409
)
end
end
context
'accepts remove_source_branch parameter'
do
let
(
:params
)
do
{
title:
'Test merge_request'
,
source_branch:
'markdown'
,
target_branch:
'master'
,
author:
user
}
end
it
'sets force_remove_source_branch to false'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params
.
merge
(
remove_source_branch:
false
)
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_falsy
end
it
'sets force_remove_source_branch to true'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
params
.
merge
(
remove_source_branch:
true
)
expect
(
json_response
[
'force_remove_source_branch'
]).
to
be_truthy
end
end
end
context
'forked projects'
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