Skip to content

Commit

Permalink
Fixes #3164 - Collection Thumbnails don't show in search results
Browse files Browse the repository at this point in the history
Updating tests for thumbnail_list_collection.#3291
  • Loading branch information
hweng committed Dec 6, 2018
1 parent 600db74 commit fa7726c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
8 changes: 7 additions & 1 deletion app/views/catalog/_thumbnail_list_collection.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div class="col-md-2">
<span class="<%= Hyrax::ModelIcon.css_class_for(Collection) %> collection-icon-search" aria-hidden="true"></span>
<% collection_presenter = Hyrax::CollectionPresenter.new(document, current_ability) %>
<% if (collection_presenter.thumbnail_path == nil) %>
<span class="<%= Hyrax::ModelIcon.css_class_for(Collection) %> collection-icon-search" aria-hidden="true"></span>
<% else %>
<%= image_tag(collection_presenter.thumbnail_path) %>
<% end %>
</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
18 changes: 14 additions & 4 deletions spec/views/catalog/_thumbnail_list_collection.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
RSpec.describe 'catalog/_thumbnail_list_collection.html.erb', type: :view do
let(:attributes) do
{ id: "xxx",
"has_model_ssim": ["Collection"],
"title_tesim": ["Collection Title"],
"description_tesim": ["Collection Description"],
"system_modified_dtsi": 'a date',
"thumbnail_path_ss": '/xxx/yyy?file=thumbnail' }
end
let(:doc) { SolrDocument.new(attributes) }
let(:current_ability) { Ability.new(build(:user)) }

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
render 'catalog/thumbnail_list_collection', document: doc, current_ability: current_ability
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>'
it 'displays the collection thumbnail in the search results' do
expect(rendered).to include '/xxx/yyy?file=thumbnail'
end
end

0 comments on commit fa7726c

Please sign in to comment.