Skip to content

Commit

Permalink
Merge pull request #320 from pulibrary/dont_error_displaying_thumbnails
Browse files Browse the repository at this point in the history
Displaying thumbnail shouldn't fail on error.
  • Loading branch information
hackartisan committed Oct 4, 2017
2 parents 266d24e + a7948fe commit a2d05f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/helpers/osd_modal_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def iiif_thumbnail_path(document, image_options = {})
return if id.blank?
thumbnail_document = Valkyrie.config.metadata_adapter.query_service.find_by(id: id)
iiif_thumbnail_path(thumbnail_document, image_options)
rescue Valkyrie::Persistence::ObjectNotFoundError
Valkyrie.logger.warn "Unable to load thumbnail for #{document}"
nil
end

def build_thumbnail_path(id, image_options = {})
Expand Down
6 changes: 6 additions & 0 deletions spec/helpers/osd_modal_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@

expect(helper.figgy_thumbnail_path(parent_book)).to include file_set.id.to_s
end
it "returns nothing when the fileset doesn't exist" do
book = FactoryGirl.create_for_repository(:scanned_resource, thumbnail_id: Valkyrie::ID.new("busted"))
parent_book = FactoryGirl.create_for_repository(:scanned_resource, thumbnail_id: book.id)

expect(helper.figgy_thumbnail_path(parent_book)).to eq nil
end
end
end
end

0 comments on commit a2d05f6

Please sign in to comment.