Commit 7e34a19f authored by Douwe Maan's avatar Douwe Maan

Check whether new service created from template is valid after unflagging it as a template

parent 3f784d8f
...@@ -281,9 +281,9 @@ class Service < ActiveRecord::Base ...@@ -281,9 +281,9 @@ class Service < ActiveRecord::Base
def self.build_from_template(project_id, template) def self.build_from_template(project_id, template)
service = template.dup service = template.dup
service.active = false unless service.valid?
service.template = false service.template = false
service.project_id = project_id service.project_id = project_id
service.active = false if service.active? && !service.valid?
service service
end end
......
...@@ -78,7 +78,7 @@ describe Service do ...@@ -78,7 +78,7 @@ describe Service do
context 'when template is invalid' do context 'when template is invalid' do
it 'sets service template to inactive when template is invalid' do it 'sets service template to inactive when template is invalid' do
project = create(:project) project = create(:project)
template = JiraService.new(template: true, active: true) template = KubernetesService.new(template: true, active: true)
template.save(validate: false) template.save(validate: false)
service = described_class.build_from_template(project.id, template) service = described_class.build_from_template(project.id, template)
......
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