Skip to content

Commit

Permalink
[ActsAsMiqSet] Fix incorrect name validation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NickLaMuro committed Jul 13, 2021
1 parent 2f3fdcd commit 85ee6fb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/extensions/ar_miq_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 85ee6fb

Please sign in to comment.