Skip to content

Commit

Permalink
Merge pull request #101 from collectionspace/fix-overflow-subgroup-wa…
Browse files Browse the repository at this point in the history
…rning

Fixes bug where an overflowing subgroup warning was spuriously returned
  • Loading branch information
kspurgin authored Mar 10, 2021
2 parents 94229e5 + 1704d14 commit 0df8b85
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/collectionspace/mapper/data_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/collectionspace/mapper/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module CollectionSpace
module Mapper
VERSION = "2.2.2"
VERSION = "2.2.3"
end
end
12 changes: 12 additions & 0 deletions spec/collectionspace/mapper/data_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions spec/fixtures/files/datahashes/core/collectionobject3.json
Original file line number Diff line number Diff line change
@@ -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%"
}

0 comments on commit 0df8b85

Please sign in to comment.