mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed Hash#from_xml with keys that are all caps.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
This commit is contained in:
parent
8b6d2ef2f5
commit
eb201e64c0
2 changed files with 17 additions and 1 deletions
|
@ -217,7 +217,7 @@ class Hash
|
|||
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"
|
||||
|
|
|
@ -646,6 +646,22 @@ class HashToXmlTest < Test::Unit::TestCase
|
|||
assert_equal expected_topic_hash, Hash.from_xml(topic_xml)["rsp"]["photos"]["photo"]
|
||||
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_from_xml
|
||||
blog_xml = <<-XML
|
||||
<blog>
|
||||
|
|
Loading…
Reference in a new issue