2016-07-20 08:33:13 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
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)
|
|
|
|
|
2017-04-05 14:21:31 -04:00
|
|
|
page.check('Auto-cancel redundant, pending 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
|
|
|
|
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
|
|
|
|
|
|
|
|
context 'when auto devops is turned on group parent level', :nested_groups do
|
|
|
|
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
|
|
|
|
click_button 'Reset runners registration token'
|
|
|
|
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
|