2016-12-05 10:00:26 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
feature 'Project settings > Merge Requests', :js do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-12-05 10:00:26 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
background do
|
|
|
|
project.team << [user, :master]
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-12-05 10:00:26 -05:00
|
|
|
end
|
|
|
|
|
2017-01-26 06:52:58 -05:00
|
|
|
context 'when Merge Request and Pipelines are initially enabled' do
|
|
|
|
context 'when Pipelines are initially enabled' do
|
2016-12-05 10:00:26 -05:00
|
|
|
before do
|
|
|
|
visit edit_project_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'shows the Merge Requests settings' do
|
2017-01-26 06:52:58 -05:00
|
|
|
expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds')
|
2016-12-05 10:00:26 -05:00
|
|
|
expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
|
|
|
|
|
2017-07-25 15:38:25 -04:00
|
|
|
within('.sharing-permissions-form') do
|
2017-09-07 14:07:40 -04:00
|
|
|
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
|
2017-07-25 15:38:25 -04:00
|
|
|
click_on('Save changes')
|
|
|
|
end
|
2016-12-05 10:00:26 -05:00
|
|
|
|
2017-01-26 06:52:58 -05:00
|
|
|
expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
|
2016-12-05 10:00:26 -05:00
|
|
|
expect(page).not_to have_content('Only allow merge requests to be merged if all discussions are resolved')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-26 06:52:58 -05:00
|
|
|
context 'when Pipelines are initially disabled' do
|
2016-12-05 10:00:26 -05:00
|
|
|
before do
|
|
|
|
project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED)
|
|
|
|
visit edit_project_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'shows the Merge Requests settings that do not depend on Builds feature' do
|
2017-01-26 06:52:58 -05:00
|
|
|
expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
|
2016-12-05 10:00:26 -05:00
|
|
|
expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
|
|
|
|
|
2017-07-25 15:38:25 -04:00
|
|
|
within('.sharing-permissions-form') do
|
2017-09-07 14:07:40 -04:00
|
|
|
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
|
2017-07-25 15:38:25 -04:00
|
|
|
click_on('Save changes')
|
|
|
|
end
|
2016-12-05 10:00:26 -05:00
|
|
|
|
2017-01-26 06:52:58 -05:00
|
|
|
expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds')
|
2016-12-05 10:00:26 -05:00
|
|
|
expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when Merge Request are initially disabled' do
|
|
|
|
before do
|
|
|
|
project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED)
|
|
|
|
visit edit_project_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'does not show the Merge Requests settings' do
|
2017-01-26 06:52:58 -05:00
|
|
|
expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
|
2016-12-05 10:00:26 -05:00
|
|
|
expect(page).not_to have_content('Only allow merge requests to be merged if all discussions are resolved')
|
|
|
|
|
2017-07-25 15:38:25 -04:00
|
|
|
within('.sharing-permissions-form') do
|
2017-09-07 14:07:40 -04:00
|
|
|
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
|
2017-07-25 15:38:25 -04:00
|
|
|
click_on('Save changes')
|
|
|
|
end
|
2016-12-05 10:00:26 -05:00
|
|
|
|
2017-01-26 06:52:58 -05:00
|
|
|
expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds')
|
2016-12-05 10:00:26 -05:00
|
|
|
expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
|
|
|
|
end
|
|
|
|
end
|
2017-03-17 08:35:39 -04:00
|
|
|
|
|
|
|
describe 'Checkbox to enable merge request link' do
|
|
|
|
before do
|
|
|
|
visit edit_project_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'is initially checked' do
|
|
|
|
checkbox = find_field('project_printing_merge_request_link_enabled')
|
|
|
|
expect(checkbox).to be_checked
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'when unchecked sets :printing_merge_request_link_enabled to false' do
|
|
|
|
uncheck('project_printing_merge_request_link_enabled')
|
2017-07-25 15:38:25 -04:00
|
|
|
within('.merge-request-settings-form') do
|
|
|
|
click_on('Save changes')
|
|
|
|
end
|
2017-03-17 08:35:39 -04:00
|
|
|
|
|
|
|
# Wait for save to complete and page to reload
|
|
|
|
checkbox = find_field('project_printing_merge_request_link_enabled')
|
|
|
|
expect(checkbox).not_to be_checked
|
|
|
|
|
|
|
|
project.reload
|
|
|
|
expect(project.printing_merge_request_link_enabled).to be(false)
|
|
|
|
end
|
|
|
|
end
|
2016-12-05 10:00:26 -05:00
|
|
|
end
|