Commit d793d4a7 authored by Michael Kozono's avatar Michael Kozono

Merge branch 'duplicate-related-mrs' into 'master'

Remove duplicates from issue related merge requests

See merge request gitlab-org/gitlab-ce!27067
parents e3fedd68 c56970e3
---
title: Remove duplicates from issue related merge requests
merge_request: 27067
author:
type: fixed
......@@ -307,7 +307,7 @@ module API
merge_requests = ::Issues::ReferencedMergeRequestsService.new(user_project, current_user)
.execute(issue)
.flatten
.first
present paginate(::Kaminari.paginate_array(merge_requests)),
with: Entities::MergeRequest,
......
......@@ -2189,6 +2189,18 @@ describe API::Issues do
expect_paginated_array_response(related_mr.id)
end
context 'merge request closes an issue' do
let!(:closing_issue_mr_rel) do
create(:merge_requests_closing_issues, issue: issue, merge_request: related_mr)
end
it 'returns closing MR only once' do
get_related_merge_requests(project.id, issue.iid, user)
expect_paginated_array_response([related_mr.id])
end
end
context 'no merge request mentioned a issue' do
it 'returns empty array' do
get_related_merge_requests(project.id, closed_issue.iid, user)
......
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