From 01f0c3f308542afa8fa262638d94d10420bd2e78 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 2 Jul 2013 23:28:56 -0300 Subject: Remove deprecated Hash#diff with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead. --- activesupport/CHANGELOG.md | 7 +++++++ activesupport/lib/active_support/core_ext/hash.rb | 1 - activesupport/lib/active_support/core_ext/hash/diff.rb | 16 ---------------- activesupport/test/core_ext/hash_ext_test.rb | 6 ------ 4 files changed, 7 insertions(+), 23 deletions(-) delete mode 100644 activesupport/lib/active_support/core_ext/hash/diff.rb diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 1853c6048b..061f296dc5 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,10 @@ +* Remove deprecated `Hash#diff` with no replacement. + + If you're using it to compare hashes for the purpose of testing, please use + MiniTest's `assert_equal` instead. + + *Carlos Antonio da Silva* + * Remove deprecated `Date#to_time_in_current_zone` in favour of `Date#in_time_zone`. *Vipul A M* diff --git a/activesupport/lib/active_support/core_ext/hash.rb b/activesupport/lib/active_support/core_ext/hash.rb index 501483498d..686f12c6da 100644 --- a/activesupport/lib/active_support/core_ext/hash.rb +++ b/activesupport/lib/active_support/core_ext/hash.rb @@ -1,6 +1,5 @@ require 'active_support/core_ext/hash/conversions' require 'active_support/core_ext/hash/deep_merge' -require 'active_support/core_ext/hash/diff' require 'active_support/core_ext/hash/except' require 'active_support/core_ext/hash/indifferent_access' require 'active_support/core_ext/hash/keys' diff --git a/activesupport/lib/active_support/core_ext/hash/diff.rb b/activesupport/lib/active_support/core_ext/hash/diff.rb deleted file mode 100644 index 4359213380..0000000000 --- a/activesupport/lib/active_support/core_ext/hash/diff.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'active_support/deprecation' - -class Hash - # Returns a hash that represents the difference between two hashes. - # - # {1 => 2}.diff(1 => 2) # => {} - # {1 => 2}.diff(1 => 3) # => {1 => 2} - # {}.diff(1 => 2) # => {1 => 2} - # {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4} - def diff(other) - ActiveSupport::Deprecation.warn "Hash#diff is no longer used inside of Rails, and is being deprecated with no replacement. If you're using it to compare hashes for the purpose of testing, please use MiniTest's assert_equal instead." - dup. - delete_if { |k, v| other[k] == v }. - merge!(other.dup.delete_if { |k, v| has_key?(k) }) - end -end diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index c6d7ab618c..0857796036 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -701,12 +701,6 @@ class HashExtTest < ActiveSupport::TestCase assert_equal expected, merged end - def test_diff - assert_deprecated do - assert_equal({ :a => 2 }, { :a => 2, :b => 5 }.diff({ :a => 1, :b => 5 })) - end - end - def test_slice original = { :a => 'x', :b => 'y', :c => 10 } expected = { :a => 'x', :b => 'y' } -- cgit v1.2.3