Skip to content

Commit

Permalink
Merge pull request #128 from collectionspace/gh-112-null-optlist-val
Browse files Browse the repository at this point in the history
stop warning about %NULLVALUE% as unknown option list value
  • Loading branch information
kspurgin authored Sep 23, 2021
2 parents 0955c6a + a4d3fb8 commit 92bf74e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This project bumps the version number for any changes (including documentation updates and refactorings). Versions with only documentation or refactoring changes may not be released. Versions with bugfixes will be released. Changes made to unreleased versions will be indicated by version number under each release that includes those changes.

## [Unreleased] - i.e. pushed to main branch but not yet tagged as a release
- nothing

## [2.5.0] - 2021-09-23
### Added
- `multiple_recs_found` batch configuration option added to allow batch deletion of duplicate records. This defaults to `fail`, which means if there are two or more existing records sharing the same ID, the batch importer will not transfer anything for that ID. In rare cases, however, you may really need to delete duplicates, and now you can. The batch importer will transfer your update or delete to the first result found via a search for the record ID. See [the batch configuration options documentation](https://github.com/collectionspace/collectionspace-mapper/blob/main/doc/batch_configuration.adoc) for more information.

### Changed
- Do not warn about "%NULLVALUE%" as an unknown option list value

## [2.4.9] - 2021-09-03
### Changed
- Use Ruby 2.7.4 to stay in sync with collectionspace-csv-importer
Expand Down
7 changes: 5 additions & 2 deletions lib/collectionspace/mapper/data_quality_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ def validate_refname(val)
def check_opt_list_vals
@opts = @mapping.opt_list_values
if @data.first.is_a?(String)
@data.each{ |val| check_opt_list_val(val) unless val.blank? }
@data.each{ |val| check_opt_list_val(val) }
else
@data.each{ |arr| arr.each{ |val| check_opt_list_val(val) unless val.blank? } }
@data.each{ |arr| arr.each{ |val| check_opt_list_val(val) } }
end
end

def check_opt_list_val(val)
return if val.blank?
return if val == '%NULLVALUE%'
return if @opts.include?(val)

@warnings << {
category: :unknown_option_list_value,
field: @column,
Expand Down
18 changes: 7 additions & 11 deletions spec/collectionspace/mapper/data_quality_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,17 @@
'teaching-collection'
]
} }
context 'and value is not in option list' do
it 'returns warning' do
data = ['Permanent Collection']
it 'returns expected warnings' do
data = [
'Permanent Collection', # not a valid option, should return warning
'%NULLVALUE%', # indicates placeholder blank value, should be skipped
'permanent-collection', # valid option
'' # non-placeholder blank value, should be skipped
]
res = CollectionSpace::Mapper::DataQualityChecker.new(mapping, data).warnings
expect(res.size).to eq(1)
end
end
context 'and value is in option list' do
it 'does not return warning' do
data = ['permanent-collection']
res = CollectionSpace::Mapper::DataQualityChecker.new(mapping, data).warnings
expect(res).to be_empty
end
end
end

context 'when datacolumn contains `refname`' do
context 'and source_type = vocabulary' do
Expand Down

0 comments on commit 92bf74e

Please sign in to comment.