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:
commit
0d019afcd5
3 changed files with 15 additions and 1 deletions
|
@ -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
|
* Add missing time zone definitions for Russian Federation and sync them
|
||||||
with `zone.tab` file from tzdata version 2014j (latest).
|
with `zone.tab` file from tzdata version 2014j (latest).
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ module ActiveSupport
|
||||||
value.nested_under_indifferent_access
|
value.nested_under_indifferent_access
|
||||||
end
|
end
|
||||||
elsif value.is_a?(Array)
|
elsif value.is_a?(Array)
|
||||||
unless options[:for] == :assignment
|
if options[:for] != :assignment || value.frozen?
|
||||||
value = value.dup
|
value = value.dup
|
||||||
end
|
end
|
||||||
value.map! { |e| convert_value(e, options) }
|
value.map! { |e| convert_value(e, options) }
|
||||||
|
|
|
@ -7,4 +7,11 @@ class HashWithIndifferentAccessTest < ActiveSupport::TestCase
|
||||||
hash.reverse_merge! key: :new_value
|
hash.reverse_merge! key: :new_value
|
||||||
assert_equal :old_value, hash[:key]
|
assert_equal :old_value, hash[:key]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_frozen_value
|
||||||
|
value = [1, 2, 3].freeze
|
||||||
|
hash = {}.with_indifferent_access
|
||||||
|
hash[:key] = value
|
||||||
|
assert_equal hash[:key], value
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue