Skip to content

Commit

Permalink
Merge pull request #493 from UCLALibrary/URS-512_Redirect_to_Collecti…
Browse files Browse the repository at this point in the history
…on_Page

The collection item on the search results page should link to the Collection Page
  • Loading branch information
jendiamond authored Oct 31, 2019
2 parents 06916be + a108c02 commit 4a734e8
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/views/catalog/_gallery.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
<% if counter = document_counter_with_offset(document_counter) %>
<span class='document-counter'>
<%= t('blacklight.search.documents.counter', counter: counter) %>
<%= link_to_document(document, truncate(index_presenter(document).label(document_show_link_field(document)), length: 150, separator: ' ')) %>
</span>
<% if document[:has_model_ssim][0] == 'Collection' %>
<a href="/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=<%= document[:title_tesim][0] %>">
<%= document[:title_tesim][0] %>
</a>
<% else %>
<%= link_to_document(document, truncate(index_presenter(document).label(document_show_link_field(document)), length: 150, separator: ' ')) %>
<% end %>
</span>
<% end %>
</header>
</div>
Expand Down
9 changes: 8 additions & 1 deletion app/views/catalog/_index_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
<%= t('blacklight.search.documents.counter', counter: counter) %>
</span>
<% end %>
<%= link_to_document document, counter: counter %>
<% if document[:has_model_ssim][0] == 'Collection' %>
<a href="/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=<%= document[:title_tesim][0] %>">
<%= document[:title_tesim][0] %>
</a>
<% else %>
<%= link_to_document document, counter: counter %>
<% end %>
</h3>
<%= document_actions %>
Expand Down
119 changes: 119 additions & 0 deletions spec/support/collection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# frozen_string_literal: true

TEST1_WORK = {
id: 'test1123',
ark_ssi: ['ark:/24920492/029402'],
has_model_ssim: ['Work'],
title_tesim: ['The Title of my Work'],
sort_title_ssort: 'The Title of my Work',
description_tesim: ['Description 1', 'Description 2'],
subject_tesim: ['Subj 1', 'Subj 2'],
human_readable_resource_type_tesim: ['still image'],
human_readable_rights_statement_tesim: ['copyrighted'],
genre_tesim: ['Genre 1', 'Genre 2', 'Genre 3'],
named_subject_tesim: ["Named Subject 1", "Named Subject 2", "Named Subject 3", "Named Subject 4"],
repository_tesim: ['University of California, Los Angeles. Library. Department of Special Collections'],
location_tesim: ['Los Angeles'],
publisher_tesim: ['Los Angeles Daily News'],
rights_country_tesim: ['US'],
rights_holder_tesim: ['Charles E. Young'],
normalized_date_sim: ['1934-56-78'], # unique value so we can test it doesn't display
local_identifier_ssm: ['local id 123'],
date_created_tesim: ["September 17, 1947"],
medium_tesim: ['1 photograph'],
extent_tesim: ['1 photograph'],
dimensions_tesim: ['10 x 12.5 cm.'],
funding_note_tesim: ['Info about funding'],
caption_tesim: ['the caption'],
human_readable_language_tesim: ['No linguistic content'],
photographer_tesim: ['Poalillo, Charles'],
member_of_collections_ssim: ['Bennett'],
member_of_collection_ids_ssim: ['coll456'],
license_tesim: ['https://creativecommons.org/licenses/by/4.0/'],
services_contact_ssm: ['UCLA Special Collections Services Contact'],
longitude_tesim: ['-118.4398'],
latitude_tesim: ['34.0700'],
alternative_title_tesim: ['Alernative Title of my Work'],
uniform_title_tesim: ['Uniform Title of my Work'],
architect_tesim: ['Alexander Butterfly'],
# year_isim: ['1974'],
place_of_origin_tesim: ['Dudley, MA'],
oclc_tesim_ssi: ['Powell Library'],
format_tesim: ['Film Still'],
support_tesim: ['Mom & Dad'],
read_access_group_ssim: ["public"],
thumbnail_url_ss: ["http://thumbnail/work_1.jpg"],
visibility_ssi: ['open']
}.freeze

TEST2_WORK = {
id: 'test2id123',
has_model_ssim: ['Work'],
title_tesim: ['Title One'],
sort_title_ssort: 'Title One',
identifier_tesim: ['ark 123'],
description_tesim: ['Description 1', 'Description 2'],
date_created_tesim: ["Date 1"],
sort_year_isi: 1923,
human_readable_resource_type_tesim: ['still image'],
subject_tesim: ['Testing', 'RSpec'],
photographer_tesim: ['Person 1', 'Person 2'],
place_of_origin_tesim: ['Boston, MA', 'Philadelphia, PA', 'New York, NY', 'Los Angeles, CA'],
location_tesim: ['search_results_spec'], # to control what displays,
member_of_collections_ssim: ['Bennett'],
member_of_collection_ids_ssim: ['coll456'],
read_access_group_ssim: ["public"],
thumbnail_url_ss: ["http://thumbnail/work_2.jpg"],
visibility_ssi: ['open']
}.freeze

