From 1997445b79cade3bf41639172a704aa953e14ba3 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Tue, 9 Sep 2014 08:52:58 -0700 Subject: [PATCH] Construct index, show and facet field labels from the field name if no field name is available. --- .../configuration_helper_behavior.rb | 23 +++++++++++-------- spec/features/search_spec.rb | 5 ++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/helpers/blacklight/configuration_helper_behavior.rb b/app/helpers/blacklight/configuration_helper_behavior.rb index bf94e7952c..cf8a1488f3 100644 --- a/app/helpers/blacklight/configuration_helper_behavior.rb +++ b/app/helpers/blacklight/configuration_helper_behavior.rb @@ -58,36 +58,39 @@ def default_search_field?(selected_search_field) ## # Look up the label for the index field def index_field_label document, field - label = index_fields(document)[field].label + field_config = index_fields(document)[field] solr_field_label( - label, + (field_config.label if field_config), :"blacklight.search.fields.index.#{field}", - :"blacklight.search.fields.#{field}" + :"blacklight.search.fields.#{field}", + field.to_s.humanize ) end ## # Look up the label for the show field def document_show_field_label document, field - label = document_show_fields(document)[field].label - + field_config = document_show_fields(document)[field] + solr_field_label( - label, + (field_config.label if field_config), :"blacklight.search.fields.show.#{field}", - :"blacklight.search.fields.#{field}" + :"blacklight.search.fields.#{field}", + field.to_s.humanize ) end ## # Look up the label for the facet field def facet_field_label field - label = blacklight_config.facet_fields[field].label + field_config = blacklight_config.facet_fields[field] solr_field_label( - label, + (field_config.label if field_config), :"blacklight.search.fields.facet.#{field}", - :"blacklight.search.fields.#{field}" + :"blacklight.search.fields.#{field}", + field.to_s.humanize ) end diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 5bd0e89b3d..14368e4fe3 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -111,5 +111,10 @@ expect(page).to have_content "Welcome!" expect(page).to_not have_selector "#q[value='history']" end + + it "should gracefully handle searches with invalid facet parameters" do + visit root_path f: { missing_s: [1]} + expect(page).to have_content "No results found for your search" + end end