Permalink
Browse files

Merge pull request #14327 from zzak/backport_a94966e

Backport a94966e
  • Loading branch information...
spastorino committed Mar 8, 2014
2 parents 6dd0f68 + af39f58 commit 93086d25582d17fc839a3a38709eb1c9d867f451
Showing with 8 additions and 1 deletion.
  1. +4 −0 activesupport/lib/active_support/ordered_hash.rb
  2. +4 −1 activesupport/test/ordered_hash_test.rb
@@ -28,6 +28,10 @@ def encode_with(coder)
coder.represent_seq '!omap', map { |k,v| { k => v } }
end
+ def select(*args, &block)
+ dup.tap { |hash| hash.select!(*args, &block) }
+ end
+
def reject(*args, &block)
dup.tap { |hash| hash.reject!(*args, &block) }
end
@@ -120,7 +120,9 @@ def test_find_all
end
def test_select
- assert_equal @keys, @ordered_hash.select { true }.map(&:first)
+ new_ordered_hash = @ordered_hash.select { true }
+ assert_equal @keys, new_ordered_hash.map(&:first)
+ assert_instance_of ActiveSupport::OrderedHash, new_ordered_hash
end
def test_delete_if
@@ -143,6 +145,7 @@ def test_reject
assert_equal copy, @ordered_hash
assert !new_ordered_hash.keys.include?('pink')
assert @ordered_hash.keys.include?('pink')
+ assert_instance_of ActiveSupport::OrderedHash, new_ordered_hash
end
def test_clear

0 comments on commit 93086d2

Please sign in to comment.