Skip to content

Commit

Permalink
Added support to get milestone issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
pbendersky committed Mar 6, 2015
1 parent d0ebd3b commit 57fa92d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/gitlab/client/milestones.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ def milestones(project, options={})
def milestone(project, id)
get("/projects/#{project}/milestones/#{id}")
end

# Gets the issues of a given milestone.
#
# @example
# Gitlab.milestone_issues(5, 2)
#
# @param [Integer, String] project The ID of a project.
# @param [Integer, String] milestone The ID of a milestone.
# @return [Array<Gitlab::ObjectifiedHash>]
def milestone_issues(project, milestone)
get("/projects/#{project}/milestones/#{milestone}/issues")
end

# Creates a new milestone.
#
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/milestone_issues.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":1,"project_id":3,"title":"Culpa eius recusandae suscipit autem distinctio dolorum.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":6,"project_id":3,"title":"Ut in dolorum omnis sed sit aliquam.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":12,"project_id":3,"title":"Veniam et tempore quidem eum reprehenderit cupiditate non aut velit eaque.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":21,"project_id":3,"title":"Vitae ea aliquam et quo eligendi sapiente voluptatum labore hic nihil culpa.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":26,"project_id":3,"title":"Quo enim est nihil atque placeat voluptas neque eos voluptas.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"},{"id":32,"project_id":3,"title":"Deserunt tenetur impedit est beatae voluptas voluptas quaerat quisquam.","description":null,"labels":[],"milestone":{"id": 1},"assignee":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-09-17T09:41:56Z"},"closed":false,"updated_at":"2012-09-17T09:42:20Z","created_at":"2012-09-17T09:42:20Z"}]
16 changes: 16 additions & 0 deletions spec/gitlab/client/milestones_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@
expect(@milestone.project_id).to eq(3)
end
end

describe ".milestone_issues" do
before do
stub_get("/projects/3/milestones/1/issues", "milestone_issues")
@milestone_issues = Gitlab.milestone_issues(3, 1)
end

it "should get the correct resource" do
expect(a_get("/projects/3/milestones/1/issues")).to have_been_made
end

it "should return an array of milestone's issues" do
expect(@milestone_issues).to be_an Array
expect(@milestone_issues.first.milestone.id).to eq(1)
end
end

describe ".create_milestone" do
before do
Expand Down

0 comments on commit 57fa92d

Please sign in to comment.