aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/ordered_hash_test.rb
diff options
context:
space:
mode:
authorEloy Duran <eloy.de.enige@gmail.com>2008-12-11 14:12:06 +0100
committerMichael Koziarski <michael@koziarski.com>2008-12-11 14:32:20 +0100
commit7394d12dc7c4bd6c1604e482042efab23f455794 (patch)
treee548b62a726ca7e5316538d2a47fd5bb7517c003 /activesupport/test/ordered_hash_test.rb
parent69387ce0169b95d3a170cfb1c66a7570b1746e37 (diff)
downloadrails-7394d12dc7c4bd6c1604e482042efab23f455794.tar.gz
rails-7394d12dc7c4bd6c1604e482042efab23f455794.tar.bz2
rails-7394d12dc7c4bd6c1604e482042efab23f455794.zip
Fixed ActiveSupport::OrderedHash #delete_if, #reject!, and #reject, which did not sync the @keys after the operation.
This probably holds true for other mutating methods as well. Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activesupport/test/ordered_hash_test.rb')
-rw-r--r--activesupport/test/ordered_hash_test.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
index 094f9316d6..ca5fce6267 100644
--- a/activesupport/test/ordered_hash_test.rb
+++ b/activesupport/test/ordered_hash_test.rb
@@ -83,4 +83,24 @@ class OrderedHashTest < Test::Unit::TestCase
def test_each_with_index
@ordered_hash.each_with_index { |pair, index| assert_equal [@keys[index], @values[index]], pair}
end
-end
+
+ def test_delete_if
+ (copy = @ordered_hash.dup).delete('pink')
+ assert_equal copy, @ordered_hash.delete_if { |k, _| k == 'pink' }
+ assert !@ordered_hash.keys.include?('pink')
+ end
+
+ def test_reject!
+ (copy = @ordered_hash.dup).delete('pink')
+ @ordered_hash.reject! { |k, _| k == 'pink' }
+ assert_equal copy, @ordered_hash
+ assert !@ordered_hash.keys.include?('pink')
+ end
+
+ def test_reject
+ copy = @ordered_hash.dup
+ new_ordered_hash = @ordered_hash.reject { |k, _| k == 'pink' }
+ assert_equal copy, @ordered_hash
+ assert !new_ordered_hash.keys.include?('pink')
+ end
+end \ No newline at end of file