From 85ee6fb4ee3261d63f3ee0cf56a2874371491111 Mon Sep 17 00:00:00 2001 From: Nick LaMuro Date: Thu, 17 Jun 2021 19:10:10 -0500 Subject: [PATCH] [ActsAsMiqSet] Fix incorrect name validation Previously, this had existed as it is now, but it didn't seem to make a difference to the specs with the previous `RelationshipMixin` version of this code. However, it seems with this change, many of the specs fail with the following: 32) MiqWidget multiple groups for non-self service user contents created for one timezone per group with timezone_matters = false Failure/Error: factory_exists?(factory) ? super : class_from_symbol(factory).create!(*args) ActiveRecord::RecordInvalid: Validation failed: MiqWidgetSet: Name has already been taken So this form seems to be the correct one. --- lib/extensions/ar_miq_set.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/extensions/ar_miq_set.rb b/lib/extensions/ar_miq_set.rb index 09e6383a075..5a273131559 100644 --- a/lib/extensions/ar_miq_set.rb +++ b/lib/extensions/ar_miq_set.rb @@ -62,8 +62,10 @@ module ActsAsMiqSet validates :name, :presence => true, - :uniqueness_when_changed => [:set_type, :userid, :group_id], - :if => proc { |c| c.class.in_my_region.exists?(:name => c.name) } + :uniqueness_when_changed => { + :scope => [:set_type, :userid, :group_id], + :if => proc { |c| c.class.in_my_region.exists?(:name => c.name) } + } validates :description, :presence => true