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
a7aacb4d
Commit
a7aacb4d
authored
Mar 25, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6586 from abner/master
added api method to return labels of a given project
parents
5fc3d746
19938156
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
0 deletions
+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
No files found.
doc/api/projects.md
View file @
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
View file @
a7aacb4d
...
...
@@ -187,5 +187,9 @@ module API
end
end
end
class
Label
<
Grape
::
Entity
expose
:name
end
end
end
lib/api/projects.rb
View file @
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
View file @
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
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