From b8402faee6e3437c4d31872a1d7e7451942c02a4 Mon Sep 17 00:00:00 2001 From: d-m-u Date: Wed, 3 Jan 2018 16:26:58 -0500 Subject: [PATCH] Fixes unique_within_region and STI per https://github.com/ManageIQ/manageiq/issues/16739 --- app/models/customization_template.rb | 2 +- spec/factories/customization_template.rb | 2 +- spec/factories/pxe_image_type.rb | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/customization_template.rb b/app/models/customization_template.rb index c6bf2ab8f89..f152bb1be76 100644 --- a/app/models/customization_template.rb +++ b/app/models/customization_template.rb @@ -5,7 +5,7 @@ class CustomizationTemplate < ApplicationRecord has_many :pxe_images, :through => :pxe_image_type validates :pxe_image_type, :presence => true, :unless => :system? - validates :name, :uniqueness => { :scope => :pxe_image_type }, :unique_within_region => true + validates :name, :unique_within_region => true scope :with_pxe_image_type_id, ->(pxe_image_type_id) { where(:pxe_image_type_id => pxe_image_type_id) } scope :with_system, ->(bool = true) { where(:system => bool) } diff --git a/spec/factories/customization_template.rb b/spec/factories/customization_template.rb index 1afb5d57d9f..cd581af7dca 100644 --- a/spec/factories/customization_template.rb +++ b/spec/factories/customization_template.rb @@ -22,7 +22,7 @@ end factory :customization_template_sysprep do - sequence(:name) { |n| "customization_template_syspre_#{seq_padded_for_sorting(n)}" } + sequence(:name) { |n| "customization_template_sysprep_#{seq_padded_for_sorting(n)}" } sequence(:description) { |n| "Customization Template Sysprep #{seq_padded_for_sorting(n)}" } after(:build) do |x| x.pxe_image_type ||= FactoryGirl.create(:pxe_image_type) diff --git a/spec/factories/pxe_image_type.rb b/spec/factories/pxe_image_type.rb index c23c4843c79..4f81d594523 100644 --- a/spec/factories/pxe_image_type.rb +++ b/spec/factories/pxe_image_type.rb @@ -1,4 +1,5 @@ FactoryGirl.define do factory :pxe_image_type do + sequence(:name) { |n| "pxe_image_type_#{seq_padded_for_sorting(n)}" } end end