Skip to content

Commit

Permalink
CatalogHelper uses SearchState
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 31, 2015
1 parent 69bb4f0 commit 51bf34c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 1 addition & 3 deletions app/helpers/blacklight/catalog_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ def render_search_to_page_title(params)
private

def feed_link_url(format)
options = params.merge(format: format)
options.permit!
url_for options
url_for search_state.to_h.merge(format: format)
end
end
13 changes: 8 additions & 5 deletions spec/helpers/deprecated_url_helper_behavior_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
end
end

let(:parameter_class) do
Rails.version >= '5.0.0' ? ActionController::Parameters : HashWithIndifferentAccess
end
let(:search_state) { Blacklight::SearchState.new(params, blacklight_config) }
let(:params) { ActionController::Parameters.new }
let(:params) { parameter_class.new }
let(:blacklight_config) { Blacklight::Configuration.new }

before do
Expand All @@ -27,7 +30,7 @@
end

it 'generates a search state for the source parameters' do
expect(helper.params_for_search(ActionController::Parameters.new(source: 1), { merge: 1 })).to include merge: 1, source: 1
expect(helper.params_for_search(parameter_class.new(source: 1), { merge: 1 })).to include merge: 1, source: 1
end
end

Expand All @@ -38,7 +41,7 @@
end

describe '#reset_search_params' do
let(:source_parameters) { ActionController::Parameters.new page: 1, counter: 10 }
let(:source_parameters) { parameter_class.new page: 1, counter: 10 }
it 'resets the current page and counter' do
expect(helper.reset_search_params(source_parameters)).to be_blank
end
Expand All @@ -57,7 +60,7 @@
end

context "with source_parameters" do
let(:source_parameters) { ActionController::Parameters.new source: 1 }
let(:source_parameters) { parameter_class.new source: 1 }
it 'generates a search state for the source parameters' do
expect(helper.add_facet_params(field, item, source_parameters)).to include source: 1
end
Expand Down Expand Up @@ -90,7 +93,7 @@
end

context "with source_parameters" do
let(:source_parameters) { ActionController::Parameters.new source: 1 }
let(:source_parameters) { parameter_class.new source: 1 }
it 'generates a search state for the source parameters' do
expect(helper.remove_facet_params(field, item, source_parameters)).to include source: 1
end
Expand Down

0 comments on commit 51bf34c

Please sign in to comment.