Skip to content
Snippets Groups Projects
Commit 7eddfef4 authored by Robert Speicher's avatar Robert Speicher
Browse files

Merge branch 'dm-invalid-active-service-template' into 'master'

Deactivate new KubernetesService created from active template to prevent project creation from failing

Closes gitlab-ee#6753

See merge request gitlab-org/gitlab-ce!20400
parents 633ac497 cf79a87e
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Loading
Loading
@@ -240,7 +240,7 @@ class KubernetesService < DeploymentService
end
 
def deprecation_validation
return if active_changed?(from: true, to: false)
return if active_changed?(from: true, to: false) || (new_record? && !active?)
 
if deprecated?
errors[:base] << deprecation_message
Loading
Loading
Loading
Loading
@@ -281,9 +281,9 @@ class Service < ActiveRecord::Base
 
def self.build_from_template(project_id, template)
service = template.dup
service.active = false unless service.valid?
service.template = false
service.project_id = project_id
service.active = false if service.active? && !service.valid?
service
end
 
Loading
Loading
---
title: Deactivate new KubernetesService created from active template to prevent project creation from failing
merge_request:
author:
type: fixed
Loading
Loading
@@ -78,7 +78,7 @@ describe Service do
context 'when template is invalid' do
it 'sets service template to inactive when template is invalid' do
project = create(:project)
template = JiraService.new(template: true, active: true)
template = KubernetesService.new(template: true, active: true)
template.save(validate: false)
 
service = described_class.build_from_template(project.id, template)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment