Skip to content

Commit 4594442

Browse files
committed
Rollback accepting an integer value in the description
Committee can't decide which type this is. See interagent/committee#286 Fixes sul-dlss/argo#2253 Ref sul-dlss/cocina-models#144
1 parent 751ca6c commit 4594442

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

openapi.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,9 @@ components:
13811381
description: String or integer value of the descriptive element.
13821382
oneOf:
13831383
- type: string
1384-
- type: integer
1384+
# Title note (nonsorting character count) was supposed to be able to accept an integer value,
1385+
# but this triggered a bug in comittee:
1386+
# - type: integer
13851387
type:
13861388
description: Type of value provided by the descriptive element.
13871389
type: string

spec/requests/update_metadata_spec.rb

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
identification: identification,
6666
structural: structural)
6767
end
68+
69+
let(:description) do
70+
{ title: [{ value: title }] }
71+
end
72+
6873
let(:data) do
6974
<<~JSON
7075
{
@@ -78,7 +83,7 @@
7883
"useAndReproductionStatement":"Property rights reside with the repository..."
7984
},
8085
"administrative":{"releaseTags":[],"hasAdminPolicy":"druid:dd999df4567","partOfProject":"Google Books"},
81-
"description":{"title":[{"value":"#{title}"}]},
86+
"description":#{description.to_json},
8287
"identification":#{identification.to_json},
8388
"structural":{
8489
"hasMemberOrders":[{"viewingDirection":"right-to-left"}],
@@ -106,6 +111,51 @@
106111
expect(AdministrativeTags).to have_received(:create).with(pid: druid, tags: ['Project : Google Books'])
107112
end
108113

114+
context 'with a structured title that has nonsorting characters' do
115+
# This tests the problem found in https://github.com/sul-dlss/argo/issues/2253
116+
# where an integer value in a string field was being detected as invalid data.
117+
let(:description) do
118+
{
119+
title: [
120+
{ structuredValue: [
121+
{ value: 'The', "type": 'nonsorting characters' },
122+
{ value: 'romantic Bach', "type": 'main title' },
123+
{ value: "a celebration of Bach's most romantic music", "type": 'subtitle' },
124+
{ note: [{ "value": '4', "type": 'nonsorting character count' }] }
125+
] }
126+
]
127+
}
128+
end
129+
130+
let(:ng_xml) do
131+
Nokogiri::XML <<~XML
132+
<mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
133+
xmlns="http://www.loc.gov/mods/v3" version="3.6"
134+
xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd">
135+
<titleInfo>
136+
<nonSort xml:space="preserve">The</nonSort>
137+
<title>romantic Bach</title>
138+
<subTitle>a celebration of Bach's most romantic music</subTitle>
139+
</titleInfo>
140+
</mods>
141+
XML
142+
end
143+
144+
let(:item) do
145+
Dor::Item.new(pid: druid).tap do |item|
146+
item.descMetadata.content = ng_xml.to_xml
147+
end
148+
end
149+
150+
it 'accepts the request with a supplied nonsorting character count' do
151+
patch "/v1/objects/#{druid}",
152+
params: data,
153+
headers: { 'Authorization' => "Bearer #{jwt}", 'Content-Type' => 'application/json' }
154+
expect(response.status).to eq(200)
155+
expect(item).to have_received(:save!)
156+
end
157+
end
158+
109159
context 'with a structured title' do
110160
let(:expected) do
111161
Cocina::Models::DRO.new(externalIdentifier: druid,

0 commit comments

Comments
 (0)