提交 b2ea8310 编写于 作者: A Abraham Chan

Fix HashWithIndifferentAccess#without bug

上级 2ab0df00
* Fix bug where `#without` for `ActiveSupport::HashWithIndifferentAccess` would fail
with symbol arguments
*Abraham Chan*
* Treat `#delete_prefix`, `#delete_suffix` and `#unicode_normalize` results as non-`html_safe`.
Ensure safety of arguments for `#insert`, `#[]=` and `#replace` calls on `html_safe` Strings.
......
......@@ -279,6 +279,8 @@ def delete(key)
super(convert_key(key))
end
alias_method :without, :except
def stringify_keys!; self end
def deep_stringify_keys!; self end
def stringify_keys; dup end
......
......@@ -672,6 +672,17 @@ def test_indifferent_slice_access_with_symbols
assert_equal "bender", slice["login"]
end
def test_indifferent_without
original = { a: "x", b: "y", c: 10 }.with_indifferent_access
expected = { c: 10 }.with_indifferent_access
[["a", "b"], [:a, :b]].each do |keys|
# Should return a new hash without the given keys.
assert_equal expected, original.without(*keys), keys.inspect
assert_not_equal expected, original
end
end
def test_indifferent_extract
original = { :a => 1, "b" => 2, :c => 3, "d" => 4 }.with_indifferent_access
expected = { a: 1, b: 2 }.with_indifferent_access
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册