Browse files

OrderedHash#select now preserves order [#5843 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
1 parent 990f52e commit 697f4851b8bc4eb539b3e565e8b6349cafed8aaa James A. Rosen committed with spastorino Oct 20, 2010
Showing with 10 additions and 0 deletions.
  1. +2 −0 activesupport/lib/active_support/ordered_hash.rb
  2. +8 −0 activesupport/test/ordered_hash_test.rb
View
2 activesupport/lib/active_support/ordered_hash.rb
@@ -137,6 +137,8 @@ def each
alias_method :each_pair, :each
+ alias_method :select, :find_all
+
def clear
super
@keys.clear
View
8 activesupport/test/ordered_hash_test.rb
@@ -109,6 +109,14 @@ def test_each_pair
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')

0 comments on commit 697f485

Please sign in to comment.