Skip to content

Commit

Permalink
Redefine MiqGroup #settings and #settings=
Browse files Browse the repository at this point in the history
This commit ensures that #settings returns the same object that
exists in the object.

This ensures that calls like the following will work as expected:

group.settings[:a] = 1

Previously, #settings returned the duplicate object created by
Hash#with_indifferent_access

https://bugzilla.redhat.com/show_bug.cgi?id=1516793
  • Loading branch information
carbonin committed Nov 30, 2017
1 parent edbd592 commit b7c89d3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/models/miq_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,16 @@ def name
end

def settings
super && super.with_indifferent_access
current = super
return if current.nil?

self.settings = current.with_indifferent_access
super
end

def settings=(new_settings)
indifferent_settings = new_settings.try(:with_indifferent_access)
super(indifferent_settings)
end

def self.with_allowed_roles_for(user_or_group)
Expand Down

0 comments on commit b7c89d3

Please sign in to comment.