diff options
author | Justin Whear <justin@economicmodeling.com> | 2014-06-02 16:10:38 -0700 |
---|---|---|
committer | Hannes Rosenögger <123haynes@gmail.com> | 2015-01-22 12:08:45 +0100 |
commit | 9d271538a8e9ddff892a084e5c8a881bf2fdb0b0 (patch) | |
tree | b52b11c433b0e0191c0257094021034ecc653e0e | |
parent | 2b10520b306697d7cbae8f3f84ca30cacc821fa4 (diff) | |
download | gitlab-ce-9d271538a8e9ddff892a084e5c8a881bf2fdb0b0.tar.gz |
Add per-milestone issues API call
-rw-r--r-- | lib/api/milestones.rb | 15 | ||||
-rw-r--r-- | spec/requests/api/milestones_spec.rb | 14 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb index 2ea49359df0..ca01fa4a57d 100644 --- a/lib/api/milestones.rb +++ b/lib/api/milestones.rb @@ -75,6 +75,21 @@ module API render_api_error!("Failed to update milestone #{milestone.errors.messages}", 400) end end + + # Get all issues for single project milestone + # + # Parameters: + # id (required) - The ID of a project + # milestone_id (required) - The ID of a project milestone + # Example Request: + # GET /projects/:id/milestones/:milestone_id/issues + get ":id/milestones/:milestone_id/issues" do + authorize! :read_milestone, user_project + + @milestone = user_project.milestones.find(params[:milestone_id]) + present paginate(@milestone.issues), with: Entities::Issue + end + end end end diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb index f0619a1c801..73432cb22a7 100644 --- a/spec/requests/api/milestones_spec.rb +++ b/spec/requests/api/milestones_spec.rb @@ -96,4 +96,18 @@ describe API::API, api: true do state_event: 'close' end end + + describe "GET /projects/:id/milestones/:milestone_id/issues" do + it "should return project issues for a particular milestone" do + get api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user) + response.status.should == 200 + json_response.should be_an Array + json_response.first['milestone']['title'].should == milestone.title + end + + it "should return a 401 error if user not authenticated" do + get api("/projects/#{project.id}/milestones/#{milestone.id}/issues") + response.status.should == 401 + end + end end |