Merge branch '30291-reopen-mr' into 'master'
Search for opened MRs - include reopened MRs Closes #30291 See merge request !10407
This commit is contained in:
commit
d062af91ca
3 changed files with 32 additions and 1 deletions
|
@ -39,7 +39,7 @@ module MergeRequests
|
||||||
private
|
private
|
||||||
|
|
||||||
# Returns all origin and fork merge requests from `@project` satisfying passed arguments.
|
# Returns all origin and fork merge requests from `@project` satisfying passed arguments.
|
||||||
def merge_requests_for(source_branch, mr_states: [:opened])
|
def merge_requests_for(source_branch, mr_states: [:opened, :reopened])
|
||||||
MergeRequest
|
MergeRequest
|
||||||
.with_state(mr_states)
|
.with_state(mr_states)
|
||||||
.where(source_branch: source_branch, source_project_id: @project.id)
|
.where(source_branch: source_branch, source_project_id: @project.id)
|
||||||
|
|
4
changelogs/unreleased/30291-reopen-mr.yml
Normal file
4
changelogs/unreleased/30291-reopen-mr.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
title: Include reopened MRs when searching for opened ones
|
||||||
|
merge_request: 10407
|
||||||
|
author:
|
|
@ -49,6 +49,7 @@ describe MergeRequests::RefreshService, services: true do
|
||||||
|
|
||||||
context 'push to origin repo source branch' do
|
context 'push to origin repo source branch' do
|
||||||
let(:refresh_service) { service.new(@project, @user) }
|
let(:refresh_service) { service.new(@project, @user) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(refresh_service).to receive(:execute_hooks)
|
allow(refresh_service).to receive(:execute_hooks)
|
||||||
refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
|
refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
|
||||||
|
@ -70,6 +71,32 @@ describe MergeRequests::RefreshService, services: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'push to origin repo source branch when an MR was reopened' do
|
||||||
|
let(:refresh_service) { service.new(@project, @user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
@merge_request.update(state: :reopened)
|
||||||
|
|
||||||
|
allow(refresh_service).to receive(:execute_hooks)
|
||||||
|
refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
|
||||||
|
reload_mrs
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'executes hooks with update action' do
|
||||||
|
expect(refresh_service).to have_received(:execute_hooks).
|
||||||
|
with(@merge_request, 'update', @oldrev)
|
||||||
|
|
||||||
|
expect(@merge_request.notes).not_to be_empty
|
||||||
|
expect(@merge_request).to be_open
|
||||||
|
expect(@merge_request.merge_when_pipeline_succeeds).to be_falsey
|
||||||
|
expect(@merge_request.diff_head_sha).to eq(@newrev)
|
||||||
|
expect(@fork_merge_request).to be_open
|
||||||
|
expect(@fork_merge_request.notes).to be_empty
|
||||||
|
expect(@build_failed_todo).to be_done
|
||||||
|
expect(@fork_build_failed_todo).to be_done
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'push to origin repo target branch' do
|
context 'push to origin repo target branch' do
|
||||||
before do
|
before do
|
||||||
service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/feature')
|
service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/feature')
|
||||||
|
|
Loading…
Reference in a new issue