Skip to content

Commit

Permalink
Deprecate facet_list_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed May 11, 2017
1 parent 4fcef29 commit 9b8cd1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .rubocop_todo.yml
Expand Up @@ -90,6 +90,8 @@ Metrics/BlockNesting:
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 186
Exclude:
- 'lib/blacklight/configuration.rb'

# Offense count: 20
Metrics/CyclomaticComplexity:
Expand All @@ -99,11 +101,15 @@ Metrics/CyclomaticComplexity:
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 52
Exclude:
- 'lib/blacklight/configuration.rb'

# Offense count: 9
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 208
Exclude:
- 'lib/blacklight/solr/search_builder_behavior.rb'

# Offense count: 1
# Configuration parameters: CountKeywordArgs.
Expand Down
3 changes: 2 additions & 1 deletion lib/blacklight/configuration.rb
Expand Up @@ -136,7 +136,8 @@ def default_values
default_per_page: nil,
# how many searches to save in session history
search_history_window: 100,
default_facet_limit: 10
default_facet_limit: 10,
default_more_limit: 20
}
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/blacklight/solr/search_builder_behavior.rb
Expand Up @@ -185,11 +185,13 @@ def add_facet_paging_to_solr(solr_params)
solr_params[:"facet.field"] = with_ex_local_param(facet_ex, facet_config.field)

limit = if scope.respond_to?(:facet_list_limit)
Deprecation.warn(self, "The use of facet_list_limit is deprecated and will be removed in 7.0. " \
"Consider using the 'more_limit' option in the field configuration or 'default_more_limit' instead.")
scope.facet_list_limit.to_s.to_i
elsif solr_params["facet.limit"]
solr_params["facet.limit"].to_i
else
facet_config.fetch(:more_limit, 20)
facet_config.fetch(:more_limit, blacklight_config.default_more_limit)
end

page = blacklight_params.fetch(request_keys[:page], 1).to_i
Expand Down
7 changes: 4 additions & 3 deletions spec/models/blacklight/solr/search_builder_spec.rb
Expand Up @@ -367,7 +367,7 @@
end
end


describe "#facet_value_to_fq_string" do
it "should use the configured field name" do
blacklight_config.add_facet_field :facet_key, field: "facet_name"
Expand Down Expand Up @@ -480,7 +480,7 @@

let(:solr_parameters) do
solr_parameters = Blacklight::Solr::Request.new

subject.add_facetting_to_solr(solr_parameters)

solr_parameters
Expand Down Expand Up @@ -512,7 +512,7 @@
it "should respect the include_in_request parameter" do
blacklight_config.add_facet_field 'yes_facet', include_in_request: true
blacklight_config.add_facet_field 'no_facet', include_in_request: false

expect(solr_parameters[:'facet.field']).to include('yes_facet')
expect(solr_parameters[:'facet.field']).not_to include('no_facet')
end
Expand Down Expand Up @@ -640,6 +640,7 @@

context 'when facet_list_limit is defined in scope' do
before do
allow(Deprecation).to receive(:warn)
allow(context).to receive_messages facet_list_limit: 1000
end
it 'uses scope method for limit' do
Expand Down

0 comments on commit 9b8cd1f

Please sign in to comment.