Commit 260d1e44 authored by Samantha Ming's avatar Samantha Ming

Add squash commit message in MR form

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/223029

It will add a message when the
squash commit checkbox is disabled.
It will indicate whether it is required or not.
parent b03f348f
......@@ -26,3 +26,6 @@
= label_tag 'merge_request[squash]', class: 'form-check-label' do
Squash commits when merge request is accepted.
= link_to icon('question-circle'), help_page_path('user/project/merge_requests/squash_and_merge'), target: '_blank'
- if project.squash_always?
.gl-text-gray-600
= _('Required in this project.')
......@@ -16,6 +16,40 @@ RSpec.describe 'User edits a merge request', :js do
visit(edit_project_merge_request_path(project, merge_request))
end
describe 'Squash commits' do
it 'displays "Required in this project" for "Required" project setting squash option' do
project.project_setting.update!(squash_option: 'always')
visit(edit_project_merge_request_path(project, merge_request))
expect(page).to have_content('Squash commits when merge request is accepted.')
expect(page).to have_content("Required in this project")
end
it 'does not display message for "Allow" project setting squash option' do
project.project_setting.update!(squash_option: 'default_off')
visit(edit_project_merge_request_path(project, merge_request))
expect(page).to have_content('Squash commits when merge request is accepted.')
expect(page).not_to have_content("Required in this project")
end
it 'does not display message for "Encourage" project setting squash option' do
project.project_setting.update!(squash_option: 'default_on')
visit(edit_project_merge_request_path(project, merge_request))
expect(page).to have_content('Squash commits when merge request is accepted.')
expect(page).not_to have_content("Required in this project")
end
it 'is hidden for "Do not allow" project setting squash option' do
project.project_setting.update!(squash_option: 'never')
visit(edit_project_merge_request_path(project, merge_request))
expect(page).not_to have_content('Squash commits when merge request is accepted.')
expect(page).not_to have_css('#merge_request_squash')
end
end
it 'changes the target branch' do
expect(page).to have_content('From master into feature')
......
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