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