blacklight-spotlight 0.28.0 → 0.28.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: 00bc8950c632e97a365418053a379016e111b937
4
- data.tar.gz: 4eb7a348e011e9e0fc646946b91126a0e017269d
3
+ metadata.gz: ece8d22f7b1839d5ea4fb24642d7805f9ab02567
4
+ data.tar.gz: 604eeed993a923572cd6c7fb533f531ed395427d
5
5
  SHA512:
6
- metadata.gz: 9b6ce0ffe5fe536bbc4b73e845e3ccbe2ae48c01f43789463e6cab7e9454a9eaac5289b7c21da19ec4b66be634440adf1a460d02352c7baafee637c5e2761da3
7
- data.tar.gz: 4ba852983e8568cc516e0a3e7cabfa7cd15b46c132ddb8d34bbd2fa2fde94625c411c7a76674632f16283f4f95947f6cd1609811450251546de4a7e7b335525a
6
+ metadata.gz: 5004e50bc5c190078217936076b7667d48089eb9e222ca8d4a7d9b7554059d49a02ebd18504afaae233d890b1b0fdc1a24e164547cab391aa309f6cd5ca973b3
7
+ data.tar.gz: dc8f7e5ccbfe784a6c3372c0131843bf2fe0732227fb279761ac7cc76532b5662d361ec7ef213c37cea3b2c1ff9824711941e9a127f55e2a807633ba4be6ad02
@@ -26,9 +26,7 @@ module Spotlight
26
26
  protected
27
27
 
28
28
  def search_query
29
- base_query = Blacklight::SearchState.new(@search.query_params, blacklight_config)
30
- user_query = Blacklight::SearchState.new(params, blacklight_config).to_h
31
- base_query.params_for_search(user_query)
29
+ @search.merge_params_for_search(params, blacklight_config)
32
30
  end
33
31
 
34
32
  ##
@@ -21,8 +21,8 @@ module Spotlight
21
21
  end
22
22
 
23
23
  def get_search_widget_search_results(block)
24
- if block.searches?
25
- search_results(search_widget_search_query(block))
24
+ if block.search.present?
25
+ search_results(block.search.merge_params_for_search(params, blacklight_config))
26
26
  else
27
27
  []
28
28
  end
@@ -50,13 +50,5 @@ module Spotlight
50
50
  def render_contact_email_address(address)
51
51
  mail_to address, address
52
52
  end
53
-
54
- private
55
-
56
- def search_widget_search_query(block)
57
- base_query = Blacklight::SearchState.new(block.query_params, blacklight_config)
58
- user_query = Blacklight::SearchState.new(params, blacklight_config).to_h
59
- base_query.params_for_search(user_query)
60
- end
61
53
  end
62
54
  end
@@ -78,6 +78,12 @@ module Spotlight
78
78
  search_builder.with(query_params.with_indifferent_access).merge(facet: false, fl: default_search_fields)
79
79
  end
80
80
 
81
+ def merge_params_for_search(params, blacklight_config)
82
+ base_query = Blacklight::SearchState.new(query_params, blacklight_config)
83
+ user_query = Blacklight::SearchState.new(params, blacklight_config).to_h
84
+ base_query.params_for_search(user_query).merge(user_query.slice(:page))
85
+ end
86
+
81
87
  private
82
88
 
83
89
  def search_builder_class
@@ -1,3 +1,3 @@
1
1
  module Spotlight
2
- VERSION = '0.28.0'.freeze
2
+ VERSION = '0.28.1'.freeze
3
3
  end
@@ -118,4 +118,20 @@ describe Spotlight::Search, type: :model do
118
118
  expect(search.send(:repository).blacklight_config).to eql blacklight_config
119
119
  end
120
120
  end
121
+
122
+ describe '#merge_params_for_search' do
123
+ it 'merges user-supplied parameters into the search query' do
124
+ user_params = { view: 'x' }
125
+ search_params = subject.merge_params_for_search(user_params, blacklight_config)
126
+ expect(search_params).to include query_params
127
+ expect(search_params).to include user_params
128
+ end
129
+
130
+ it 'preserves user pagination' do
131
+ user_params = { page: 5, per_page: 7 }
132
+ search_params = subject.merge_params_for_search(user_params, blacklight_config)
133
+ expect(search_params).to include query_params
134
+ expect(search_params).to include user_params
135
+ end
136
+ end
121
137
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-spotlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.28.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer