Skip to content

Commit

Permalink
Rollback accepting an integer value in the description
Browse files Browse the repository at this point in the history
Committee can't decide which type this is.
See interagent/committee#286
Fixes sul-dlss/argo#2253
Ref sul-dlss/cocina-models#144
  • Loading branch information
jcoyne committed Sep 21, 2020
1 parent 751ca6c commit 4594442
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
4 changes: 3 additions & 1 deletion openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,9 @@ components:
description: String or integer value of the descriptive element.
oneOf:
- type: string
- type: integer
# Title note (nonsorting character count) was supposed to be able to accept an integer value,
# but this triggered a bug in comittee:
# - type: integer
type:
description: Type of value provided by the descriptive element.
type: string
Expand Down
52 changes: 51 additions & 1 deletion spec/requests/update_metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
identification: identification,
structural: structural)
end

let(:description) do
{ title: [{ value: title }] }
end

let(:data) do
<<~JSON
{
Expand All @@ -78,7 +83,7 @@
"useAndReproductionStatement":"Property rights reside with the repository..."
},
"administrative":{"releaseTags":[],"hasAdminPolicy":"druid:dd999df4567","partOfProject":"Google Books"},
"description":{"title":[{"value":"#{title}"}]},
"description":#{description.to_json},
"identification":#{identification.to_json},
"structural":{
"hasMemberOrders":[{"viewingDirection":"right-to-left"}],
Expand Down Expand Up @@ -106,6 +111,51 @@
expect(AdministrativeTags).to have_received(:create).with(pid: druid, tags: ['Project : Google Books'])
end

context 'with a structured title that has nonsorting characters' do
# This tests the problem found in https://github.com/sul-dlss/argo/issues/2253
# where an integer value in a string field was being detected as invalid data.
let(:description) do
{
title: [
{ structuredValue: [
{ value: 'The', "type": 'nonsorting characters' },
{ value: 'romantic Bach', "type": 'main title' },
{ value: "a celebration of Bach's most romantic music", "type": 'subtitle' },
{ note: [{ "value": '4', "type": 'nonsorting character count' }] }
] }
]
}
end

let(:ng_xml) do
Nokogiri::XML <<~XML
<mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.loc.gov/mods/v3" version="3.6"
xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd">
<titleInfo>
<nonSort xml:space="preserve">The</nonSort>
<title>romantic Bach</title>
<subTitle>a celebration of Bach's most romantic music</subTitle>
</titleInfo>
</mods>
XML
end

let(:item) do
Dor::Item.new(pid: druid).tap do |item|
item.descMetadata.content = ng_xml.to_xml
end
end

it 'accepts the request with a supplied nonsorting character count' do
patch "/v1/objects/#{druid}",
params: data,
headers: { 'Authorization' => "Bearer #{jwt}", 'Content-Type' => 'application/json' }
expect(response.status).to eq(200)
expect(item).to have_received(:save!)
end
end

context 'with a structured title' do
let(:expected) do
Cocina::Models::DRO.new(externalIdentifier: druid,
Expand Down

0 comments on commit 4594442

Please sign in to comment.