TEST3_WORK = {
id: 'test3id456',
has_model_ssim: ['Work'],
title_tesim: ['Title Two'],
sort_title_ssort: 'Title Two',
identifier_tesim: ['ark 456'],
description_tesim: ['bennett', 'Description 4'],
date_created_tesim: ["Date 1"],
sort_year_isi: 1945,
human_readable_resource_type_tesim: ['still image'],
subject_tesim: ['Testing', 'Minitest'],
photographer_tesim: ['Person 1'],
location_tesim: ['search_results_spec'], # to control what displays
collection_tesim: ['Slide Film', 'Analog', 'Photographs'],
member_of_collections_ssim: ['Bennett'],
member_of_collection_ids_ssim: ['coll456'],
read_access_group_ssim: ["public"],
thumbnail_url_ss: ["http://thumbnail/work_3.jpg"],
visibility_ssi: ['open']
}.freeze

BENNETT_COLLECTION = {
id: 'coll456',
title_tesim: ['Bennett'],
services_contact_ssm: ['someone somewhere'],
description_tesim: ['bennett', 'Description 4', 'another desc'],
date_created_tesim: ["Date 1"],
repository_tesim: ['UCLA Collection'],
languages_tesim: ['en', 'es', 'gk'],
human_readable_language_tesim: ['English', 'Spanish', 'Greek']
}.freeze

TEST4_WORK = {
id: 'test4id456',
has_model_ssim: ['Work'],
title_tesim: ['Title Three'],
sort_title_ssort: 'Title Three',
identifier_tesim: ['ark 456'],
description_tesim: ['bennett', 'Description 4', 'another desc'],
date_created_tesim: ["Date 1"],
sort_year_isi: 1929,
human_readable_resource_type_tesim: ['still image'],
photographer_tesim: ['Person 1'],
location_tesim: ['search_results_spec'], # to control what displays
collection_tesim: ['Photographs', 'Digital'],
thumbnail_url_ss: ["http://thumbnail/work_4.jpg"],
member_of_collections_ssim: ['Bennett'],
member_of_collection_ids_ssim: ['coll456'],
visibility_ssi: ['open']
}.freeze
25 changes: 25 additions & 0 deletions spec/system/search_results_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
solr.add(work_1_attributes)
solr.add(work_2_attributes)
solr.add(work_3_attributes)
solr.add(collection_1_attributes)
solr.add(work_4_attributes)
solr.add(work_5_attributes)
solr.commit
allow(Rails.application.config).to receive(:iiif_url).and_return('https://example.com')
end
Expand All @@ -18,6 +21,12 @@

let(:work_3_attributes) { FOURTH_WORK }

let(:collection_1_attributes) { BENNETT_COLLECTION }

let(:work_4_attributes) { TEST4_WORK }

let(:work_5_attributes) { TEST3_WORK }

scenario do
visit '/catalog?f%5Blocation_tesim%5D%5B%5D=search_results_spec'
# it 'displays: title, description, date_created, resource_type, and photographer' do
Expand Down Expand Up @@ -70,6 +79,14 @@
expect(page).to have_content 'Title One'
end

it 'displays Gallery View results with a collection item' do
visit '/catalog?q=bennett&search_field=all_fields'
click_on 'Gallery'
expect(page).to have_selector('.view-type-gallery.active')
expect(page).to have_content 'Bennett'
page.find_link('Bennett').click
expect(page).to have_current_path(/f%5Bmember_of_collections_ssim%5D%5B%5D=Bennett/)
end
it 'displays List View results' do
visit '/catalog?f%5Blocation_tesim%5D%5B%5D=search_results_spec&view=list'
click_on 'List'
Expand All @@ -80,6 +97,14 @@
expect(page).to have_content 'Date Created: 1923'
end

it 'displays List View results with a collection item' do
visit '/catalog?q=bennett&search_field=all_fields'
click_on 'List'
expect(page).to have_selector('.view-type-list.active')
expect(page).to have_content 'Bennett'
expect(page).to have_link(href: '/catalog?f%5Bmember_of_collections_ssim%5D%5B%5D=Bennett')
end

it 'visiting the home page and getting the correct search field options' do
visit '/' do
expect(page.html).to match(/<option value="all_fields">All Fields<\/option>/)
Expand Down

0 comments on commit 4a734e8

Please sign in to comment.