Fix parsing a false value

Fixes #45
This commit is contained in:
Benjamin Neff 2017-01-04 04:03:42 +01:00
parent 160b2bdc34
commit 9a7fd278b5
2 changed files with 15 additions and 1 deletions

View file

@ -275,7 +275,7 @@ module DiasporaFederation
private_class_method def self.entity_data(root_node)
class_props.map {|name, type|
value = parse_element_from_node(name, type, root_node)
[name, value] if value
[name, value] unless value.nil?
}.compact.to_h
end

View file

@ -192,6 +192,20 @@ XML
expect(entity.test2).to eq("qwer")
expect(entity.test3).to eq(true)
end
it "parses boolean fields with false value" do
xml = <<-XML.strip
<test_default_entity>
<test1>qwer</test1>
<test2>qwer</test2>
<test3>false</test3>
</test_default_entity>
XML
entity = Entities::TestDefaultEntity.from_xml(Nokogiri::XML::Document.parse(xml).root)
expect(entity).to be_an_instance_of Entities::TestDefaultEntity
expect(entity.test3).to eq(false)
end
end
context "nested entities" do