From cc388b8cf9e92c005e68280e0f241ed442e92e56 Mon Sep 17 00:00:00 2001 From: d-m-u Date: Mon, 18 Feb 2019 15:49:36 -0500 Subject: [PATCH] Service templates should have name presence checks --- app/models/service_template.rb | 1 + spec/factories/service_template.rb | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/models/service_template.rb b/app/models/service_template.rb index 84efa7014300..9fb161268cd8 100644 --- a/app/models/service_template.rb +++ b/app/models/service_template.rb @@ -45,6 +45,7 @@ class ServiceTemplate < ApplicationRecord include_concern 'Filter' include_concern 'Copy' + validates :name, :presence => true belongs_to :tenant # # These relationships are used to specify children spawned from a parent service # has_many :child_services, :class_name => "ServiceTemplate", :foreign_key => :service_template_id diff --git a/spec/factories/service_template.rb b/spec/factories/service_template.rb index 0172d10149ed..3a74d06ce627 100644 --- a/spec/factories/service_template.rb +++ b/spec/factories/service_template.rb @@ -1,8 +1,16 @@ FactoryBot.define do - factory :service_template - factory :service_template_orchestration, :class => 'ServiceTemplateOrchestration', :parent => :service_template - factory :service_template_ansible_playbook, :class => 'ServiceTemplateAnsiblePlaybook', :parent => :service_template - factory :service_template_container_template, :class => 'ServiceTemplateContainerTemplate', :parent => :service_template + factory :service_template do + sequence(:name) { |n| "service_template_#{seq_padded_for_sorting(n)}" } + end + factory :service_template_orchestration, :class => 'ServiceTemplateOrchestration', :parent => :service_template do + sequence(:name) { |n| "service_template_#{seq_padded_for_sorting(n)}" } + end + factory :service_template_ansible_playbook, :class => 'ServiceTemplateAnsiblePlaybook', :parent => :service_template do + sequence(:name) { |n| "service_template_#{seq_padded_for_sorting(n)}" } + end + factory :service_template_container_template, :class => 'ServiceTemplateContainerTemplate', :parent => :service_template do + sequence(:name) { |n| "service_template_#{seq_padded_for_sorting(n)}" } + end factory :service_template_transformation_plan, :class => 'ServiceTemplateTransformationPlan', :parent => :service_template do sequence(:name) { |n| "service_template_#{seq_padded_for_sorting(n)}" } end