Improve coding and doc style

This commit is contained in:
Robert Schilling 2016-04-06 20:53:17 +02:00
parent 0728588c34
commit e6215a9a8e
4 changed files with 21 additions and 10 deletions

View file

@ -15,6 +15,7 @@ v 8.7.0 (unreleased)
- Handle nil descriptions in Slack issue messages (Stan Hu) - Handle nil descriptions in Slack issue messages (Stan Hu)
- Add default scope to projects to exclude projects pending deletion - Add default scope to projects to exclude projects pending deletion
- Ensure empty recipients are rejected in BuildsEmailService - Ensure empty recipients are rejected in BuildsEmailService
- API: Ability to filter milestones by state `active` and `closed` (Robert Schilling)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.) - Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.) - Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu) - Gracefully handle notes on deleted commits in merge requests (Stan Hu)
@ -25,7 +26,6 @@ v 8.7.0 (unreleased)
- Build status notifications - Build status notifications
- API: Ability to retrieve a specific tag (Robert Schilling) - API: Ability to retrieve a specific tag (Robert Schilling)
- API: Expose user location (Robert Schilling) - API: Expose user location (Robert Schilling)
- API: Ability to milter milestones by state `active` and `closed` (Robert Schilling)
v 8.6.5 (unreleased) v 8.6.5 (unreleased)
- Check permissions when user attempts to import members from another project - Check permissions when user attempts to import members from another project

View file

@ -11,6 +11,20 @@ GET /projects/:id/milestones?state=active
GET /projects/:id/milestones?state=closed GET /projects/:id/milestones?state=closed
``` ```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `iid` | integer | optional | Return only the milestone having the given `iid` |
| `state` | string | optional | Return only `active` or `closed` milestones` |
```bash
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/milestones
```
Example Response:
```json ```json
[ [
{ {
@ -27,11 +41,6 @@ GET /projects/:id/milestones?state=closed
] ]
``` ```
Parameters:
- `id` (required) - The ID of a project
- `iid` (optional) - Return the milestone having the given `iid`
- `state` (optional) - Return "active" or "closed" milestones
## Get single milestone ## Get single milestone

View file

@ -27,7 +27,7 @@ module API
authorize! :read_milestone, user_project authorize! :read_milestone, user_project
milestones = user_project.milestones milestones = user_project.milestones
milestones = filter_milestones_state(milestones, params[:state]) unless params[:state].nil? milestones = filter_milestones_state(milestones, params[:state])
present paginate(milestones), with: Entities::Milestone present paginate(milestones), with: Entities::Milestone
end end

View file

@ -4,7 +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_milestone) { create(:closed_milestone, project: project, state: :closed) } let!(:closed_milestone) { create(:closed_milestone, project: project) }
let!(:milestone) { create(:milestone, project: project) } let!(:milestone) { create(:milestone, project: project) }
before { project.team << [user, :developer] } before { project.team << [user, :developer] }
@ -22,16 +22,18 @@ describe API::API, api: true do
expect(response.status).to eq(401) expect(response.status).to eq(401)
end end
it 'should return an array of active milestones' do it 'returns an array of active milestones' do
get api("/projects/#{project.id}/milestones?state=active", user) get api("/projects/#{project.id}/milestones?state=active", user)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)
expect(json_response.first['id']).to eq(milestone.id) expect(json_response.first['id']).to eq(milestone.id)
end end
it 'should return an array of closed milestones' do it 'returns an array of closed milestones' do
get api("/projects/#{project.id}/milestones?state=closed", user) get api("/projects/#{project.id}/milestones?state=closed", user)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.length).to eq(1) expect(json_response.length).to eq(1)