Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Project ID can also be a string (namespace/project_name). (@bergholdt)
- Support pipeline. (@bergholdt)
- Add methods to disable and enable deploy keys on projects. (@buzzdeee)
- Add method to fetch issues a merge request will close. (@joren)

### 3.7.0 (16/08/2016)

Expand Down
11 changes: 11 additions & 0 deletions lib/gitlab/client/merge_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ def merge_request_commits(project, id)
get("/projects/#{url_encode project}/merge_requests/#{id}/commits")
end

# List issues that will close on merge
#
# @example
# Gitlab.merge_request_closes_issues(5, 1)
#
# @param [Integer] project The ID of a project
# @param [Integer] iid The internal ID of a merge request
def merge_request_closes_issues(project_id, merge_request_iid)
get("/projects/#{project_id}/merge_requests/#{merge_request_iid}/closes_issues")
end

# Subscribes to a merge request.
#
# @example
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/merge_request_closes_issues.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":1,"iid":1,"project_id":5,"title":"Merge request 1 issue 1","description":"","state":"opened","created_at":"2017-04-06T08:03:36.163Z","updated_at":"2017-04-06T08:03:57.087Z","labels":[],"milestone":null,"assignee":null,"author":{"name":"John","username":"jdoe","id":1,"state":"active","avatar_url":"","web_url":"https://gitlab.com/jdoe"},"user_notes_count":0,"upvotes":0,"downvotes":0,"due_date":null,"confidential":false,"weight":null,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/issues/1"},{"id":2,"iid":2,"project_id":5,"title":"Merge request 1 issue 2","description":"","state":"opened","created_at":"2017-04-06T08:03:44.023Z","updated_at":"2017-04-06T08:03:44.023Z","labels":[],"milestone":null,"assignee":null,"author":{"name":"John","username":"jdoe","id":426047,"state":"active","avatar_url":"","web_url":"https://gitlab.com/jdoe"},"user_notes_count":0,"upvotes":0,"downvotes":0,"due_date":null,"confidential":false,"weight":null,"web_url":"https://gitlab.com/jdoe/milestone_merge_requests_test/issues/2"}]
17 changes: 17 additions & 0 deletions spec/gitlab/client/merge_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,23 @@
end
end

describe ".merge_request_closes_issues" do
before do
stub_get("/projects/5/merge_requests/1/closes_issues", "merge_request_closes_issues")
@issues = Gitlab.merge_request_closes_issues(5, 1)
end

it "should get the correct resource" do
expect(a_get("/projects/5/merge_requests/1/closes_issues")).to have_been_made
end

it "should return a paginated response of the issues the merge_request will close" do
expect(@issues).to be_a(Gitlab::PaginatedResponse)
expect(@issues.first.title).to eq("Merge request 1 issue 1")
expect(@issues.size).to eq(2)
end
end

describe ".subscribe_to_merge_request" do
before do
stub_post("/projects/3/merge_requests/2/subscribe", "merge_request")
Expand Down