2019-04-12 14:41:31 +00:00
|
|
|
# frozen_string_literal: true
|
2016-12-05 15:00:26 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 18:08:28 +00:00
|
|
|
RSpec.describe 'Projects > Settings > User manages merge request settings' do
|
2016-12-05 15:00:26 +00:00
|
|
|
let(:user) { create(:user) }
|
2018-04-06 12:40:33 +00:00
|
|
|
let(:project) { create(:project, :public, namespace: user.namespace, path: 'gitlab', name: 'sample') }
|
2016-12-05 15:00:26 +00:00
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2018-04-06 12:40:33 +00:00
|
|
|
visit edit_project_path(project)
|
2016-12-05 15:00:26 +00:00
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
it 'shows "Merge commit" strategy' do
|
2018-11-16 21:34:36 +00:00
|
|
|
page.within '#js-merge-request-settings' do
|
2018-04-06 12:40:33 +00:00
|
|
|
expect(page).to have_content 'Merge commit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows "Merge commit with semi-linear history " strategy' do
|
2018-11-16 21:34:36 +00:00
|
|
|
page.within '#js-merge-request-settings' do
|
2018-04-06 12:40:33 +00:00
|
|
|
expect(page).to have_content 'Merge commit with semi-linear history'
|
|
|
|
end
|
|
|
|
end
|
2016-12-05 15:00:26 +00:00
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
it 'shows "Fast-forward merge" strategy' do
|
2018-11-16 21:34:36 +00:00
|
|
|
page.within '#js-merge-request-settings' do
|
2018-04-06 12:40:33 +00:00
|
|
|
expect(page).to have_content 'Fast-forward merge'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when Merge Request and Pipelines are initially enabled', :js do
|
|
|
|
context 'when Pipelines are initially enabled' do
|
|
|
|
it 'shows the Merge Requests settings' do
|
2019-04-12 14:41:31 +00:00
|
|
|
expect(page).to have_content 'Pipelines must succeed'
|
|
|
|
expect(page).to have_content 'All discussions must be resolved'
|
2016-12-05 15:00:26 +00:00
|
|
|
|
2017-07-25 19:38:25 +00:00
|
|
|
within('.sharing-permissions-form') do
|
2017-09-07 18:07:40 +00:00
|
|
|
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
|
2017-10-02 17:51:16 +00:00
|
|
|
find('input[value="Save changes"]').send_keys(:return)
|
2017-07-25 19:38:25 +00:00
|
|
|
end
|
2016-12-05 15:00:26 +00:00
|
|
|
|
2019-04-12 14:41:31 +00:00
|
|
|
expect(page).not_to have_content 'Pipelines must succeed'
|
|
|
|
expect(page).not_to have_content 'All discussions must be resolved'
|
2016-12-05 15:00:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
context 'when Pipelines are initially disabled', :js do
|
2016-12-05 15:00:26 +00:00
|
|
|
before do
|
|
|
|
project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED)
|
|
|
|
visit edit_project_path(project)
|
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
it 'shows the Merge Requests settings that do not depend on Builds feature' do
|
2019-06-06 09:29:05 +00:00
|
|
|
expect(page).to have_content 'Pipelines must succeed'
|
2019-04-12 14:41:31 +00:00
|
|
|
expect(page).to have_content 'All discussions must be resolved'
|
2016-12-05 15:00:26 +00:00
|
|
|
|
2017-07-25 19:38:25 +00:00
|
|
|
within('.sharing-permissions-form') do
|
2017-09-07 18:07:40 +00:00
|
|
|
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
|
2017-10-02 17:51:16 +00:00
|
|
|
find('input[value="Save changes"]').send_keys(:return)
|
2017-07-25 19:38:25 +00:00
|
|
|
end
|
2016-12-05 15:00:26 +00:00
|
|
|
|
2019-04-12 14:41:31 +00:00
|
|
|
expect(page).to have_content 'Pipelines must succeed'
|
|
|
|
expect(page).to have_content 'All discussions must be resolved'
|
2016-12-05 15:00:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
context 'when Merge Request are initially disabled', :js do
|
2016-12-05 15:00:26 +00:00
|
|
|
before do
|
|
|
|
project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED)
|
|
|
|
visit edit_project_path(project)
|
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
it 'does not show the Merge Requests settings' do
|
2019-04-12 14:41:31 +00:00
|
|
|
expect(page).not_to have_content 'Pipelines must succeed'
|
|
|
|
expect(page).not_to have_content 'All discussions must be resolved'
|
2016-12-05 15:00:26 +00:00
|
|
|
|
2017-07-25 19:38:25 +00:00
|
|
|
within('.sharing-permissions-form') do
|
2017-09-07 18:07:40 +00:00
|
|
|
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
|
2017-10-02 17:51:16 +00:00
|
|
|
find('input[value="Save changes"]').send_keys(:return)
|
2017-07-25 19:38:25 +00:00
|
|
|
end
|
2016-12-05 15:00:26 +00:00
|
|
|
|
2019-04-12 14:41:31 +00:00
|
|
|
expect(page).to have_content 'Pipelines must succeed'
|
|
|
|
expect(page).to have_content 'All discussions must be resolved'
|
2016-12-05 15:00:26 +00:00
|
|
|
end
|
|
|
|
end
|
2017-03-17 12:35:39 +00:00
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
describe 'Checkbox to enable merge request link', :js do
|
|
|
|
it 'is initially checked' do
|
2017-03-17 12:35:39 +00:00
|
|
|
checkbox = find_field('project_printing_merge_request_link_enabled')
|
|
|
|
expect(checkbox).to be_checked
|
|
|
|
end
|
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
it 'when unchecked sets :printing_merge_request_link_enabled to false' do
|
2017-03-17 12:35:39 +00:00
|
|
|
uncheck('project_printing_merge_request_link_enabled')
|
2017-07-25 19:38:25 +00:00
|
|
|
within('.merge-request-settings-form') do
|
2019-07-26 21:51:59 +00:00
|
|
|
find('.rspec-save-merge-request-changes')
|
2017-07-25 19:38:25 +00:00
|
|
|
click_on('Save changes')
|
|
|
|
end
|
2017-03-17 12:35:39 +00:00
|
|
|
|
2019-03-14 20:52:01 +00:00
|
|
|
find('.flash-notice')
|
2017-03-17 12:35:39 +00:00
|
|
|
checkbox = find_field('project_printing_merge_request_link_enabled')
|
2019-03-14 20:52:01 +00:00
|
|
|
|
2017-03-17 12:35:39 +00:00
|
|
|
expect(checkbox).not_to be_checked
|
|
|
|
|
|
|
|
project.reload
|
|
|
|
expect(project.printing_merge_request_link_enabled).to be(false)
|
|
|
|
end
|
|
|
|
end
|
2019-10-23 21:06:17 +00:00
|
|
|
|
|
|
|
describe 'Checkbox to remove source branch after merge', :js do
|
|
|
|
it 'is initially checked' do
|
|
|
|
checkbox = find_field('project_remove_source_branch_after_merge')
|
|
|
|
expect(checkbox).to be_checked
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'when unchecked sets :remove_source_branch_after_merge to false' do
|
|
|
|
uncheck('project_remove_source_branch_after_merge')
|
|
|
|
within('.merge-request-settings-form') do
|
|
|
|
find('.qa-save-merge-request-changes')
|
|
|
|
click_on('Save changes')
|
|
|
|
end
|
|
|
|
|
|
|
|
find('.flash-notice')
|
|
|
|
checkbox = find_field('project_remove_source_branch_after_merge')
|
|
|
|
|
|
|
|
expect(checkbox).not_to be_checked
|
|
|
|
|
|
|
|
project.reload
|
|
|
|
expect(project.remove_source_branch_after_merge).to be(false)
|
|
|
|
end
|
|
|
|
end
|
2016-12-05 15:00:26 +00:00
|
|
|
end
|