Commit 12c6b641 authored by Sean McGivern's avatar Sean McGivern

Hide squash checkbox when there is a single commit

When there is only one commit, the squash checkbox doesn't do
anything. When a commit is added after the widget is loaded, the MR
can't be merged anyway - you have to refresh the page. So we can only
show the checkbox on page load if there's more than one commit.
parent 59a58038
......@@ -38,9 +38,10 @@
= label_tag :should_remove_source_branch, class: "merge-param-checkbox" do
= check_box_tag :should_remove_source_branch
Remove source branch
= hidden_field_tag :squash, '0', id: nil
- if @merge_request.commits_count > 1
.accept-control.checkbox
= label_tag :squash, class: 'merge-param-checkbox' do
= hidden_field_tag :squash, '0', id: nil
= check_box_tag :squash, '1', @merge_request.squash
Squash commits
= link_to icon('question-circle'), help_page_path('user/project/merge_requests/squash_and_merge'), title: 'About this feature', data: {toggle: 'tooltip', placement: 'bottom', container: 'body'}
......
......@@ -46,6 +46,18 @@ feature 'Squashing merge requests', js: true, feature: true do
login_as user
end
context 'when the MR has only one commit' do
before do
merge_request = create(:merge_request, source_project: project, target_project: project, source_branch: 'master', target_branch: 'branch-merged')
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
it 'does not show the squash checkbox' do
expect(page).not_to have_field('squash')
end
end
context 'when squash is enabled on merge request creation' do
before do
visit new_namespace_project_merge_request_path(project.namespace, project, merge_request: { target_branch: 'master', source_branch: source_branch })
......
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