Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
Fixes #464 - Add support of facet_default_uri for search result page …
Browse files Browse the repository at this point in the history
…when using View Collection Items.

Fixed the failed tests.

Update tests.
  • Loading branch information
hweng committed Jul 26, 2018
1 parent 3fb10b2 commit c6eb470
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/helpers/catalog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def facet_uri(field, field_string)
return add_facet_params(field_string, field).merge!({"controller" => "catalog", :action=> "index"})
end

def facet_default_uri(field, field_string)
return add_facet_params(field_string, field).merge!({"controller" => "catalog", :action=> "index", :sort=>"title_ssi asc"})
end

#override of blacklight helper function:
# https://github.com/projectblacklight/blacklight/blob/master/app/helpers/blacklight/blacklight_helper_behavior.rb#L353
# uses a semi-colon delimiter in for search result field values
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_sort_widget.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ul class="dropdown-menu">
<%- blacklight_config.sort_fields.each do |sort_key, field| %>
<li><%= link_to(field.label, url_for(params_for_search(:sort => sort_key))) %></li>
<li><%= link_to(field.label, url_for(params_for_search(:sort => sort_key))) %></li>
<%- end -%>
</ul>

Expand Down
4 changes: 2 additions & 2 deletions app/views/dams_collections/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
<%# Collection controls %>
<% if @object_count > 0 %>
<%= link_to "<i class='icon-eye-open icon-white'></i> View Collection Items".html_safe, facet_uri(@collection_title,'collection_sim'), :class => 'btn btn-large btn-inverse btn-block' %>
<%= link_to "<i class='icon-eye-open icon-white'></i> View Collection Items".html_safe, facet_default_uri(@collection_title,'collection_sim'), :class => 'btn btn-large btn-inverse btn-block' %>
<div class="well collections-search-box"><%= render :partial => 'search' %></div>
<% else %>
<p class="alert alert-phone alert-no-dismiss"><%=no_collection_items_notice%></p>
Expand All @@ -50,7 +50,7 @@
</div>
<%# Collection controls %>
<% if @object_count > 0 %>
<%= link_to "<i class='icon-eye-open icon-white'></i> View Collection Items".html_safe, facet_uri(@collection_title,'collection_sim'), :class => 'btn btn-large btn-inverse btn-block' %>
<%= link_to "<i class='icon-eye-open icon-white'></i> View Collection Items".html_safe, facet_default_uri(@collection_title,'collection_sim'), :class => 'btn btn-large btn-inverse btn-block' %>
<div class="well collections-search-box"><%= render :partial => 'search' %></div>
<% else %>
<p class="alert alert-no-dismiss"><%=no_collection_items_notice%></p>
Expand Down
12 changes: 9 additions & 3 deletions spec/features/dams_collections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
visit dams_collections_path({:per_page=>100})
expect(page).to have_content('Access: Curator Only')
end

end

feature 'Visitor wants to look at the collection search results view with no issued date' do
Expand All @@ -102,7 +101,6 @@
expect(page).to have_selector("ul.dams-search-results-fields:first li span", :text => '1961-1978')
expect(page).to have_no_content('1000-2015')
end

end

feature 'Visitor wants to see the collection record' do
Expand All @@ -119,19 +117,20 @@
@unit.delete
@commonName.delete
end

scenario 'should see the related resource with no URI' do
visit dams_collection_path("#{@provCollection.pid}")
expect(page).to have_content('The physical materials are held at UC San Diego Library')
expect(page).not_to have_link('The physical materials are held at UC San Diego Library', {href: ''})
end

scenario 'should see the names in order' do
visit dams_collection_path("#{@provCollection.pid}")
expect(page).to have_selector("div.span8 dl dt[1]", :text => 'Principal Investigator')
expect(page).to have_selector("div.span8 dl dt[3]", :text => 'Co Principal Investigator')
expect(page).to have_selector("div.span8 dl dt[5]", :text => 'Creator')
expect(page).to have_selector("div.span8 dl dt[7]", :text => 'Author')
expect(page).to have_selector("div.span8 dl dt[9]", :text => 'Contributors')

end

scenario 'should not see access control information (public)' do
Expand Down Expand Up @@ -341,6 +340,13 @@
expect(page).to_not have_content("<a href=\"http://library.ucsd.edu/dc/collection/<span class='search-highlight'>#{@aCollection.pid}</span>\">")
end

scenario 'should see the search result page default sort is title after click "View Collection Items"' do
visit dams_collection_path("#{@aCollection.pid}")
first(:link, "View Collection Items").click

expect(page).to have_content("Sort: title")
expect(page).to_not have_content("Sort: relevance")
end
end


Expand Down

0 comments on commit c6eb470

Please sign in to comment.