Commit 6e4fdc11 authored by Robert Schilling's avatar Robert Schilling

Directly use MRs given by ReferencedMergeRequestsService

parent feb2cb90
......@@ -304,19 +304,14 @@ module API
get ':id/issues/:issue_iid/related_merge_requests' do
issue = find_project_issue(params[:issue_iid])
merge_request_iids = ::Issues::ReferencedMergeRequestsService.new(user_project, current_user)
merge_requests = ::Issues::ReferencedMergeRequestsService.new(user_project, current_user)
.execute(issue)
.flatten
.map(&:iid)
merge_requests =
if merge_request_iids.present?
MergeRequest.all.where(iid: merge_request_iids)
else
MergeRequest.none
end
present paginate(merge_requests), with: Entities::MergeRequestBasic, current_user: current_user, project: user_project
present paginate(::Kaminari.paginate_array(merge_requests)),
with: Entities::MergeRequestBasic,
current_user: current_user,
project: user_project
end
desc 'List merge requests closing issue' do
......
......@@ -1835,7 +1835,7 @@ describe API::Issues do
get_related_merge_requests(project.id, issue.iid, user)
expect_paginated_array_response(merge_request.id)
expect_paginated_array_response([related_mr.id, merge_request.id])
end
context 'no merge request mentioned a issue' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment