-
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.
- Loading branch information
Showing
4 changed files
with
114 additions
and
10 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,22 @@ | ||
require 'rails_helper' | ||
|
||
describe IIIFIngestJob do | ||
let(:url1) { 'http://example.com/1/manifest' } | ||
let(:url2) { 'http://example.com/2/manifest' } | ||
let(:resource) { IIIFResource.new } | ||
|
||
it 'ingests a single url' do | ||
allow_any_instance_of(IIIFResource).to receive(:save) | ||
expect(IIIFResource).to receive(:new).with(manifest_url: url1).and_return(resource) | ||
|
||
described_class.new.perform(url1) | ||
end | ||
|
||
it 'ingests each of an array of urls' do | ||
allow_any_instance_of(IIIFResource).to receive(:save) | ||
expect(IIIFResource).to receive(:new).with(manifest_url: url1).and_return(resource) | ||
expect(IIIFResource).to receive(:new).with(manifest_url: url2).and_return(resource) | ||
|
||
described_class.new.perform([url1, url2]) | ||
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,61 @@ | ||
require 'rails_helper' | ||
|
||
describe IIIFResource do | ||
let(:url) { 'http://example.com/1/manifest' } | ||
let(:json) { '{ | ||
"@context":"http://iiif.io/api/presentation/2/context.json", | ||
"@id":"http://example.com/1/manifest", | ||
"@type":"sc:Manifest", | ||
"label":"Sample Manifest", | ||
"thumbnail":{ | ||
"@id":"http://example.com/loris/1.jp2/full/100,/0/default.jpg", | ||
"service":{ | ||
"@context":"http://iiif.io/api/image/2/context.json", | ||
"@id":"https://example.com/loris/1.jp2", | ||
"profile":"http://iiif.io/api/image/2/level2.json" }}, | ||
"metadata":[ | ||
{ "label": "Creator", "value": [{ "@value": "Author, Alice, 1954-" }] }, | ||
{ "label": "Date created", "value": [{ "@value": "1985" }] } | ||
]}' | ||
} | ||
|
||
before do | ||
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(json) | ||
end | ||
|
||
describe '#initialize' do | ||
it 'loads metadata from the IIIF manifest' do | ||
resource = described_class.new(manifest_url: url) | ||
expect(resource.url).to eq(url) | ||
expect(resource.data['thumbnail']).to eq('http://example.com/loris/1.jp2/full/100,/0/default.jpg') | ||
expect(resource.data['creator']).to eq(['Author, Alice, 1954-']) | ||
end | ||
end | ||
|
||
describe '#parse_manifest' do | ||
it 'retrieves and parses an IIIF manifest' do | ||
expect_any_instance_of(Faraday::Connection).to receive(:get).with(url) | ||
manifest = described_class.parse_manifest(url) | ||
expect(manifest['@id']).to eq(url) | ||
expect(manifest['label']).to eq('Sample Manifest') | ||
expect(manifest['thumbnail']['@id']).to eq('http://example.com/loris/1.jp2/full/100,/0/default.jpg') | ||
end | ||
end | ||
|
||
describe '#to_solr' do | ||
subject { described_class.new(manifest_url: url) } | ||
before do | ||
exhibit = Spotlight::Exhibit.new | ||
allow(exhibit).to receive(:blacklight_config).and_return(Blacklight::Configuration.new) | ||
subject.exhibit = exhibit | ||
end | ||
|
||
it 'indexes iiif metadata' do | ||
solr_doc = subject.to_solr | ||
expect(solr_doc[:spotlight_title_ssim]).to eq('Sample Manifest') | ||
expect(solr_doc[:thumbnail_ssim]).to eq('http://example.com/loris/1.jp2/full/100,/0/default.jpg') | ||
expect(solr_doc[:creator_ssim]).to eq(['Author, Alice, 1954-']) | ||
expect(solr_doc[:date_created_ssim]).to eq(['1985']) | ||
end | ||
end | ||
end |