Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6dc24e3b
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6dc24e3b
编写于
8月 18, 2014
作者:
J
Jacob Vosmaer
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7527 from Razer6/api_labels_return_code
API: Fix labels return code
上级
2fd7d6e2
4ca3f647
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
16 deletion
+15
-16
doc/api/labels.md
doc/api/labels.md
+5
-6
lib/api/labels.rb
lib/api/labels.rb
+2
-2
spec/requests/api/labels_spec.rb
spec/requests/api/labels_spec.rb
+8
-8
未找到文件。
doc/api/labels.md
浏览文件 @
6dc24e3b
...
...
@@ -45,7 +45,7 @@ Parameters:
It returns 200 and the newly created label, if the operation succeeds.
If the label already exists, 409 and an error message is returned.
If label parameters are invalid, 40
5
and an explaining error message is returned.
If label parameters are invalid, 40
0
and an explaining error message is returned.
## Delete a label
...
...
@@ -58,8 +58,8 @@ DELETE /projects/:id/labels
-
`id`
(required) - The ID of a project
-
`name`
(required) - The name of the label to be deleted
It returns 200 if the label successfully was deleted, 40
4
for wrong parameters
and 40
0
if the label does not exist.
It returns 200 if the label successfully was deleted, 40
0
for wrong parameters
and 40
4
if the label does not exist.
In case of an error, additionally an error message is returned.
## Edit an existing label
...
...
@@ -79,7 +79,6 @@ Parameters:
-
`color`
(optional) - New color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB)
On success, this method returns 200 with the updated label.
If required parameters are missing, 400 is returned.
If required parameters are missing
or parameters are invalid
, 400 is returned.
If the label to be updated is missing, 404 is returned.
If parameters are invalid, 405 is returned. In case of an error,
additionally an error message is returned.
In case of an error, additionally an error message is returned.
lib/api/labels.rb
浏览文件 @
6dc24e3b
...
...
@@ -39,7 +39,7 @@ module API
if
label
.
valid?
present
label
,
with:
Entities
::
Label
else
render_api_error!
(
label
.
errors
.
full_messages
.
join
(
', '
),
40
5
)
render_api_error!
(
label
.
errors
.
full_messages
.
join
(
', '
),
40
0
)
end
end
...
...
@@ -95,7 +95,7 @@ module API
if
label
.
update
(
attrs
)
present
label
,
with:
Entities
::
Label
else
render_api_error!
(
label
.
errors
.
full_messages
.
join
(
', '
),
40
5
)
render_api_error!
(
label
.
errors
.
full_messages
.
join
(
', '
),
40
0
)
end
end
end
...
...
spec/requests/api/labels_spec.rb
浏览文件 @
6dc24e3b
...
...
@@ -42,19 +42,19 @@ describe API::API, api: true do
response
.
status
.
should
==
400
end
it
'should return 40
5
for invalid color'
do
it
'should return 40
0
for invalid color'
do
post
api
(
"/projects/
#{
project
.
id
}
/labels"
,
user
),
name:
'Foo'
,
color:
'#FFAA'
response
.
status
.
should
==
40
5
response
.
status
.
should
==
40
0
json_response
[
'message'
].
should
==
'Color is invalid'
end
it
'should return 40
5
for invalid name'
do
it
'should return 40
0
for invalid name'
do
post
api
(
"/projects/
#{
project
.
id
}
/labels"
,
user
),
name:
'?'
,
color:
'#FFAABB'
response
.
status
.
should
==
40
5
response
.
status
.
should
==
40
0
json_response
[
'message'
].
should
==
'Title is invalid'
end
...
...
@@ -131,20 +131,20 @@ describe API::API, api: true do
response
.
status
.
should
==
400
end
it
'should return 40
5
for invalid name'
do
it
'should return 40
0
for invalid name'
do
put
api
(
"/projects/
#{
project
.
id
}
/labels"
,
user
),
name:
'label1'
,
new_name:
'?'
,
color:
'#FFFFFF'
response
.
status
.
should
==
40
5
response
.
status
.
should
==
40
0
json_response
[
'message'
].
should
==
'Title is invalid'
end
it
'should return 40
5
for invalid name'
do
it
'should return 40
0
for invalid name'
do
put
api
(
"/projects/
#{
project
.
id
}
/labels"
,
user
),
name:
'label1'
,
color:
'#FF'
response
.
status
.
should
==
40
5
response
.
status
.
should
==
40
0
json_response
[
'message'
].
should
==
'Color is invalid'
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录