2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-20 08:33:13 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe "Projects > Settings > Pipelines settings" do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2016-07-20 08:33:13 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:role) { :developer }
|
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_role(user, role)
|
2016-07-20 08:33:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'for developer' do
|
2018-04-06 08:40:33 -04:00
|
|
|
let(:role) { :developer }
|
2016-07-20 08:33:13 -04:00
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
it 'to be disallowed to view' do
|
2017-11-20 11:40:01 -05:00
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
2016-07-20 08:33:13 -04:00
|
|
|
expect(page.status_code).to eq(404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-11 10:36:08 -04:00
|
|
|
context 'for maintainer' do
|
|
|
|
let(:role) { :maintainer }
|
2016-07-20 08:33:13 -04:00
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
it 'be allowed to change' do
|
2017-11-20 11:40:01 -05:00
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
2016-07-20 08:33:13 -04:00
|
|
|
fill_in('Test coverage parsing', with: 'coverage_regex')
|
2018-04-12 11:51:25 -04:00
|
|
|
|
2018-04-17 12:37:16 -04:00
|
|
|
page.within '#js-general-pipeline-settings' do
|
2018-04-11 13:04:35 -04:00
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
2016-07-20 08:33:13 -04:00
|
|
|
|
|
|
|
expect(page.status_code).to eq(200)
|
2018-04-12 11:51:25 -04:00
|
|
|
|
2018-04-17 12:37:16 -04:00
|
|
|
page.within '#js-general-pipeline-settings' do
|
2018-04-11 13:04:35 -04:00
|
|
|
expect(page).to have_button('Save changes', disabled: false)
|
|
|
|
end
|
2018-04-12 11:51:25 -04:00
|
|
|
|
2016-07-20 08:33:13 -04:00
|
|
|
expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
|
|
|
|
end
|
2017-04-05 14:21:31 -04:00
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
it 'updates auto_cancel_pending_pipelines' do
|
2017-11-20 11:40:01 -05:00
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
2021-01-27 04:09:01 -05:00
|
|
|
page.check('Auto-cancel redundant pipelines')
|
2018-04-17 12:37:16 -04:00
|
|
|
page.within '#js-general-pipeline-settings' do
|
2018-04-11 13:04:35 -04:00
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
2017-04-05 14:21:31 -04:00
|
|
|
|
|
|
|
expect(page.status_code).to eq(200)
|
2018-04-12 11:51:25 -04:00
|
|
|
|
2018-04-17 12:37:16 -04:00
|
|
|
page.within '#js-general-pipeline-settings' do
|
2018-04-11 13:04:35 -04:00
|
|
|
expect(page).to have_button('Save changes', disabled: false)
|
|
|
|
end
|
2017-04-05 14:21:31 -04:00
|
|
|
|
|
|
|
checkbox = find_field('project_auto_cancel_pending_pipelines')
|
|
|
|
expect(checkbox).to be_checked
|
|
|
|
end
|
2017-09-04 03:27:09 -04:00
|
|
|
|
2020-03-03 04:07:54 -05:00
|
|
|
it 'updates forward_deployment_enabled' do
|
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
2020-10-20 02:09:03 -04:00
|
|
|
checkbox = find_field('project_ci_cd_settings_attributes_forward_deployment_enabled')
|
2020-03-03 04:07:54 -05:00
|
|
|
expect(checkbox).to be_checked
|
|
|
|
|
|
|
|
checkbox.set(false)
|
|
|
|
|
|
|
|
page.within '#js-general-pipeline-settings' do
|
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page.status_code).to eq(200)
|
|
|
|
|
|
|
|
page.within '#js-general-pipeline-settings' do
|
|
|
|
expect(page).to have_button('Save changes', disabled: false)
|
|
|
|
end
|
|
|
|
|
2020-10-20 02:09:03 -04:00
|
|
|
checkbox = find_field('project_ci_cd_settings_attributes_forward_deployment_enabled')
|
2020-03-03 04:07:54 -05:00
|
|
|
expect(checkbox).not_to be_checked
|
|
|
|
end
|
|
|
|
|
2017-11-20 11:40:01 -05:00
|
|
|
describe 'Auto DevOps' do
|
2018-08-06 17:51:37 -04:00
|
|
|
context 'when auto devops is turned on instance-wide' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(auto_devops_enabled: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'auto devops is on by default and can be manually turned off' do
|
|
|
|
visit project_settings_ci_cd_path(project)
|
2017-09-04 03:27:09 -04:00
|
|
|
|
2018-08-06 17:51:37 -04:00
|
|
|
page.within '#autodevops-settings' do
|
|
|
|
expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
|
|
|
|
expect(page).to have_content('instance enabled')
|
|
|
|
uncheck 'Default to Auto DevOps pipeline'
|
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page.status_code).to eq(200)
|
|
|
|
expect(project.auto_devops).to be_present
|
|
|
|
expect(project.auto_devops).not_to be_enabled
|
|
|
|
|
|
|
|
page.within '#autodevops-settings' do
|
|
|
|
expect(find_field('project_auto_devops_attributes_enabled')).not_to be_checked
|
|
|
|
expect(page).not_to have_content('instance enabled')
|
|
|
|
end
|
2018-04-11 13:04:35 -04:00
|
|
|
end
|
2018-08-06 17:51:37 -04:00
|
|
|
end
|
2017-11-20 11:40:01 -05:00
|
|
|
|
2018-08-06 17:51:37 -04:00
|
|
|
context 'when auto devops is not turned on instance-wide' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(auto_devops_enabled: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'auto devops is off by default and can be manually turned on' do
|
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
|
|
|
page.within '#autodevops-settings' do
|
|
|
|
expect(page).not_to have_content('instance enabled')
|
|
|
|
expect(find_field('project_auto_devops_attributes_enabled')).not_to be_checked
|
|
|
|
check 'Default to Auto DevOps pipeline'
|
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page.status_code).to eq(200)
|
|
|
|
expect(project.auto_devops).to be_present
|
|
|
|
expect(project.auto_devops).to be_enabled
|
|
|
|
|
|
|
|
page.within '#autodevops-settings' do
|
|
|
|
expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
|
|
|
|
expect(page).not_to have_content('instance enabled')
|
|
|
|
end
|
|
|
|
end
|
2019-03-12 06:15:33 -04:00
|
|
|
|
|
|
|
context 'when auto devops is turned on group level' do
|
|
|
|
before do
|
|
|
|
project.update!(namespace: create(:group, :auto_devops_enabled))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders group enabled badge' do
|
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
|
|
|
page.within '#autodevops-settings' do
|
|
|
|
expect(page).to have_content('group enabled')
|
|
|
|
expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-24 05:20:54 -04:00
|
|
|
context 'when auto devops is turned on group parent level' do
|
2019-03-12 06:15:33 -04:00
|
|
|
before do
|
|
|
|
group = create(:group, parent: create(:group, :auto_devops_enabled))
|
|
|
|
project.update!(namespace: group)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders group enabled badge' do
|
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
|
|
|
page.within '#autodevops-settings' do
|
|
|
|
expect(page).to have_content('group enabled')
|
|
|
|
expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-11-20 11:40:01 -05:00
|
|
|
end
|
2017-09-04 03:27:09 -04:00
|
|
|
end
|
2018-09-10 17:57:03 -04:00
|
|
|
|
|
|
|
describe 'runners registration token' do
|
|
|
|
let!(:token) { project.runners_token }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has a registration token' do
|
|
|
|
expect(page.find('#registration_token')).to have_content(token)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'reload registration token' do
|
|
|
|
let(:page_token) { find('#registration_token').text }
|
|
|
|
|
|
|
|
before do
|
2021-01-12 16:10:47 -05:00
|
|
|
click_button 'Reset registration token'
|
2018-09-10 17:57:03 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'changes registration token' do
|
|
|
|
expect(page_token).not_to eq token
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-07-20 08:33:13 -04:00
|
|
|
end
|
|
|
|
end
|