Skip to content

Commit

Permalink
Fix #exhibit_search_facet_url regression from to_unsafe_h; fixes #1550
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Aug 3, 2016
1 parent 6fc29ff commit 00c89de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/spotlight/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def exhibit_search_action_url(*args)

def exhibit_search_facet_url(*args)
options = args.extract_options!
options = params.to_unsafe_h.merge(options).except(:exhibit_id, :only_path)
options = Blacklight::Parameters.sanitize(params.to_unsafe_h.with_indifferent_access).merge(options).except(:exhibit_id, :only_path)
spotlight.facet_exhibit_catalog_url(current_exhibit, *args, options)
end
end
Expand Down
17 changes: 16 additions & 1 deletion spec/lib/spotlight/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ class MockController < ActionController::Base

subject { MockController.new }

let(:params) { { action: 'show' } }

before do
allow(subject).to receive_messages(params: { action: 'show' })
allow(subject).to receive_messages(params: ActionController::Parameters.new(params))
end

describe '#current_exhibit' do
Expand Down Expand Up @@ -82,4 +84,17 @@ class MockController < ActionController::Base
expect(subject.resource_masthead?).to eq false
end
end

describe '#exhibit_search_facet_url' do
let(:exhibit) { FactoryGirl.create(:exhibit) }
let(:params) { { action: 'index', q: 'xyz' } }

before do
allow(subject).to receive(:current_exhibit).and_return(exhibit)
end
it 'adds the current exhibit context to the route' do
expect(subject.spotlight).to receive(:facet_exhibit_catalog_url).with(exhibit, id: 'some_field', q: 'xyz')
subject.exhibit_search_facet_url(id: 'some_field')
end
end
end

0 comments on commit 00c89de

Please sign in to comment.