Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure Hash#except is allowed on a frozen hash. References #382

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit 980c2985fd16ec51c32cc90794be655d0cd08c49 1 parent 91c14e9
@mislav mislav authored lifo committed
View
2  activesupport/lib/active_support/core_ext/hash/except.rb
@@ -10,7 +10,7 @@ module Hash #:nodoc:
module Except
# Returns a new hash without the given keys.
def except(*keys)
- clone.except!(*keys)
+ dup.except!(*keys)
end
# Replaces the hash without only the given keys.
View
14 activesupport/test/core_ext/hash_ext_test.rb
@@ -310,6 +310,20 @@ def test_except
assert_equal expected, original.except!(:c)
assert_equal expected, original
end
+
+ def test_except_with_original_frozen
+ original = { :a => 'x', :b => 'y' }
+ original.freeze
+ assert_nothing_raised { original.except(:a) }
+ end
+
+ uses_mocha 'except with expectation' do
+ def test_except_with_mocha_expectation_on_original
+ original = { :a => 'x', :b => 'y' }
+ original.expects(:delete).never
+ original.except(:a)
+ end
+ end
end
class IWriteMyOwnXML
Please sign in to comment.
Something went wrong with that request. Please try again.