mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ensure Hash#except is allowed on a frozen hash. References #382
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
parent
113de01eaf
commit
96055414d6
2 changed files with 15 additions and 1 deletions
|
@ -10,7 +10,7 @@ module ActiveSupport #: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 the given keys.
|
||||
|
|
|
@ -341,6 +341,20 @@ class HashExtTest < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue