Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of #3164 - Collection Thumbnails don't show in search results #3658

Merged
merged 1 commit into from
Mar 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/views/catalog/_thumbnail_list_collection.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div class="col-md-2">
<span class="<%= Hyrax::ModelIcon.css_class_for(Collection) %> collection-icon-search" aria-hidden="true"></span>
</div>
<%= render_thumbnail_tag document, {}, suppress_link: true %>
</div>

2 changes: 1 addition & 1 deletion spec/features/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
expect(page).to have_content('Search Results')
expect(page).to have_content "Toothbrush"
expect(page).to have_content('collection title abc')
expect(page).to have_css("span.collection-icon-search")
expect(page).to have_selector("//img")

expect(page.body).to include "<span itemprop=\"keywords\"><a href=\"/catalog?f%5Bkeyword_sim%5D%5B%5D=taco&amp;locale=en\">taco</a></span>"
expect(page.body).to include "<span itemprop=\"keywords\"><a href=\"/catalog?f%5Bkeyword_sim%5D%5B%5D=mustache&amp;locale=en\">mustache</a></span>"
Expand Down
43 changes: 38 additions & 5 deletions spec/views/catalog/_thumbnail_list_collection.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
RSpec.describe 'catalog/_thumbnail_list_collection.html.erb', type: :view do
before do
stub_template 'catalog/_thumbnail_list_collection.html.erb' => '<div class="col-sm-3"><span class="fa fa-cubes collection-icon-search"></span></div>'
render
context "When the collection thumbnail is attached" do
let(:attributes) do
{ id: "xxx",
"has_model_ssim": ["Collection"],
"title_tesim": ["Collection Title"],
"description_tesim": ["Collection Description"],
"system_modified_dtsi": 'date',
"thumbnail_path_ss": '/xxx/yyy?file=thumbnail' }
end
let(:doc) { SolrDocument.new(attributes) }
let(:current_ability) { Ability.new(build(:user)) }

before do
render 'catalog/thumbnail_list_collection', document: doc
end

it 'displays the collection thumbnail in the search results' do
expect(rendered).to include '/xxx/yyy?file=thumbnail'
end
end

it 'displays the collection icon in the search results' do
expect(rendered).to match '<div class="col-sm-3"><span class="fa fa-cubes collection-icon-search"></span></div>'
context "When the collection thumbnail is not attached" do
let(:attributes) do
{ id: "xxx",
"has_model_ssim": ["Collection"],
"title_tesim": ["Collection Title"],
"description_tesim": ["Collection Description"],
"system_modified_dtsi": 'date',
"thumbnail_path_ss" => Hyrax::CollectionIndexer.thumbnail_path_service.default_image }
end
let(:doc) { SolrDocument.new(attributes) }
let(:current_ability) { Ability.new(build(:user)) }

before do
render 'catalog/thumbnail_list_collection', document: doc
end

it 'displays the collection icon in the search results' do
expect(rendered).to include '/assets/collection-'
end
end
end