Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollback accepting an integer value in the description #1073

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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