Skip to content

Commit

Permalink
Remove stray underscore from the hash conversion methods which broke …
Browse files Browse the repository at this point in the history
…backwards compatibility with Hash.from_xml

Also add an all-caps test to prevent future regressions
  • Loading branch information
codebrulee authored and NZKoz committed May 4, 2009
1 parent 17e712d commit ebe8dd6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -221,7 +221,7 @@ def unrename_keys(params)
case params.class.to_s
when "Hash"
params.inject({}) do |h,(k,v)|
h[k.to_s.underscore.tr("-", "_")] = unrename_keys(v)
h[k.to_s.tr("-", "_")] = unrename_keys(v)
h
end
when "Array"
Expand Down
16 changes: 16 additions & 0 deletions activesupport/test/core_ext/hash_ext_test.rb
Expand Up @@ -654,6 +654,22 @@ def test_empty_array_from_xml
assert_equal expected_blog_hash, Hash.from_xml(blog_xml)
end

def test_all_caps_key_from_xml
test_xml = <<-EOT
<ABC3XYZ>
<TEST>Lorem Ipsum</TEST>
</ABC3XYZ>
EOT

expected_hash = {
"ABC3XYZ" => {
"TEST" => "Lorem Ipsum"
}
}

assert_equal expected_hash, Hash.from_xml(test_xml)
end

def test_empty_array_with_whitespace_from_xml
blog_xml = <<-XML
<blog>
Expand Down

0 comments on commit ebe8dd6

Please sign in to comment.