Commit 512ca3b3 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/223235/stopAllowChangingTargetBranchOnMergedMR' into 'master'

Disallow editing target branch after merge request is merged

Closes #223235

See merge request gitlab-org/gitlab!39455
parents 12a33075 4baf46d7
......@@ -17,7 +17,9 @@
= link_to _('Change branches'), mr_change_branches_path(issuable)
- elsif issuable.for_fork?
%code= issuable.target_project_path + ":"
- unless issuable.new_record?
- if issuable.merged?
%code= target_title
- unless issuable.new_record? || issuable.merged?
%span.dropdown.gl-ml-2.d-inline-block
= form.hidden_field(:target_branch,
{ class: 'target_branch js-target-branch-select ref-name mw-xl',
......
......@@ -85,13 +85,24 @@ RSpec.describe 'User edits a merge request', :js do
end
end
it 'changes the target branch' do
expect(page).to have_content('From master into feature')
describe 'changing target branch' do
it 'allows user to change target branch' do
expect(page).to have_content('From master into feature')
select2('merge-test', from: '#merge_request_target_branch')
click_button('Save changes')
select2('merge-test', from: '#merge_request_target_branch')
click_button('Save changes')
expect(page).to have_content("Request to merge #{merge_request.source_branch} into merge-test")
expect(page).to have_content("changed target branch from #{merge_request.target_branch} to merge-test")
end
expect(page).to have_content("Request to merge #{merge_request.source_branch} into merge-test")
expect(page).to have_content("changed target branch from #{merge_request.target_branch} to merge-test")
describe 'merged merge request' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, state: :merged) }
it 'does not allow user to change target branch' do
expect(page).to have_content('From master into feature')
expect(page).not_to have_selector('.select2-container')
end
end
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