summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2018-07-05 11:43:48 +0200
committerDouwe Maan <douwe@selenight.nl>2018-07-05 11:43:48 +0200
commit7e34a19f291cecb359e9e77c60a0fc169fe3c18c (patch)
tree154c17ded4a874305c7c44d54aa6981ea435aaea
parent3f784d8f3413288cc39da5577ce6b5c17eb9c004 (diff)
downloadgitlab-ce-7e34a19f291cecb359e9e77c60a0fc169fe3c18c.tar.gz
Check whether new service created from template is valid after unflagging it as a template
-rw-r--r--app/models/service.rb2
-rw-r--r--spec/models/service_spec.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/app/models/service.rb b/app/models/service.rb
index 1d259bcfec7..ad835293b46 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -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
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 28c908ea425..a849af062c5 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -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)