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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
4cfafd44
Commit
4cfafd44
authored
Sep 02, 2014
by
Robert Schilling
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
parents
8f3585fe
7f9fa8c1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
4 deletions
+59
-4
CHANGELOG
CHANGELOG
+1
-0
doc/api/issues.md
doc/api/issues.md
+9
-0
lib/api/issues.rb
lib/api/issues.rb
+23
-4
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+26
-0
No files found.
CHANGELOG
View file @
4cfafd44
...
@@ -11,6 +11,7 @@ v 7.3.0
...
@@ -11,6 +11,7 @@ v 7.3.0
- Store session Redis keys in 'session:gitlab:' namespace
- Store session Redis keys in 'session:gitlab:' namespace
- Deprecate LDAP account takeover based on partial LDAP email / GitLab username match
- Deprecate LDAP account takeover based on partial LDAP email / GitLab username match
- Keyboard shortcuts for productivity (Robert Schilling)
- Keyboard shortcuts for productivity (Robert Schilling)
- API: filter issues by state (Julien Bianchi)
v 7.2.0
v 7.2.0
- Explore page
- Explore page
...
...
doc/api/issues.md
View file @
4cfafd44
...
@@ -7,8 +7,14 @@ Get all issues created by authenticated user. This function takes pagination par
...
@@ -7,8 +7,14 @@ Get all issues created by authenticated user. This function takes pagination par
```
```
GET /issues
GET /issues
GET /issues?state=opened
GET /issues?state=closed
```
```
Parameters:
-
`state`
(optional) - Return
`all`
issues or just those that are
`opened`
or
`closed`
```
json
```
json
[
[
{
{
...
@@ -80,11 +86,14 @@ to return the list of project issues.
...
@@ -80,11 +86,14 @@ to return the list of project issues.
```
```
GET /projects/:id/issues
GET /projects/:id/issues
GET /projects/:id/issues?state=opened
GET /projects/:id/issues?state=closed
```
```
Parameters:
Parameters:
-
`id`
(required) - The ID of a project
-
`id`
(required) - The ID of a project
-
`state`
(optional) - Return
`all`
issues or just those that are
`opened`
or
`closed`
## Single issue
## Single issue
...
...
lib/api/issues.rb
View file @
4cfafd44
...
@@ -3,13 +3,28 @@ module API
...
@@ -3,13 +3,28 @@ module API
class
Issues
<
Grape
::
API
class
Issues
<
Grape
::
API
before
{
authenticate!
}
before
{
authenticate!
}
helpers
do
def
filter_issues_state
(
issues
,
state
=
nil
)
case
state
when
'opened'
then
issues
.
opened
when
'closed'
then
issues
.
closed
else
issues
end
end
end
resource
:issues
do
resource
:issues
do
# Get currently authenticated user's issues
# Get currently authenticated user's issues
#
#
# Example Request:
# Parameters:
# state (optional) - Return "opened" or "closed" issues
#
# Example Requests:
# GET /issues
# GET /issues
# GET /issues?state=opened
# GET /issues?state=closed
get
do
get
do
present
paginate
(
current_user
.
issues
),
with:
Entities
::
Issue
present
paginate
(
filter_issues_state
(
current_user
.
issues
,
params
[
'state'
])
),
with:
Entities
::
Issue
end
end
end
end
...
@@ -18,10 +33,14 @@ module API
...
@@ -18,10 +33,14 @@ module API
#
#
# Parameters:
# Parameters:
# id (required) - The ID of a project
# id (required) - The ID of a project
# Example Request:
# state (optional) - Return "opened" or "closed" issues
#
# Example Requests:
# GET /projects/:id/issues
# GET /projects/:id/issues
# GET /projects/:id/issues?state=opened
# GET /projects/:id/issues?state=closed
get
":id/issues"
do
get
":id/issues"
do
present
paginate
(
user_project
.
issues
),
with:
Entities
::
Issue
present
paginate
(
filter_issues_state
(
user_project
.
issues
,
params
[
'state'
])
),
with:
Entities
::
Issue
end
end
# Get a single project issue
# Get a single project issue
...
...
spec/requests/api/issues_spec.rb
View file @
4cfafd44
...
@@ -4,6 +4,7 @@ describe API::API, api: true do
...
@@ -4,6 +4,7 @@ describe API::API, api: true do
include
ApiHelpers
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let!
(
:closed_issue
)
{
create
(
:closed_issue
,
author:
user
,
assignee:
user
,
project:
project
,
state: :closed
)
}
let!
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
let!
(
:issue
)
{
create
(
:issue
,
author:
user
,
assignee:
user
,
project:
project
)
}
let!
(
:label
)
do
let!
(
:label
)
do
create
(
:label
,
title:
'label'
,
color:
'#FFAABB'
,
project:
project
)
create
(
:label
,
title:
'label'
,
color:
'#FFAABB'
,
project:
project
)
...
@@ -32,6 +33,31 @@ describe API::API, api: true do
...
@@ -32,6 +33,31 @@ describe API::API, api: true do
response
.
headers
[
'Link'
].
should
==
response
.
headers
[
'Link'
].
should
==
'<http://www.example.com/api/v3/issues?page=1&per_page=3>; rel="first", <http://www.example.com/api/v3/issues?page=1&per_page=3>; rel="last"'
'<http://www.example.com/api/v3/issues?page=1&per_page=3>; rel="first", <http://www.example.com/api/v3/issues?page=1&per_page=3>; rel="last"'
end
end
it
'should return an array of closed issues'
do
get
api
(
'/issues?state=closed'
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
length
.
should
==
1
json_response
.
first
[
'id'
].
should
==
closed_issue
.
id
end
it
'should return an array of opened issues'
do
get
api
(
'/issues?state=opened'
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
length
.
should
==
1
json_response
.
first
[
'id'
].
should
==
issue
.
id
end
it
'should return an array of all issues'
do
get
api
(
'/issues?state=all'
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
length
.
should
==
2
json_response
.
first
[
'id'
].
should
==
issue
.
id
json_response
.
second
[
'id'
].
should
==
closed_issue
.
id
end
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