summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2019-02-14 23:11:06 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2019-02-14 23:11:06 +0100
commit6e4fdc117c6a78c0de0e65a31e4867b6ece063df (patch)
tree87197aa53a6b1c2eba781568f62d51bd340136c9
parentfeb2cb9085ace1c0b9dbc86df59de0d5d6521a4d (diff)
downloadgitlab-ce-6e4fdc117c6a78c0de0e65a31e4867b6ece063df.tar.gz
Directly use MRs given by ReferencedMergeRequestsService
-rw-r--r--lib/api/issues.rb15
-rw-r--r--spec/requests/api/issues_spec.rb2
2 files changed, 6 insertions, 11 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index f44df1d4fcd..a85a0909e86 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -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
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 8e097bee715..cb6ccbb7053 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -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