Remove duplicates from issue related merge requests
Remove duplicates returned by Issues#related_merge_requests API that relies on ReferencedMergeRequestsService which returns 2 arrays one of related MRs and one of related MRs that close the issue(i.e. a subset of first one). We only need related MRs in this case so just pick the first array.
This commit is contained in:
parent
941e00121c
commit
c56970e3f7
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue