diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2018-03-03 08:59:38 +0900 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2018-03-02 16:40:55 -0800 |
commit | acbcec8ea869849f98213fea5e554bb3a82fea61 (patch) | |
tree | 4eda1100b0360ba544d9118c6700a1317df283c0 /activesupport/test/core_ext | |
parent | b1a9cee83082d6c7a58d87d06055c86fcdbc7644 (diff) | |
download | rails-acbcec8ea869849f98213fea5e554bb3a82fea61.tar.gz rails-acbcec8ea869849f98213fea5e554bb3a82fea61.tar.bz2 rails-acbcec8ea869849f98213fea5e554bb3a82fea61.zip |
Deprecate `active_support/core_ext/hash/compact`
Ruby 2.4+ provides `Hash#compact` and `Hash#compact!` natively,
so `active_support/core_ext/hash/compact` is no longer necessary.
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 38 |
1 files changed, 4 insertions, 34 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 50b811e79f..f4f0dd6b31 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -45,8 +45,6 @@ class HashExtTest < ActiveSupport::TestCase assert_respond_to h, :deep_stringify_keys! assert_respond_to h, :to_options assert_respond_to h, :to_options! - assert_respond_to h, :compact - assert_respond_to h, :compact! assert_respond_to h, :except assert_respond_to h, :except! end @@ -456,38 +454,10 @@ class HashExtTest < ActiveSupport::TestCase end end - def test_compact - hash_contain_nil_value = @symbols.merge(z: nil) - hash_with_only_nil_values = { a: nil, b: nil } - - h = hash_contain_nil_value.dup - assert_equal(@symbols, h.compact) - assert_equal(hash_contain_nil_value, h) - - h = hash_with_only_nil_values.dup - assert_equal({}, h.compact) - assert_equal(hash_with_only_nil_values, h) - - h = @symbols.dup - assert_equal(@symbols, h.compact) - assert_equal(@symbols, h) - end - - def test_compact! - hash_contain_nil_value = @symbols.merge(z: nil) - hash_with_only_nil_values = { a: nil, b: nil } - - h = hash_contain_nil_value.dup - assert_equal(@symbols, h.compact!) - assert_equal(@symbols, h) - - h = hash_with_only_nil_values.dup - assert_equal({}, h.compact!) - assert_equal({}, h) - - h = @symbols.dup - assert_nil(h.compact!) - assert_equal(@symbols, h) + def test_requiring_compact_is_deprecated + assert_deprecated do + require "active_support/core_ext/hash/compact" + end end end |