API: Add iid filter to milestones

This commit is contained in:
Robert Schilling 2016-04-07 10:59:54 +02:00
parent 8cb41f1989
commit 9d03e8fd5c
3 changed files with 8 additions and 3 deletions

View file

@ -23,6 +23,7 @@ v 8.7.0 (unreleased)
- Add default scope to projects to exclude projects pending deletion
- Ensure empty recipients are rejected in BuildsEmailService
- API: Ability to filter milestones by state `active` and `closed` (Robert Schilling)
- API: Fix milestone filtering by `iid` (Robert Schilling)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Better errors handling when creating milestones inside groups
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)

View file

@ -21,6 +21,7 @@ module API
# state (optional) - Return "active" or "closed" milestones
# Example Request:
# GET /projects/:id/milestones
# GET /projects/:id/milestones?iid=42
# GET /projects/:id/milestones?state=active
# GET /projects/:id/milestones?state=closed
get ":id/milestones" do
@ -28,6 +29,7 @@ module API
milestones = user_project.milestones
milestones = filter_milestones_state(milestones, params[:state])
milestones = filter_by_iid(milestones, params[:iid]) if params[:iid].present?
present paginate(milestones), with: Entities::Milestone
end

View file

@ -50,10 +50,12 @@ describe API::API, api: true do
end
it 'should return a project milestone by iid' do
get api("/projects/#{project.id}/milestones?iid=#{milestone.iid}", user)
get api("/projects/#{project.id}/milestones?iid=#{closed_milestone.iid}", user)
expect(response.status).to eq 200
expect(json_response.first['title']).to eq milestone.title
expect(json_response.first['id']).to eq milestone.id
expect(json_response.size).to eq(1)
expect(json_response.first['title']).to eq closed_milestone.title
expect(json_response.first['id']).to eq closed_milestone.id
end
it 'should return 401 error if user not authenticated' do