Skip to content

Commit

Permalink
fix searchworks url formation
Browse files Browse the repository at this point in the history
  • Loading branch information
dnoneill committed Sep 5, 2024
1 parent 1970b00 commit 3db4a38
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/traject/macros/cocina.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def iiif_manifest_url(version: 3)
# Generate a Searchworks URL if object is released to Searchworks
def searchworks_url
lambda do |record, accumulator, _context|
accumulator << "#{settings['searchworks.url']}/view/#{record.druid}" if record.public_meta_json? && record.released_to_searchworks?
accumulator << "#{settings['searchworks.url']}/view/#{record.searchworks_id}" if record.public_meta_json? && record.released_to_searchworks?
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/files/bq589tv8583.meta_json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sitemap": false,
"searchworks": false,
"searchworks": true,
"earthworks": true
}
11 changes: 10 additions & 1 deletion spec/integration/geo_aardvark_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
end
let(:druid) { 'vv853br8653' }
let(:record) { PurlRecord.new(druid) }
let(:xml_body) { begin File.new(file_fixture("#{druid}.xml")) rescue nil end }
let(:body) { File.new(file_fixture("#{druid}.json")) }
let(:metadata_json) { File.new(file_fixture("#{druid}.meta_json")) }

before do
stub_request(:get, "https://purl.stanford.edu/#{druid}.xml").to_return(status: 404)
stub_request(:get, "https://purl.stanford.edu/#{druid}.xml").to_return(status: xml_body ? 200 : 400, body: xml_body)
stub_request(:get, "https://purl.stanford.edu/#{druid}.json").to_return(status: 200, body:)
stub_request(:get, "https://purl.stanford.edu/#{druid}.meta_json").to_return(status: 200, body: metadata_json)
end
Expand Down Expand Up @@ -534,6 +535,14 @@
expect(result['dct_spatial_sm']).to eq ['San Francisco Bay Area']
end

describe 'references' do
let(:references) { JSON.parse result['dct_references_s'] }

it 'maps the searchworks URL when released to searchworks' do
expect(references['https://schema.org/relatedLink']).to eq 'https://searchworks.stanford.edu/view/11235662'
end
end

# This record has two differently-formatted events in cocina descriptive
# adminMetadata; we want to parse both and use the more recent (modified)
it 'maps the modification date as the metadata modification date' do
Expand Down

0 comments on commit 3db4a38

Please sign in to comment.