mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
OrderedHash#select now preserves order [#5843 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
committed by
Santiago Pastorino
parent
990f52ebd7
commit
697f4851b8
@@ -137,6 +137,8 @@ module ActiveSupport
|
||||
|
||||
alias_method :each_pair, :each
|
||||
|
||||
alias_method :select, :find_all
|
||||
|
||||
def clear
|
||||
super
|
||||
@keys.clear
|
||||
|
||||
@@ -109,6 +109,14 @@ class OrderedHashTest < Test::Unit::TestCase
|
||||
assert_equal @keys, keys
|
||||
end
|
||||
|
||||
def test_find_all
|
||||
assert_equal @keys, @ordered_hash.find_all { true }.map(&:first)
|
||||
end
|
||||
|
||||
def test_select
|
||||
assert_equal @keys, @ordered_hash.select { true }.map(&:first)
|
||||
end
|
||||
|
||||
def test_delete_if
|
||||
copy = @ordered_hash.dup
|
||||
copy.delete('pink')
|
||||
|
||||
Reference in New Issue
Block a user