diff options
author | Robin Dupret <robin.dupret@gmail.com> | 2017-02-06 14:27:08 +0100 |
---|---|---|
committer | Robin Dupret <robin.dupret@gmail.com> | 2017-02-19 22:06:12 +0100 |
commit | e532531939a610c3a1ba4594d325b10a0c9b4546 (patch) | |
tree | 377843c41a67eaa8b0d3a2161549981edba61baa /activesupport/test | |
parent | 4f2aa162ed3dc419fa1a7880ecd77d47ba28a8d3 (diff) | |
download | rails-e532531939a610c3a1ba4594d325b10a0c9b4546.tar.gz rails-e532531939a610c3a1ba4594d325b10a0c9b4546.tar.bz2 rails-e532531939a610c3a1ba4594d325b10a0c9b4546.zip |
Deprecate the top-level `HashWithIndifferentAccess` contant
This constant was kept for the sake of backward compatibility; it
is still available under `ActiveSupport::HashWithIndifferentAccess`.
Furthermore, since Ruby 2.5 (https://bugs.ruby-lang.org/issues/11547)
won't support top level constant lookup, people would have to update
their code anyway.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 05813ad388..042bb60a22 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -8,6 +8,8 @@ require "active_support/core_ext/object/deep_dup" require "active_support/inflections" class HashExtTest < ActiveSupport::TestCase + HashWithIndifferentAccess = ActiveSupport::HashWithIndifferentAccess + class IndifferentHash < ActiveSupport::HashWithIndifferentAccess end @@ -1078,6 +1080,25 @@ class HashExtTest < ActiveSupport::TestCase assert_equal 1, hash[:a] assert_equal 3, hash[:b] end + + def test_top_level_hash_with_indifferent_access_is_deprecated + assert_deprecated do + ::HashWithIndifferentAccess.new + end + end + + def test_top_level_hash_with_indifferent_access_can_be_extended + assert_deprecated do + Class.new(::HashWithIndifferentAccess) + end + end + + def test_yaml_encoding_outputs_an_activesupport_namespaced_constant + ActiveSupport::Deprecation.silence do + instance = ::HashWithIndifferentAccess.new + assert_includes instance.to_yaml, "ActiveSupport::HashWithIndifferentAccess" + end + end end class IWriteMyOwnXML @@ -1123,6 +1144,8 @@ class HashExtToParamTests < ActiveSupport::TestCase end class HashToXmlTest < ActiveSupport::TestCase + HashWithIndifferentAccess = ActiveSupport::HashWithIndifferentAccess + def setup @xml_options = { root: :person, skip_instruct: true, indent: 0 } end |