Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
a7aacb4d
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,发现更多精彩内容 >>
提交
a7aacb4d
编写于
3月 25, 2014
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6586 from abner/master
added api method to return labels of a given project
上级
5fc3d746
19938156
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
0 deletion
+54
-0
doc/api/projects.md
doc/api/projects.md
+26
-0
lib/api/entities.rb
lib/api/entities.rb
+4
-0
lib/api/projects.rb
lib/api/projects.rb
+11
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+13
-0
未找到文件。
doc/api/projects.md
浏览文件 @
a7aacb4d
...
...
@@ -621,3 +621,29 @@ Parameters:
+
query (required) - A string contained in the project name
+
per_page (optional) - number of projects to return per page
+
page (optional) - the page to retrieve
## Labels
### List project labels
Get a list of project labels.
```
GET /projects/:id/labels
```
Parameters:
+
`id`
(required) - The ID or NAMESPACE/PROJECT_NAME of a project
```
json
[
{
"name"
:
"featute"
},
{
"name"
:
"bug"
}
]
```
lib/api/entities.rb
浏览文件 @
a7aacb4d
...
...
@@ -187,5 +187,9 @@ module API
end
end
end
class
Label
<
Grape
::
Entity
expose
:name
end
end
end
lib/api/projects.rb
浏览文件 @
a7aacb4d
...
...
@@ -215,6 +215,17 @@ module API
@users
=
paginate
@users
present
@users
,
with:
Entities
::
User
end
# Get a project labels
#
# Parameters:
# id (required) - The ID of a project
# Example Request:
# GET /projects/:id/labels
get
':id/labels'
do
@labels
=
user_project
.
issues_labels
present
@labels
,
with:
Entities
::
Label
end
end
end
end
spec/requests/api/projects_spec.rb
浏览文件 @
a7aacb4d
...
...
@@ -13,6 +13,7 @@ describe API::API do
let
(
:snippet
)
{
create
(
:project_snippet
,
author:
user
,
project:
project
,
title:
'example'
)
}
let
(
:users_project
)
{
create
(
:users_project
,
user:
user
,
project:
project
,
project_access:
UsersProject
::
MASTER
)
}
let
(
:users_project2
)
{
create
(
:users_project
,
user:
user3
,
project:
project
,
project_access:
UsersProject
::
DEVELOPER
)
}
let
(
:issue_with_labels
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
,
:label_list
=>
"label1, label2"
)
}
describe
"GET /projects"
do
before
{
project
}
...
...
@@ -632,4 +633,16 @@ describe API::API do
end
end
end
describe
"GET /projects/:id/labels"
do
before
{
issue_with_labels
}
it
"should return project labels"
do
get
api
(
"/projects/
#{
project
.
id
}
/labels"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
first
[
'name'
].
should
==
issue_with_labels
.
labels
.
first
.
name
json_response
.
last
[
'name'
].
should
==
issue_with_labels
.
labels
.
last
.
name
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录