Skip to content

Commit

Permalink
Merge 2a32906 into 9f48931
Browse files Browse the repository at this point in the history
  • Loading branch information
henningwold committed Sep 13, 2017
2 parents 9f48931 + 2a32906 commit 1868a9f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/savon/qualified_message.rb
Expand Up @@ -9,7 +9,7 @@ def initialize(types, used_namespaces, key_converter)
end

def to_hash(hash, path)
return unless hash
return hash unless hash
return hash.map { |value| to_hash(value, path) } if hash.is_a?(Array)
return hash.to_s unless hash.is_a?(Hash)

Expand Down
33 changes: 33 additions & 0 deletions spec/savon/qualified_message_spec.rb
Expand Up @@ -62,6 +62,39 @@ module Savon
expect(resulting_hash).to eq good_result
expect(xml).to eq good_xml
end

it "properly handles boolean false" do
used_namespaces = {
%w(tns Foo) => 'ns'
}

hash = {
:foo => {
:falsey => {
:@attr1 => false,
:content! => false
}
}
}

good_result = {
"ns:Foo" => {
:falsey => {
:@attr1 => false,
:content! => false
}
}
}

good_xml = %(<ns:Foo><Falsey attr1="false">false</Falsey></ns:Foo>)

message = described_class.new(types, used_namespaces, key_converter)
resulting_hash = message.to_hash(hash, ['tns'])
xml = Gyoku.xml(resulting_hash, key_converter: key_converter)

expect(resulting_hash).to eq good_result
expect(xml).to eq good_xml
end
end

end
Expand Down

0 comments on commit 1868a9f

Please sign in to comment.