mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #8158 from steveklabnik/deprecate_diff
Deprecate Hash#diff.
This commit is contained in:
commit
e56b8900f9
3 changed files with 5 additions and 3 deletions
|
@ -1,5 +1,4 @@
|
|||
require 'uri'
|
||||
require 'active_support/core_ext/hash/diff'
|
||||
require 'active_support/core_ext/hash/indifferent_access'
|
||||
require 'action_controller/metal/exceptions'
|
||||
|
||||
|
@ -44,9 +43,8 @@ module ActionDispatch
|
|||
|
||||
expected_options.stringify_keys!
|
||||
|
||||
# FIXME: minitest does object diffs, do we need to have our own?
|
||||
message ||= sprintf("The recognized options <%s> did not match <%s>, difference: <%s>",
|
||||
request.path_parameters, expected_options, expected_options.diff(request.path_parameters))
|
||||
request.path_parameters, expected_options, diff(expected_options, request.path_parameters))
|
||||
assert_equal(expected_options, request.path_parameters, message)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
## Rails 4.0.0 (unreleased) ##
|
||||
|
||||
* Deprecate Hash#diff in favor of MiniTest's #diff. *Steve Klabnik*
|
||||
|
||||
* Kernel#capture can catch output from subprocesses *Dmitry Vorotilin*
|
||||
|
||||
* `to_xml` conversions now use builder's `tag!` method instead of explicit invocation of `method_missing`.
|
||||
|
|
|
@ -6,6 +6,7 @@ class Hash
|
|||
# {}.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 diff instead."
|
||||
dup.
|
||||
delete_if { |k, v| other[k] == v }.
|
||||
merge!(other.dup.delete_if { |k, v| has_key?(k) })
|
||||
|
|
Loading…
Reference in a new issue