Skip to content

Commit

Permalink
Uses solr_name :facetable for the link_to_search: and Fixes spec test…
Browse files Browse the repository at this point in the history
… to allow the view to receive :search_state and :search_action_path.

Experiments with adjusting the code for the tests by removing itemprop since link_to_search also produces a span for itemprop creator. Keeps url at /catalog to avoid Esher-esque cases
  • Loading branch information
mtribone committed Jun 16, 2016
1 parent 45be148 commit 21f0455
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/generators/sufia/templates/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ def self.modified_field
# The ordering of the field names is the order of the display
config.add_index_field solr_name("title", :stored_searchable), label: "Title", itemprop: 'name', if: false
config.add_index_field solr_name("description", :stored_searchable), label: "Description", itemprop: 'description', helper_method: :iconify_auto_link
config.add_index_field solr_name("keyword", :stored_searchable), label: "Keyword", itemprop: 'keywords'
config.add_index_field solr_name("subject", :stored_searchable), label: "Subject", itemprop: 'about'
config.add_index_field solr_name("creator", :stored_searchable), label: "Creator", itemprop: 'creator'
config.add_index_field solr_name("contributor", :stored_searchable), label: "Contributor", itemprop: 'contributor'
config.add_index_field solr_name("keyword", :stored_searchable), label: "Keyword", itemprop: 'keywords', link_to_search: solr_name("keyword", :facetable)
config.add_index_field solr_name("subject", :stored_searchable), label: "Subject", itemprop: 'about', link_to_search: solr_name("subject", :facetable)
config.add_index_field solr_name("creator", :stored_searchable), label: "Creator", link_to_search: solr_name("creator", :facetable)
config.add_index_field solr_name("contributor", :stored_searchable), label: "Contributor", itemprop: 'contributor', link_to_search: solr_name("contributor", :facetable)
config.add_index_field solr_name("proxy_depositor", :symbol), label: "Depositor", helper_method: :link_to_profile
config.add_index_field solr_name("depositor"), label: "Owner", helper_method: :link_to_profile
config.add_index_field solr_name("publisher", :stored_searchable), label: "Publisher", itemprop: 'publisher'
config.add_index_field solr_name("based_near", :stored_searchable), label: "Location", itemprop: 'contentLocation'
config.add_index_field solr_name("language", :stored_searchable), label: "Language", itemprop: 'inLanguage'
config.add_index_field solr_name("publisher", :stored_searchable), label: "Publisher", itemprop: 'publisher', link_to_search: solr_name("publisher", :facetable)
config.add_index_field solr_name("based_near", :stored_searchable), label: "Location", itemprop: 'contentLocation', link_to_search: solr_name("based_near", :facetable)
config.add_index_field solr_name("language", :stored_searchable), label: "Language", itemprop: 'inLanguage', link_to_search: solr_name("language", :facetable)
config.add_index_field solr_name("date_uploaded", :stored_sortable, type: :date), label: "Date Uploaded", itemprop: 'datePublished', helper_method: :human_readable_date
config.add_index_field solr_name("date_modified", :stored_sortable, type: :date), label: "Date Modified", itemprop: 'dateModified', helper_method: :human_readable_date
config.add_index_field solr_name("date_created", :stored_searchable), label: "Date Created", itemprop: 'dateCreated'
config.add_index_field solr_name("rights", :stored_searchable), label: "Rights", helper_method: :rights_statement_links
config.add_index_field solr_name("resource_type", :stored_searchable), label: "Resource Type"
config.add_index_field solr_name("format", :stored_searchable), label: "File Format"
config.add_index_field solr_name("resource_type", :stored_searchable), label: "Resource Type", link_to_search: solr_name("resource_type", :facetable)
config.add_index_field solr_name("format", :stored_searchable), label: "File Format", link_to_search: solr_name("format", :facetable)
config.add_index_field solr_name("identifier", :stored_searchable), label: "Identifier"

# solr fields to be displayed in the show (single result) view
Expand Down
5 changes: 4 additions & 1 deletion spec/views/catalog/_index_list_default.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"http://creativecommons.org/publicdomain/mark/1.0/",
"http://www.europeana.eu/portal/rights/rr-r.html"] }
end
let(:search_state) { Blacklight::SearchState.new(params, CatalogController.blacklight_config) }
let(:document) { SolrDocument.new(attributes) }
let(:blacklight_configuration_context) do
Blacklight::Configuration::Context.new(controller)
Expand All @@ -21,13 +22,15 @@
allow(User).to receive(:find_by_user_key).and_return(joe, justin)
allow(view).to receive(:blacklight_config).and_return(CatalogController.blacklight_config)
allow(view).to receive(:blacklight_configuration_context).and_return(blacklight_configuration_context)
allow(view).to receive(:search_state).and_return(search_state)
allow(view).to receive(:search_action_path)
render 'catalog/index_list_default', document: document
end

it "displays metadata" do
expect(rendered).not_to include 'Title:'
expect(rendered).to include '<span class="attribute-label h4">Creator:</span>'
expect(rendered).to include '<span itemprop="creator">Justin</span> and <span itemprop="creator">Joe</span>'
expect(rendered).to include '<span itemprop="creator"><a href="/catalog">Justin</a></span> and <span itemprop="creator"><a href="/catalog">Joe</a></span>'
expect(rendered).to include '<span class="attribute-label h4">Description:</span>'
expect(rendered).to include '<span itemprop="description">This links to <a href="http://example.com/"><span class="glyphicon glyphicon-new-window"></span> http://example.com/</a> What about that?</span>'
expect(rendered).to include '<span class="attribute-label h4">Date Uploaded:</span>'
Expand Down

0 comments on commit 21f0455

Please sign in to comment.