1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #18551 from aditya-kapoor/fix-frozen-hwia

Fix assignment for frozen value in HWIA
This commit is contained in:
Andrew White 2015-01-16 21:56:26 +00:00
commit 0d019afcd5
3 changed files with 15 additions and 1 deletions

View file

@ -1,3 +1,10 @@
* Duplicate frozen array when assigning it to a HashWithIndifferentAccess so
that it doesn't raise a `RuntimeError` when calling `map!` on it in `convert_value`.
Fixes #18550.
*Aditya Kapoor*
* Add missing time zone definitions for Russian Federation and sync them
with `zone.tab` file from tzdata version 2014j (latest).

View file

@ -267,7 +267,7 @@ module ActiveSupport
value.nested_under_indifferent_access
end
elsif value.is_a?(Array)
unless options[:for] == :assignment
if options[:for] != :assignment || value.frozen?
value = value.dup
end
value.map! { |e| convert_value(e, options) }

View file

@ -7,4 +7,11 @@ class HashWithIndifferentAccessTest < ActiveSupport::TestCase
hash.reverse_merge! key: :new_value
assert_equal :old_value, hash[:key]
end
def test_frozen_value
value = [1, 2, 3].freeze
hash = {}.with_indifferent_access
hash[:key] = value
assert_equal hash[:key], value
end
end