-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class Gitlab::Client | ||
# Defines methods related to merge requests. | ||
module MergeRequests | ||
# Gets a list of project merge requests. | ||
# | ||
# @example | ||
# Gitlab.merge_requests(5) | ||
# Gitlab.merge_requests('gitlab', :per_page => 40) | ||
# | ||
# @param [Integer, String] project The ID or code name of a project. | ||
# @param [Hash] options A customizable set of options. | ||
# @option options [Integer] :page The page number. | ||
# @option options [Integer] :per_page The number of results per page. | ||
# @return [Array<Gitlab::ObjectifiedHash>] | ||
def merge_requests(project, options={}) | ||
get("/projects/#{project}/merge_requests", :query => options) | ||
end | ||
|
||
# Gets a single merge request. | ||
# | ||
# @example | ||
# Gitlab.merge_request(5, 36) | ||
# Gitlab.merge_request('gitlab', 42) | ||
# | ||
# @param [Integer, String] project The ID or code name of a project. | ||
# @param [Integer] id The ID of a merge request. | ||
# @return [Array<Gitlab::ObjectifiedHash>] | ||
def merge_request(project, id) | ||
get("/projects/#{project}/merge_request/#{id}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"id":1,"target_branch":"master","source_branch":"api","project_id":3,"title":"New feature","closed":false,"merged":false,"author":{"id":1,"email":"john@example.com","name":"John Smith","blocked":false,"created_at":"2012-10-19T05:56:05Z"},"assignee":{"id":2,"email":"jack@example.com","name":"Jack Smith","blocked":false,"created_at":"2012-10-19T05:56:14Z"}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec_helper' | ||
|
||
describe Gitlab::Client do | ||
describe ".merge_requests" do | ||
before do | ||
stub_get("/projects/3/merge_requests", "merge_requests") | ||
@merge_requests = Gitlab.merge_requests(3) | ||
end | ||
|
||
it "should get the correct resource" do | ||
a_get("/projects/3/merge_requests").should have_been_made | ||
end | ||
|
||
it "should return an array of project's merge requests" do | ||
@merge_requests.should be_an Array | ||
@merge_requests.first.project_id.should == 3 | ||
end | ||
end | ||
|
||
describe ".merge_request" do | ||
before do | ||
stub_get("/projects/3/merge_request/1", "merge_request") | ||
@merge_request = Gitlab.merge_request(3, 1) | ||
end | ||
|
||
it "should get the correct resource" do | ||
a_get("/projects/3/merge_request/1").should have_been_made | ||
end | ||
|
||
it "should return information about a merge request" do | ||
@merge_request.project_id.should == 3 | ||
@merge_request.assignee.name.should == "Jack Smith" | ||
end | ||
end | ||
end |