Allow empty `VisualizationInfo` XML nodes in .bcfv files

pull/8253/head
Wieland Lindenthal 5 years ago
parent ae4b276b21
commit 228996b3d7
  1. 3
      modules/bim/lib/open_project/bim/bcf_json/viewpoint_reader.rb
  2. 3
      modules/bim/spec/fixtures/viewpoints/empty.bcfv.json
  3. 2
      modules/bim/spec/fixtures/viewpoints/empty.bcfv.xml
  4. 8
      modules/bim/spec/lib/open_project/bcf/bcf_json/viewpoint_reader_spec.rb

@ -28,7 +28,7 @@ module OpenProject::Bim
@viewpoint_hash ||= begin
# Load from XML using activesupport
hash = Hash.from_xml(xml)
hash = hash[ROOT_NODE] if hash.key?(ROOT_NODE)
hash = hash[ROOT_NODE] if hash[ROOT_NODE]
# Perform destructive transformations
transformations.each do |method_name|
@ -58,6 +58,7 @@ module OpenProject::Bim
def remove_keys(hash)
hash.delete 'xmlns:xsi'
hash.delete 'xmlns:xsd'
hash.delete 'VisualizationInfo' unless hash['VisualizationInfo']
end
def set_uuid(hash)

@ -0,0 +1,3 @@
{
"guid": "{{UUID}}"
}

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<VisualizationInfo />

@ -33,6 +33,14 @@ describe OpenProject::Bim::BcfJson::ViewpointReader do
let(:instance) { described_class.new xml_viewpoint.uuid, xml_viewpoint.viewpoint }
subject { instance.result }
describe 'with empty example' do
let_it_be(:xml_viewpoint) do
FactoryBot.build_stubbed :xml_viewpoint, viewpoint_name: 'empty.bcfv'
end
it_behaves_like 'matches the JSON counterpart'
end
describe 'with minimal example' do
let_it_be(:xml_viewpoint) do
FactoryBot.build_stubbed :xml_viewpoint, viewpoint_name: 'minimal.bcfv'

Loading…
Cancel
Save