From 1704d1422fe45efe56e93be33714afac94362b6b Mon Sep 17 00:00:00 2001 From: Kristina Spurgin Date: Tue, 9 Mar 2021 20:06:20 -0500 Subject: [PATCH] Fixes bug where an overflowing subgroup warning was spuriously returned --- lib/collectionspace/mapper/data_mapper.rb | 2 +- lib/collectionspace/mapper/version.rb | 2 +- spec/collectionspace/mapper/data_mapper_spec.rb | 12 ++++++++++++ .../files/datahashes/core/collectionobject3.json | 9 +++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/files/datahashes/core/collectionobject3.json diff --git a/lib/collectionspace/mapper/data_mapper.rb b/lib/collectionspace/mapper/data_mapper.rb index 5e5cd535..17b7e9e3 100644 --- a/lib/collectionspace/mapper/data_mapper.rb +++ b/lib/collectionspace/mapper/data_mapper.rb @@ -168,7 +168,7 @@ def add_too_many_subgroups_warning(parent_path:, intervening_path:, subgroup:) end def group_accommodates_subgroup?(groupdata, subgroupdata) - sg_max_length = subgroupdata.values.map(&:flatten).map(&:length).max + sg_max_length = subgroupdata.values.map(&:length).max sg_max_length <= groupdata.length ? true : false end diff --git a/lib/collectionspace/mapper/version.rb b/lib/collectionspace/mapper/version.rb index d84e8508..e8cb19ed 100644 --- a/lib/collectionspace/mapper/version.rb +++ b/lib/collectionspace/mapper/version.rb @@ -1,5 +1,5 @@ module CollectionSpace module Mapper - VERSION = "2.2.2" + VERSION = "2.2.3" end end diff --git a/spec/collectionspace/mapper/data_mapper_spec.rb b/spec/collectionspace/mapper/data_mapper_spec.rb index dd27fdfe..e1e18eb8 100644 --- a/spec/collectionspace/mapper/data_mapper_spec.rb +++ b/spec/collectionspace/mapper/data_mapper_spec.rb @@ -49,6 +49,18 @@ end end end + + context 'overflow subgroup record with even subgroup values' do + before(:all) do + @datahash = get_datahash(path: 'spec/fixtures/files/datahashes/core/collectionobject3.json') + @prepper = CollectionSpace::Mapper::DataPrepper.new(@datahash, @handler) + @mapper = CollectionSpace::Mapper::DataMapper.new(@prepper.prep, @handler, @prepper.xphash) + end + it 'mapper response does not include overflow subgroup warning' do + w = @mapper.response.warnings.any?{ |w| w[:category] == :subgroup_contains_data_for_nonexistent_groups } + expect(w).to be false + end + end end end diff --git a/spec/fixtures/files/datahashes/core/collectionobject3.json b/spec/fixtures/files/datahashes/core/collectionobject3.json new file mode 100644 index 00000000..81e05c86 --- /dev/null +++ b/spec/fixtures/files/datahashes/core/collectionobject3.json @@ -0,0 +1,9 @@ +{ + "objectnumber": "UR72", + "measuredpart": "overall", + "dimensionsummary": "35 1/2 x 28 1/16 in. (90.2 x 71.3 cm)", + "dimension": "height^^height^^width^^width", + "value": "35.51174^^90.2^^28.070809999999998^^71.3", + "measurementunit": "inches^^centimeters^^inches^^centimeters", + "valuedate": "%NULLVALUE%^^%NULLVALUE%^^%NULLVALUE%^^%NULLVALUE%" +}