Skip to content

Commit

Permalink
Fixes unique_within_region and STI per ManageIQ#16739
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jan 10, 2018
1 parent 79d25e3 commit b8402fa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/customization_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/customization_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions spec/factories/pxe_image_type.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b8402fa

Please sign in to comment.