-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sort fields for title, date, and author; refs #307
- Loading branch information
1 parent
c8ba3b6
commit 129d9b2
Showing
5 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# pulled and pared down from spotlight | ||
# https://github.com/projectblacklight/spotlight/blob/b4608610ed0405f1d8ed4d6c9c17a02b06b9bcf6/spec/fixtures/iiif_responses.rb | ||
module IiifResponses | ||
def test_manifest1 | ||
{ | ||
"@id": 'uri://for-manifest1/manifest', | ||
"@type": 'sc:Manifest', | ||
"label": 'Test Manifest 1', | ||
"attribution": 'Attribution Data', | ||
"description": 'A test IIIF manifest', | ||
"license": 'http://www.example.org/license.html', | ||
"metadata": [ | ||
{ | ||
"label": 'Author', | ||
"value": 'John Doe' | ||
}, | ||
{ | ||
"label": 'Author', | ||
"value": 'Jane Doe' | ||
}, | ||
{ | ||
"label": 'Another Field', | ||
"value": 'Some data' | ||
}, | ||
{ | ||
"label": 'Date', | ||
"value": '1929' | ||
} | ||
], | ||
"thumbnail": { | ||
"@id": 'uri://to-thumbnail' | ||
}, | ||
"sequences": [ | ||
{ | ||
"@type": 'sc:Sequence', | ||
"canvases": [ | ||
{ | ||
"@type": 'sc:Canvas', | ||
"images": [ | ||
{ | ||
"@type": 'oa:Annotation', | ||
"resource": { | ||
"@type": 'dcterms:Image', | ||
"@id": 'uri://full-image', | ||
"service": { | ||
"@id": 'uri://to-image-service' | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}.to_json | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe IiifManifest do | ||
subject { described_class.new(url: url, manifest: manifest, collection: collection) } | ||
let(:url) { 'uri://some_id/manifest' } | ||
let(:collection) { double(compound_id: '1') } | ||
let(:manifest_fixture) { test_manifest1 } | ||
before do | ||
stub_iiif_response_for_url(url, manifest_fixture) | ||
subject.with_exhibit(exhibit) | ||
end | ||
|
||
describe '#to_solr' do | ||
let(:manifest) { IiifService.new(url).send(:object) } | ||
let(:exhibit) { FactoryBot.create(:exhibit) } | ||
describe 'sort_title' do | ||
it 'is a single-value text field' do | ||
expect(subject.to_solr["sort_title_ssi"]).to eq "Test Manifest 1" | ||
end | ||
end | ||
|
||
describe 'sort_date' do | ||
it 'is a single-value text field' do | ||
expect(subject.to_solr["sort_date_ssi"]).to eq "1929" | ||
end | ||
end | ||
|
||
describe 'sort_author' do | ||
it 'is a single-value text field' do | ||
expect(subject.to_solr["sort_author_ssi"]).to eq "John Doe" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# pulled and pared down from spotlight | ||
# https://github.com/projectblacklight/spotlight/blob/b4608610ed0405f1d8ed4d6c9c17a02b06b9bcf6/spec/support/stub_iiif_response.rb | ||
require 'fixtures/iiif_responses' | ||
module StubIiifResponse | ||
def stub_iiif_response_for_url(url, response) | ||
allow(IiifService).to receive(:iiif_response).with(url).and_return(response) | ||
end | ||
|
||
def stub_default_collection | ||
allow_any_instance_of(Spotlight::Resources::IiifHarvester).to receive_messages(url_is_iiif?: true) | ||
|
||
stub_iiif_response_for_url('uri://for-manifest1/manifest', test_manifest1) | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.include IiifResponses | ||
config.include StubIiifResponse | ||
end |