2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
describe "Projects > Settings > Pipelines settings" do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project) }
|
2016-08-24 12:49:21 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:role) { :developer }
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2018-03-17 18:26:18 +05:30
|
|
|
project.add_role(user, role)
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'for developer' do
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:role) { :developer }
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
it 'to be disallowed to view' do
|
2018-03-17 18:26:18 +05:30
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
expect(page.status_code).to eq(404)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
context 'for maintainer' do
|
|
|
|
let(:role) { :maintainer }
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
it 'be allowed to change' do
|
2018-03-17 18:26:18 +05:30
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
fill_in('Test coverage parsing', with: 'coverage_regex')
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
page.within '#js-general-pipeline-settings' do
|
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
|
|
|
|
expect(page.status_code).to eq(200)
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
page.within '#js-general-pipeline-settings' do
|
|
|
|
expect(page).to have_button('Save changes', disabled: false)
|
|
|
|
end
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
it 'updates auto_cancel_pending_pipelines' do
|
2018-03-17 18:26:18 +05:30
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
page.check('Auto-cancel redundant, pending pipelines')
|
2018-10-15 14:42:47 +05:30
|
|
|
page.within '#js-general-pipeline-settings' do
|
|
|
|
click_on 'Save changes'
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(page.status_code).to eq(200)
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
page.within '#js-general-pipeline-settings' do
|
|
|
|
expect(page).to have_button('Save changes', disabled: false)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
checkbox = find_field('project_auto_cancel_pending_pipelines')
|
|
|
|
expect(checkbox).to be_checked
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
it 'updates forward_deployment_enabled' do
|
|
|
|
visit project_settings_ci_cd_path(project)
|
|
|
|
|
|
|
|
checkbox = find_field('project_forward_deployment_enabled')
|
|
|
|
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
|
|
|
|
|
|
|
|
checkbox = find_field('project_forward_deployment_enabled')
|
|
|
|
expect(checkbox).not_to be_checked
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'Auto DevOps' do
|
2018-11-18 11:00:15 +05:30
|
|
|
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)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
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-10-15 14:42:47 +05:30
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
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-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
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-10-12 21:52:04 +05:30
|
|
|
context 'when auto devops is turned on group parent level' do
|
2019-07-07 11:18:12 +05:30
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
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-08-24 12:49:21 +05:30
|
|
|
end
|
|
|
|
end
|