summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--lib/api/milestones.rb2
-rw-r--r--spec/requests/api/milestones_spec.rb8
3 files changed, 8 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 75743872801..593e8f77ab4 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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.)
diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb
index 0f3f505fa05..84b4d4cdd6d 100644
--- a/lib/api/milestones.rb
+++ b/lib/api/milestones.rb
@@ -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
diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb
index d97bf6d38ff..344f0fe0b7f 100644
--- a/spec/requests/api/milestones_spec.rb
+++ b/spec/requests/api/milestones_spec.rb
@@ -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