Ensure merge request's "remove branch" accessors return booleans
Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
651bdd7c34
commit
46689162a3
4 changed files with 20 additions and 3 deletions
|
@ -441,11 +441,11 @@ class MergeRequest < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def should_remove_source_branch?
|
||||
merge_params['should_remove_source_branch'].present?
|
||||
Gitlab::Utils.to_boolean(merge_params['should_remove_source_branch'])
|
||||
end
|
||||
|
||||
def force_remove_source_branch?
|
||||
merge_params['force_remove_source_branch'].present?
|
||||
Gitlab::Utils.to_boolean(merge_params['force_remove_source_branch'])
|
||||
end
|
||||
|
||||
def remove_source_branch?
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
.col-sm-10.col-sm-offset-2
|
||||
.checkbox
|
||||
= label_tag 'merge_request[force_remove_source_branch]' do
|
||||
= hidden_field_tag 'merge_request[force_remove_source_branch]', '0'
|
||||
= check_box_tag 'merge_request[force_remove_source_branch]', '1', @merge_request.force_remove_source_branch?
|
||||
Remove source branch when merge request is accepted.
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Ensure merge request's "remove branch" accessors return booleans
|
||||
merge_request: 7267
|
||||
author:
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
feature 'Edit Merge Request', feature: true do
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, :public) }
|
||||
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project) }
|
||||
let(:merge_request) { create(:merge_request, :simple, source_project: project) }
|
||||
|
||||
before do
|
||||
project.team << [user, :master]
|
||||
|
@ -28,5 +28,17 @@ feature 'Edit Merge Request', feature: true do
|
|||
|
||||
expect(page).to have_content 'Someone edited the merge request the same time you did'
|
||||
end
|
||||
|
||||
it 'allows to unselect "Remove source branch"' do
|
||||
merge_request.update(merge_params: { 'force_remove_source_branch' => '1' })
|
||||
expect(merge_request.merge_params['force_remove_source_branch']).to be_truthy
|
||||
|
||||
visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request)
|
||||
uncheck 'Remove source branch when merge request is accepted'
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
expect(page).to have_content 'Remove source branch'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue