This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
identity_metadata_indexer_spec.rb
105 lines (94 loc) · 3.12 KB
/
identity_metadata_indexer_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe IdentityMetadataIndexer do
let(:obj) { Dor::Item.new(pid: 'druid:rt923jk3421') }
let(:cocina) do
Cocina::Models.build({
externalIdentifier: 'druid:rt923jk3421',
type: type,
version: 1,
label: 'Squirrels of North America',
access: {
access: 'world'
},
administrative: {
hasAdminPolicy: 'druid:bd999bd9999'
},
identification: identification
}.with_indifferent_access)
end
let(:indexer) do
described_class.new(resource: obj, cocina: cocina)
end
describe '#to_solr' do
subject(:doc) { indexer.to_solr }
context 'with an item' do
let(:type) { Cocina::Models::Vocab.book }
let(:identification) do
{
sourceId: 'google:STANFORD_342837261527',
catalogLinks: [
{
catalog: 'symphony',
catalogRecordId: '129483625'
}
],
barcode: '36105049267078'
}
end
it 'has the fields used by argo' do
expect(doc).to include(
'barcode_id_ssim' => ['36105049267078'],
'catkey_id_ssim' => ['129483625'],
'dor_id_tesim' => %w[STANFORD_342837261527 36105049267078 129483625],
'identifier_ssim' => ['google:STANFORD_342837261527', 'barcode:36105049267078',
'catkey:129483625'],
'identifier_tesim' => ['google:STANFORD_342837261527', 'barcode:36105049267078',
'catkey:129483625'],
'objectType_ssim' => ['item'],
'source_id_ssim' => ['google:STANFORD_342837261527']
)
end
end
context 'with an agreement' do
let(:type) { Cocina::Models::Vocab.agreement }
let(:identification) { {} }
it 'has the fields used by argo' do
expect(doc).to include(
'barcode_id_ssim' => [],
'catkey_id_ssim' => [],
'dor_id_tesim' => [],
'identifier_ssim' => [],
'identifier_tesim' => [],
'objectType_ssim' => ['agreement'],
'source_id_ssim' => []
)
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