Skip to content

Commit

Permalink
Merge pull request #1073 from sul-dlss/rollback-integer
Browse files Browse the repository at this point in the history
Rollback accepting an integer value in the description
mjgiarlo authored Sep 21, 2020
2 parents 751ca6c + d6cc50e commit c3878be
Showing 2 changed files with 55 additions and 2 deletions.
5 changes: 4 additions & 1 deletion openapi.yml
Original file line number Diff line number Diff line change
@@ -1381,7 +1381,10 @@ 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 committee:
# https://github.com/interagent/committee/issues/286
# - type: integer
type:
description: Type of value provided by the descriptive element.
type: string
52 changes: 51 additions & 1 deletion spec/requests/update_metadata_spec.rb
Original file line number Diff line number Diff line change
@@ -65,6 +65,11 @@
identification: identification,
structural: structural)
end

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

let(:data) do
<<~JSON
{
@@ -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"}],
@@ -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,

0 comments on commit c3878be

Please sign in to comment.