Skip to content

Commit

Permalink
Add test for upload to_solr method
Browse files Browse the repository at this point in the history
  • Loading branch information
taylor-steve committed Jul 16, 2024
1 parent 9387c28 commit 39df40f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/models/spotlight/resources/upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@
end
end

describe '#to_solr' do
subject(:solr_document) { upload.to_solr }

let(:featured_image) { instance_double(Spotlight::FeaturedImage, id: 1, file_present?: true) }

before do
allow(upload).to receive(:upload).and_return(featured_image)
allow(Spotlight::RiiifService).to receive(:thumbnail_url).with(featured_image).and_return('/a/thumbnail/url')
allow(Spotlight::RiiifService).to receive(:manifest_url).with(exhibit, upload).and_return('/a/manifest/url')
end

it 'returns a hash using the iiif service' do
expect(solr_document).to have_key(:iiif_manifest_url_ssi)
expect(solr_document).to have_key(:thumbnail_url_ssm)
expect(Spotlight::RiiifService).to have_received(:manifest_url).with(exhibit, upload)
end
end

context 'when creating' do
before do
allow(upload).to receive(:write?).and_return(false)
Expand Down

0 comments on commit 39df40f

Please sign in to comment.