|
65 | 65 | identification: identification,
|
66 | 66 | structural: structural)
|
67 | 67 | end
|
| 68 | + |
| 69 | + let(:description) do |
| 70 | + { title: [{ value: title }] } |
| 71 | + end |
| 72 | + |
68 | 73 | let(:data) do
|
69 | 74 | <<~JSON
|
70 | 75 | {
|
|
78 | 83 | "useAndReproductionStatement":"Property rights reside with the repository..."
|
79 | 84 | },
|
80 | 85 | "administrative":{"releaseTags":[],"hasAdminPolicy":"druid:dd999df4567","partOfProject":"Google Books"},
|
81 |
| - "description":{"title":[{"value":"#{title}"}]}, |
| 86 | + "description":#{description.to_json}, |
82 | 87 | "identification":#{identification.to_json},
|
83 | 88 | "structural":{
|
84 | 89 | "hasMemberOrders":[{"viewingDirection":"right-to-left"}],
|
|
106 | 111 | expect(AdministrativeTags).to have_received(:create).with(pid: druid, tags: ['Project : Google Books'])
|
107 | 112 | end
|
108 | 113 |
|
| 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 | + |
109 | 159 | context 'with a structured title' do
|
110 | 160 | let(:expected) do
|
111 | 161 | Cocina::Models::DRO.new(externalIdentifier: druid,
|
|
0 commit comments