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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
846e2799
Commit
846e2799
authored
Aug 21, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7557 from Razer6/fix_tests
Fix merge request API after #7526
parents
87efd92d
66f6ca07
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+6
-5
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+7
-6
No files found.
lib/api/merge_requests.rb
View file @
846e2799
...
@@ -78,8 +78,8 @@ module API
...
@@ -78,8 +78,8 @@ module API
attrs
=
attributes_for_keys
[
:source_branch
,
:target_branch
,
:assignee_id
,
:title
,
:target_project_id
,
:description
]
attrs
=
attributes_for_keys
[
:source_branch
,
:target_branch
,
:assignee_id
,
:title
,
:target_project_id
,
:description
]
# Validate label names in advance
# Validate label names in advance
if
validate_label_params
(
params
)
if
(
errors
=
validate_label_params
(
params
)).
any?
re
turn
render_api_error!
(
'Label names invalid'
,
405
)
re
nder_api_error!
({
labels:
errors
},
400
)
end
end
merge_request
=
::
MergeRequests
::
CreateService
.
new
(
user_project
,
current_user
,
attrs
).
execute
merge_request
=
::
MergeRequests
::
CreateService
.
new
(
user_project
,
current_user
,
attrs
).
execute
...
@@ -117,15 +117,16 @@ module API
...
@@ -117,15 +117,16 @@ module API
authorize!
:modify_merge_request
,
merge_request
authorize!
:modify_merge_request
,
merge_request
# Validate label names in advance
# Validate label names in advance
if
validate_label_params
(
params
)
if
(
errors
=
validate_label_params
(
params
)).
any?
re
turn
render_api_error!
(
'Label names invalid'
,
405
)
re
nder_api_error!
({
labels:
errors
},
400
)
end
end
merge_request
=
::
MergeRequests
::
UpdateService
.
new
(
user_project
,
current_user
,
attrs
).
execute
(
merge_request
)
merge_request
=
::
MergeRequests
::
UpdateService
.
new
(
user_project
,
current_user
,
attrs
).
execute
(
merge_request
)
if
merge_request
.
valid?
if
merge_request
.
valid?
# Find or create labels and attach to issue
# Find or create labels and attach to issue
if
params
[
:labels
].
present?
unless
params
[
:labels
].
nil?
merge_request
.
remove_labels
merge_request
.
add_labels_by_names
(
params
[
:labels
].
split
(
","
))
merge_request
.
add_labels_by_names
(
params
[
:labels
].
split
(
","
))
end
end
...
...
spec/requests/api/merge_requests_spec.rb
View file @
846e2799
...
@@ -112,15 +112,16 @@ describe API::API, api: true do
...
@@ -112,15 +112,16 @@ describe API::API, api: true do
response
.
status
.
should
==
400
response
.
status
.
should
==
400
end
end
it
'should return 40
5
on invalid label names'
do
it
'should return 40
0
on invalid label names'
do
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
title:
'Test merge_request'
,
title:
'Test merge_request'
,
source_branch:
'stable'
,
source_branch:
'stable'
,
target_branch:
'master'
,
target_branch:
'master'
,
author:
user
,
author:
user
,
labels:
'label, ?'
labels:
'label, ?'
response
.
status
.
should
==
405
response
.
status
.
should
==
400
json_response
[
'message'
].
should
==
'Label names invalid'
json_response
[
'message'
][
'labels'
][
'?'
][
'title'
].
should
==
[
'is invalid'
]
end
end
end
end
...
@@ -252,13 +253,13 @@ describe API::API, api: true do
...
@@ -252,13 +253,13 @@ describe API::API, api: true do
json_response
[
'target_branch'
].
should
==
'wiki'
json_response
[
'target_branch'
].
should
==
'wiki'
end
end
it
'should return 40
5
on invalid label names'
do
it
'should return 40
0
on invalid label names'
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
"
,
put
api
(
"/projects/
#{
project
.
id
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
),
user
),
title:
'new issue'
,
title:
'new issue'
,
labels:
'label, ?'
labels:
'label, ?'
response
.
status
.
should
==
40
5
response
.
status
.
should
==
40
0
json_response
[
'message'
]
.
should
==
'Label names invalid'
json_response
[
'message'
]
[
'labels'
][
'?'
][
'title'
].
should
==
[
'is invalid'
]
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