diff --git a/Gemfile.lock b/Gemfile.lock index aea2a72e..bf78b58b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -252,7 +252,8 @@ GEM mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2021.0225) - mimemagic (0.3.6) + mimemagic (0.3.8) + nokogiri (~> 1) mini_mime (1.0.2) mini_portile2 (2.5.0) minitest (5.14.4) diff --git a/app/indexers/identity_metadata_indexer.rb b/app/indexers/identity_metadata_indexer.rb index 1c8a2166..d34df418 100644 --- a/app/indexers/identity_metadata_indexer.rb +++ b/app/indexers/identity_metadata_indexer.rb @@ -33,7 +33,7 @@ def source_id_value end def barcode - @barcode ||= cocina_object.identification.barcode + @barcode ||= object_type != 'collection' ? cocina_object.identification.barcode : nil end def catkey diff --git a/spec/indexers/identity_metadata_indexer_spec.rb b/spec/indexers/identity_metadata_indexer_spec.rb index caffb5a2..7121ce36 100644 --- a/spec/indexers/identity_metadata_indexer_spec.rb +++ b/spec/indexers/identity_metadata_indexer_spec.rb @@ -74,5 +74,32 @@ ) end end + + context 'with a collection' do + let(:type) { Cocina::Models::Vocab.collection } + let(:identification) do + { + sourceId: 'google:STANFORD_342837261527', + catalogLinks: [ + { + catalog: 'symphony', + catalogRecordId: '129483625' + } + ] + } + end + + it 'has the fields used by argo' do + expect(doc).to include( + 'barcode_id_ssim' => [], + 'catkey_id_ssim' => ['129483625'], + 'dor_id_tesim' => %w[STANFORD_342837261527 129483625], + 'identifier_ssim' => ['google:STANFORD_342837261527', 'catkey:129483625'], + 'identifier_tesim' => ['google:STANFORD_342837261527', 'catkey:129483625'], + 'objectType_ssim' => ['collection'], + 'source_id_ssim' => ['google:STANFORD_342837261527'] + ) + end + end end end