Commit 3041d2d4 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '225579-reset-approvals-closed-mrs' into 'master'

Update closed MRs on push

See merge request gitlab-org/gitlab!37414
parents 2aec0058 fcbe226f
......@@ -9,7 +9,7 @@ module MergeRequests
def execute
return [] if branch_names.blank?
source_branches = project.source_of_merge_requests.opened
source_branches = project.source_of_merge_requests.open_and_closed
.from_source_branches(branch_names).pluck(:source_branch)
target_branches = project.merge_requests.opened
......
---
title: Update closed MRs on push
merge_request: 37414
author:
type: fixed
......@@ -8,19 +8,24 @@ RSpec.describe MergeRequests::PushedBranchesService do
context 'when branches pushed' do
let(:pushed_branches) do
%w(branch1 branch2 extra1 extra2 extra3).map do |branch|
%w(branch1 branch2 closed-branch1 closed-branch2 extra1 extra2).map do |branch|
{ ref: "refs/heads/#{branch}" }
end
end
it 'returns only branches which have a merge request' do
it 'returns only branches which have a open and closed merge request' do
create(:merge_request, source_branch: 'branch1', source_project: project)
create(:merge_request, source_branch: 'branch2', source_project: project)
create(:merge_request, target_branch: 'branch2', source_project: project)
create(:merge_request, :closed, target_branch: 'extra1', source_project: project)
create(:merge_request, source_branch: 'extra2')
expect(service.execute).to contain_exactly('branch1', 'branch2')
create(:merge_request, :closed, target_branch: 'closed-branch1', source_project: project)
create(:merge_request, :closed, source_branch: 'closed-branch2', source_project: project)
create(:merge_request, source_branch: 'extra1')
expect(service.execute).to contain_exactly(
'branch1',
'branch2',
'closed-branch2'
)
end
end
......
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