Skip to content

Commit

Permalink
Construct index, show and facet field labels from the field name if n…
Browse files Browse the repository at this point in the history
…o field name is available.
  • Loading branch information
cbeer committed Sep 9, 2014
1 parent 3e1b865 commit 1997445
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
23 changes: 13 additions & 10 deletions app/helpers/blacklight/configuration_helper_behavior.rb
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions spec/features/search_spec.rb
Expand Up @@ -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

0 comments on commit 1997445

Please sign in to comment.