Skip to content

Commit

Permalink
Handle user-supplied facet value parameters as arrays or strings
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Aug 31, 2016
1 parent d914c53 commit f8aed34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/helpers/blacklight/render_constraints_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ def render_constraints_filters(localized_params = params)
def render_filter_element(facet, values, path)
facet_config = facet_configuration_for_field(facet)

safe_join(values.map do |val|
safe_join(Array(values).map do |val|
next if val.blank? # skip empty string
render_constraint_element( facet_field_label(facet_config.key), facet_display_value(facet, val),
remove: search_action_path(path.remove_facet_params(facet, val)),
classes: ["filter", "filter-" + facet.parameterize]
)
render_constraint_element(facet_field_label(facet_config.key),
facet_display_value(facet, val),
remove: search_action_path(path.remove_facet_params(facet, val)),
classes: ["filter", "filter-" + facet.parameterize])
end, "\n")
end

Expand Down
8 changes: 8 additions & 0 deletions spec/helpers/render_constraints_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz"
expect(subject).to have_selector ".filterName", text: 'Item Type'
end

context 'with string values' do
subject { helper.render_filter_element('type', 'journal', path) }

it "handles string values gracefully" do
expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz"
end
end
end

describe "#render_constraints_filters" do
Expand Down

0 comments on commit f8aed34

Please sign in to comment.