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
Trey Terrell
committed
Jun 23, 2015
1 parent
b6790e9
commit fea9009
Showing
4 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module ThumbnailHelper | ||
include Blacklight::CatalogHelper | ||
# Had to override the thumbnail URL because the document doesn't directly have | ||
# the relative URL, just the raw location of the thumbnail on disk. | ||
def thumbnail_url document | ||
document.derivative_paths[:thumbnail].relative_path.to_s | ||
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
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,6 @@ | ||
class BlacklightConfig::ThumbnailConfiguration | ||
pattr_initialize :configuration | ||
def run | ||
configuration.index.thumbnail_field = :workflow_metadata__thumbnail_path_ssim | ||
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,29 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "catalog/_thumbnail_default.html.erb" do | ||
let(:document) { SolrDocument.new(solr_hash) } | ||
let(:solr_hash) { | ||
{ | ||
:id => "1", | ||
:workflow_metadata__thumbnail_path_ssim => [OregonDigital.derivative_injector.thumbnail_path("13")] | ||
} | ||
} | ||
let(:blacklight_config) { | ||
BlacklightConfig.new(GenericAsset, CatalogController.blacklight_config).configuration | ||
} | ||
describe "thumbnails" do | ||
before do | ||
allow(view).to receive(:blacklight_config).and_return(blacklight_config) | ||
allow(view).to receive(:render_grouped_response?).and_return false | ||
allow(view).to receive(:current_search_session).and_return nil | ||
allow(view).to receive(:search_session).and_return({}) | ||
assign :response, double(start: 0) | ||
render :partial => "catalog/thumbnail_default", :locals => {:document => document, :document_counter => 1} | ||
end | ||
context "when there's a thumbnail" do | ||
it "should show it" do | ||
expect(rendered).to have_selector "img[src='/media/thumbnails/3/1/13.jpg']" | ||
end | ||
end | ||
end | ||
end |