blacklight_advanced_search 6.2.0 → 6.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f94e150438b2ed6a6fabd89cfbd050babfbcd96e
4
- data.tar.gz: ad24822b9631e506de17d7a11db709dba64a68e7
3
+ metadata.gz: 050411c1a81b12203d148e6573bdcf65a1e24f6d
4
+ data.tar.gz: 23537090bf069c31ed54b42f07bcc60fd18fdf86
5
5
  SHA512:
6
- metadata.gz: 72a0b4d1718c5f03c69df999c11bc2465d787c0198932e7f964c06bb20097c9db6950107ea9c14eb65f6c4a77bbe0ba3a4c06f29cafa2680c24eb65761650a29
7
- data.tar.gz: 3961675ce8655a762252fce99bede4bfd758c52e2a96ff33c69263ce722bbf27143599fc8bc3a27052c0b6393daacc379fce12712310afc97317bdf235e4ae2c
6
+ metadata.gz: 96ccfb9dfb3c8a8b14bb973ff9adaff70ce15e722b706b0b428396e3c2b5e08263bc2f5b0bdf14b80a6a64c5eb01ce311dce4585032a7f279b18dfe172bdc6f2
7
+ data.tar.gz: 25f215056e4225475c068732e8facd4c09c60e71d3a2a4bd90ce44a5f4de916608d0d775435fa8fd452edb6b94abeee69b70c861e0fd727d7c428d1260133aca
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.2.0
1
+ 6.2.1
@@ -48,29 +48,29 @@ module BlacklightAdvancedSearch
48
48
  # parse and send it straight to solr same as if advanced_parse_q
49
49
  # were not being used.
50
50
  def add_advanced_parse_q_to_solr(solr_parameters)
51
- unless blacklight_params[:q].blank?
52
- field_def = search_field_def_for_key(blacklight_params[:search_field]) ||
53
- default_search_field
51
+ return if blacklight_params[:q].blank? || !blacklight_params[:q].respond_to?(:to_str)
54
52
 
55
- # If the individual field has advanced_parse_q suppressed, punt
56
- return if field_def[:advanced_parse] == false
53
+ field_def = search_field_def_for_key(blacklight_params[:search_field]) ||
54
+ default_search_field
57
55
 
58
- solr_direct_params = field_def[:solr_parameters] || {}
59
- solr_local_params = field_def[:solr_local_parameters] || {}
56
+ # If the individual field has advanced_parse_q suppressed, punt
57
+ return if field_def[:advanced_parse] == false
60
58
 
61
- # See if we can parse it, if we can't, we're going to give up
62
- # and just allow basic search, perhaps with a warning.
63
- begin
64
- adv_search_params = ParsingNesting::Tree.parse(blacklight_params[:q], blacklight_config.advanced_search[:query_parser]).to_single_query_params(solr_local_params)
59
+ solr_direct_params = field_def[:solr_parameters] || {}
60
+ solr_local_params = field_def[:solr_local_parameters] || {}
65
61
 
66
- BlacklightAdvancedSearch.deep_merge!(solr_parameters, solr_direct_params)
67
- BlacklightAdvancedSearch.deep_merge!(solr_parameters, adv_search_params)
68
- rescue PARSLET_FAILED_EXCEPTIONS => e
69
- # do nothing, don't merge our input in, keep basic search
70
- # optional TODO, display error message in flash here, but hard to
71
- # display a good one.
72
- return
73
- end
62
+ # See if we can parse it, if we can't, we're going to give up
63
+ # and just allow basic search, perhaps with a warning.
64
+ begin
65
+ adv_search_params = ParsingNesting::Tree.parse(blacklight_params[:q], blacklight_config.advanced_search[:query_parser]).to_single_query_params(solr_local_params)
66
+
67
+ BlacklightAdvancedSearch.deep_merge!(solr_parameters, solr_direct_params)
68
+ BlacklightAdvancedSearch.deep_merge!(solr_parameters, adv_search_params)
69
+ rescue *PARSLET_FAILED_EXCEPTIONS => e
70
+ # do nothing, don't merge our input in, keep basic search
71
+ # optional TODO, display error message in flash here, but hard to
72
+ # display a good one.
73
+ return
74
74
  end
75
75
  end
76
76
 
@@ -44,6 +44,23 @@ describe BlacklightAdvancedSearch::AdvancedSearchBuilder do
44
44
  obj.add_advanced_parse_q_to_solr(solr_params)
45
45
  expect(solr_params[:q]).to eq(unparseable_q)
46
46
  end
47
+
48
+ describe 'when parslet fails' do
49
+ let(:failing_q) { ")(" }
50
+ let(:params) { { :q => failing_q } }
51
+ it 'does not return the query that could not be parsed' do
52
+ obj.add_advanced_parse_q_to_solr(solr_params)
53
+ expect(solr_params[:q]).to be_nil
54
+ end
55
+ end
56
+
57
+ describe 'when `q` is a hash' do
58
+ let(:params) { { q: { id: ['a'] } } }
59
+ it 'does not return the query that could not be parsed' do
60
+ obj.add_advanced_parse_q_to_solr(solr_params)
61
+ expect(solr_params[:q]).to be_nil
62
+ end
63
+ end
47
64
  end
48
65
 
49
66
  context "when advanced_parse is false" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight_advanced_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0
4
+ version: 6.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  version: '0'
267
267
  requirements: []
268
268
  rubyforge_project: blacklight
269
- rubygems_version: 2.5.2
269
+ rubygems_version: 2.5.1
270
270
  signing_key:
271
271
  specification_version: 4
272
272
  summary: Blacklight Advanced Search plugin