Skip to content

Commit

Permalink
Render 404 when a facet isn't found.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Sep 12, 2017
1 parent d9eb936 commit 11e1e42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/concerns/blacklight/catalog.rb
Expand Up @@ -67,6 +67,7 @@ def track
# displays values and pagination links for a single facet field
def facet
@facet = blacklight_config.facet_fields[params[:id]]
raise ActionController::RoutingError, 'Not Found' unless @facet
@response = get_facet_field_response(@facet.key, params)
@display_facet = @response.aggregations[@facet.field]
@pagination = facet_paginator(@facet, @display_facet)
Expand Down
8 changes: 8 additions & 0 deletions spec/controllers/catalog_controller_spec.rb
Expand Up @@ -541,6 +541,14 @@ def export_as_mock
expect(assigns[:pagination].items.first['value']).to eq 'Book'
end
end

context 'when the requested facet is not in the configuration' do
it 'raises a routing error' do
expect {
get :facet, params: { id: 'fake' }
}.to raise_error ActionController::RoutingError, 'Not Found'
end
end
end

describe "#add_to_search_history" do
Expand Down

0 comments on commit 11e1e42

Please sign in to comment.