Commit 89d3fcd1 authored by bikebilly's avatar bikebilly

Remove Auto DevOps checkboxes - backend

parent 50eb1252
...@@ -29,7 +29,6 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController ...@@ -29,7 +29,6 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController
:runners_token, :builds_enabled, :build_allow_git_fetch, :runners_token, :builds_enabled, :build_allow_git_fetch,
:build_timeout_in_minutes, :build_coverage_regex, :public_builds, :build_timeout_in_minutes, :build_coverage_regex, :public_builds,
:auto_cancel_pending_pipelines, :ci_config_path, :auto_cancel_pending_pipelines, :ci_config_path,
:run_auto_devops_pipeline_implicit, :run_auto_devops_pipeline_explicit,
auto_devops_attributes: [:id, :domain, :enabled] auto_devops_attributes: [:id, :domain, :enabled]
) )
end end
......
...@@ -8,22 +8,6 @@ module AutoDevopsHelper ...@@ -8,22 +8,6 @@ module AutoDevopsHelper
!project.ci_service !project.ci_service
end end
def show_run_auto_devops_pipeline_checkbox_for_instance_setting?(project)
return false if project.repository.gitlab_ci_yml
if project&.auto_devops&.enabled.present?
!project.auto_devops.enabled && current_application_settings.auto_devops_enabled?
else
current_application_settings.auto_devops_enabled?
end
end
def show_run_auto_devops_pipeline_checkbox_for_explicit_setting?(project)
return false if project.repository.gitlab_ci_yml
!project.auto_devops_enabled?
end
def auto_devops_warning_message(project) def auto_devops_warning_message(project)
missing_domain = !project.auto_devops&.has_domain? missing_domain = !project.auto_devops&.has_domain?
missing_service = !project.deployment_platform&.active? missing_service = !project.deployment_platform&.active?
......
...@@ -15,7 +15,7 @@ module Projects ...@@ -15,7 +15,7 @@ module Projects
return error("Could not set the default branch") unless project.change_head(params[:default_branch]) return error("Could not set the default branch") unless project.change_head(params[:default_branch])
end end
if project.update_attributes(update_params) if project.update_attributes(params.except(:default_branch))
if project.previous_changes.include?('path') if project.previous_changes.include?('path')
project.rename_repo project.rename_repo
else else
...@@ -32,15 +32,13 @@ module Projects ...@@ -32,15 +32,13 @@ module Projects
end end
def run_auto_devops_pipeline? def run_auto_devops_pipeline?
params.dig(:run_auto_devops_pipeline_explicit) == 'true' || params.dig(:run_auto_devops_pipeline_implicit) == 'true' return false if project.repository.gitlab_ci_yml || !project.auto_devops.previous_changes.include?('enabled')
project.auto_devops.enabled? || (project.auto_devops.enabled.nil? && current_application_settings.auto_devops_enabled?)
end end
private private
def update_params
params.except(:default_branch, :run_auto_devops_pipeline_explicit, :run_auto_devops_pipeline_implicit)
end
def renaming_project_with_container_registry_tags? def renaming_project_with_container_registry_tags?
new_path = params[:path] new_path = params[:path]
......
...@@ -16,14 +16,13 @@ describe Projects::PipelinesSettingsController do ...@@ -16,14 +16,13 @@ describe Projects::PipelinesSettingsController do
patch :update, patch :update,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
project_id: project, project_id: project,
project: { auto_devops_attributes: params, project: {
run_auto_devops_pipeline_implicit: 'false', auto_devops_attributes: params
run_auto_devops_pipeline_explicit: auto_devops_pipeline } }
end end
context 'when updating the auto_devops settings' do context 'when updating the auto_devops settings' do
let(:params) { { enabled: '', domain: 'mepmep.md' } } let(:params) { { enabled: '', domain: 'mepmep.md' } }
let(:auto_devops_pipeline) { 'false' }
it 'redirects to the settings page' do it 'redirects to the settings page' do
subject subject
...@@ -44,7 +43,9 @@ describe Projects::PipelinesSettingsController do ...@@ -44,7 +43,9 @@ describe Projects::PipelinesSettingsController do
end end
context 'when run_auto_devops_pipeline is true' do context 'when run_auto_devops_pipeline is true' do
let(:auto_devops_pipeline) { 'true' } before do
expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(true)
end
it 'queues a CreatePipelineWorker' do it 'queues a CreatePipelineWorker' do
expect(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) expect(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args)
...@@ -54,7 +55,9 @@ describe Projects::PipelinesSettingsController do ...@@ -54,7 +55,9 @@ describe Projects::PipelinesSettingsController do
end end
context 'when run_auto_devops_pipeline is not true' do context 'when run_auto_devops_pipeline is not true' do
let(:auto_devops_pipeline) { 'false' } before do
expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(false)
end
it 'does not queue a CreatePipelineWorker' do it 'does not queue a CreatePipelineWorker' do
expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, :web, any_args) expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, :web, any_args)
......
...@@ -82,104 +82,4 @@ describe AutoDevopsHelper do ...@@ -82,104 +82,4 @@ describe AutoDevopsHelper do
it { is_expected.to eq(false) } it { is_expected.to eq(false) }
end end
end end
describe '.show_run_auto_devops_pipeline_checkbox_for_instance_setting?' do
subject { helper.show_run_auto_devops_pipeline_checkbox_for_instance_setting?(project) }
context 'when master contains a .gitlab-ci.yml file' do
before do
allow(project.repository).to receive(:gitlab_ci_yml).and_return("script: ['test']")
end
it { is_expected.to eq(false) }
end
context 'when auto devops is explicitly enabled' do
before do
project.create_auto_devops!(enabled: true)
end
it { is_expected.to eq(false) }
end
context 'when auto devops is explicitly disabled' do
before do
project.create_auto_devops!(enabled: false)
end
context 'when auto devops is enabled system-wide' do
before do
stub_application_setting(auto_devops_enabled: true)
end
it { is_expected.to eq(true) }
end
context 'when auto devops is disabled system-wide' do
before do
stub_application_setting(auto_devops_enabled: false)
end
it { is_expected.to eq(false) }
end
end
context 'when auto devops is set to instance setting' do
before do
project.create_auto_devops!(enabled: nil)
end
it { is_expected.to eq(false) }
end
end
describe '.show_run_auto_devops_pipeline_checkbox_for_explicit_setting?' do
subject { helper.show_run_auto_devops_pipeline_checkbox_for_explicit_setting?(project) }
context 'when master contains a .gitlab-ci.yml file' do
before do
allow(project.repository).to receive(:gitlab_ci_yml).and_return("script: ['test']")
end
it { is_expected.to eq(false) }
end
context 'when auto devops is explicitly enabled' do
before do
project.create_auto_devops!(enabled: true)
end
it { is_expected.to eq(false) }
end
context 'when auto devops is explicitly disabled' do
before do
project.create_auto_devops!(enabled: false)
end
it { is_expected.to eq(true) }
end
context 'when auto devops is set to instance setting' do
before do
project.create_auto_devops!(enabled: nil)
end
context 'when auto devops is enabled system-wide' do
before do
stub_application_setting(auto_devops_enabled: true)
end
it { is_expected.to eq(false) }
end
context 'when auto devops is disabled system-wide' do
before do
stub_application_setting(auto_devops_enabled: false)
end
it { is_expected.to eq(true) }
end
end
end
end end
...@@ -199,25 +199,54 @@ describe Projects::UpdateService do ...@@ -199,25 +199,54 @@ describe Projects::UpdateService do
end end
describe '#run_auto_devops_pipeline?' do describe '#run_auto_devops_pipeline?' do
subject { described_class.new(project, user, params).run_auto_devops_pipeline? } subject { described_class.new(project, user).run_auto_devops_pipeline? }
context 'when neither pipeline setting is true' do context 'when master contains a .gitlab-ci.yml file' do
let(:params) { {} } before do
allow(project.repository).to receive(:gitlab_ci_yml).and_return("script: ['test']")
end
it { is_expected.to eq(false) } it { is_expected.to eq(false) }
end end
context 'when run_auto_devops_pipeline_explicit is true' do context 'when auto devops is explicitly enabled' do
let(:params) { { run_auto_devops_pipeline_explicit: 'true' } } before do
project.create_auto_devops!(enabled: true)
end
it { is_expected.to eq(true) } it { is_expected.to eq(true) }
end end
context 'when run_auto_devops_pipeline_implicit is true' do context 'when auto devops is explicitly disabled' do
let(:params) { { run_auto_devops_pipeline_implicit: 'true' } } before do
project.create_auto_devops!(enabled: false)
end
it { is_expected.to eq(false) }
end
context 'when auto devops is set to instance setting' do
before do
project.create_auto_devops!(enabled: nil)
allow(project.auto_devops).to receive(:previous_changes).and_return('enabled' => true)
end
context 'when auto devops is enabled system-wide' do
before do
stub_application_setting(auto_devops_enabled: true)
end
it { is_expected.to eq(true) } it { is_expected.to eq(true) }
end end
context 'when auto devops is disabled system-wide' do
before do
stub_application_setting(auto_devops_enabled: false)
end
it { is_expected.to eq(false) }
end
end
end end
def update_project(project, user, opts) def update_project(project, user, opts)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment