blacklight 5.7.2 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -3
  3. data/Gemfile +1 -4
  4. data/VERSION +1 -1
  5. data/app/assets/stylesheets/blacklight/_catalog.css.scss +38 -1
  6. data/app/assets/stylesheets/blacklight/_facets.css.scss +10 -0
  7. data/app/assets/stylesheets/blacklight/_layout.css.scss +6 -0
  8. data/app/controllers/bookmarks_controller.rb +3 -163
  9. data/app/helpers/blacklight/blacklight_helper_behavior.rb +18 -186
  10. data/app/helpers/blacklight/catalog_helper_behavior.rb +36 -2
  11. data/app/helpers/blacklight/component_helper_behavior.rb +77 -0
  12. data/app/helpers/blacklight/configuration_helper_behavior.rb +30 -21
  13. data/app/helpers/blacklight/render_partials_helper.rb +185 -0
  14. data/app/helpers/blacklight/url_helper_behavior.rb +24 -3
  15. data/app/helpers/component_helper.rb +3 -0
  16. data/app/views/_user_util_links.html.erb +2 -15
  17. data/app/views/blacklight/nav/_bookmark.html.erb +4 -0
  18. data/app/views/blacklight/nav/_saved_searches.html.erb +1 -0
  19. data/app/views/blacklight/nav/_search_history.html.erb +1 -0
  20. data/app/views/bookmarks/_tools.html.erb +6 -9
  21. data/app/views/bookmarks/index.html.erb +1 -1
  22. data/app/views/catalog/_bookmark_control.html.erb +8 -8
  23. data/app/views/catalog/_constraints_element.html.erb +1 -1
  24. data/app/views/catalog/_document_action.html.erb +4 -0
  25. data/app/views/catalog/_email_form.html.erb +1 -1
  26. data/app/views/catalog/_facet_limit.html.erb +1 -1
  27. data/app/views/catalog/_index_header_default.html.erb +5 -6
  28. data/app/views/catalog/_per_page_widget.html.erb +3 -1
  29. data/app/views/catalog/_results_pagination.html.erb +1 -1
  30. data/app/views/catalog/_search_form.html.erb +5 -8
  31. data/app/views/catalog/_show_more_like_this.html.erb +2 -2
  32. data/app/views/catalog/_show_tools.html.erb +5 -34
  33. data/app/views/catalog/_sms_form.html.erb +1 -1
  34. data/app/views/catalog/_sort_and_per_page.html.erb +2 -6
  35. data/app/views/catalog/_sort_widget.html.erb +1 -1
  36. data/app/views/catalog/_zero_results.html.erb +2 -2
  37. data/app/views/catalog/citation.js.erb +1 -1
  38. data/app/views/catalog/email_sent.html.erb +2 -9
  39. data/app/views/catalog/email_success.html.erb +9 -0
  40. data/app/views/catalog/sms_sent.html.erb +2 -9
  41. data/app/views/catalog/sms_success.html.erb +9 -0
  42. data/app/views/kaminari/blacklight/_gap.html.erb +1 -1
  43. data/app/views/kaminari/blacklight/_page.html.erb +5 -1
  44. data/app/views/shared/_header_navbar.html.erb +1 -1
  45. data/config/locales/blacklight.en.yml +1 -1
  46. data/config/locales/blacklight.es.yml +1 -1
  47. data/config/locales/blacklight.fr.yml +1 -1
  48. data/config/locales/blacklight.pt-BR.yml +1 -1
  49. data/lib/blacklight.rb +3 -0
  50. data/lib/blacklight/base.rb +0 -1
  51. data/lib/blacklight/bookmarks.rb +135 -0
  52. data/lib/blacklight/catalog.rb +58 -77
  53. data/lib/blacklight/catalog/component_configuration.rb +99 -0
  54. data/lib/blacklight/configuration.rb +82 -4
  55. data/lib/blacklight/configuration/tool_config.rb +4 -0
  56. data/lib/blacklight/controller.rb +5 -1
  57. data/lib/blacklight/document_presenter.rb +17 -8
  58. data/lib/blacklight/request_builders.rb +136 -4
  59. data/lib/blacklight/routes.rb +5 -0
  60. data/lib/blacklight/solr_helper.rb +90 -208
  61. data/lib/blacklight/solr_repository.rb +69 -0
  62. data/lib/blacklight/token_based_user.rb +58 -0
  63. data/lib/blacklight/utils.rb +13 -1
  64. data/lib/generators/blacklight/install_generator.rb +6 -7
  65. data/spec/controllers/alternate_controller_spec.rb +19 -0
  66. data/spec/controllers/catalog_controller_spec.rb +89 -4
  67. data/spec/features/alternate_controller_spec.rb +0 -1
  68. data/spec/features/bookmarks_spec.rb +31 -6
  69. data/spec/features/search_results_spec.rb +11 -0
  70. data/spec/features/search_spec.rb +5 -0
  71. data/spec/helpers/blacklight_helper_spec.rb +49 -8
  72. data/spec/helpers/catalog_helper_spec.rb +56 -8
  73. data/spec/helpers/configuration_helper_spec.rb +5 -5
  74. data/spec/helpers/url_helper_spec.rb +15 -8
  75. data/spec/lib/blacklight/catalog/component_configuration_spec.rb +29 -0
  76. data/spec/lib/blacklight/configuration_spec.rb +15 -0
  77. data/spec/lib/blacklight/solr_helper_spec.rb +44 -104
  78. data/spec/lib/blacklight/solr_repository_spec.rb +113 -0
  79. data/spec/lib/utils_spec.rb +27 -0
  80. data/spec/views/_user_util_links.html.erb_spec.rb +6 -3
  81. data/spec/views/catalog/_show_sidebar.erb_spec.rb +8 -2
  82. data/spec/views/catalog/_show_tools.html.erb_spec.rb +82 -0
  83. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +15 -1
  84. data/tasks/blacklight.rake +25 -1
  85. metadata +24 -2
@@ -11,7 +11,7 @@ describe CatalogHelper do
11
11
  start = (current_page - 1) * per_page
12
12
 
13
13
  mock_docs = (1..total).to_a.map { {}.with_indifferent_access }
14
-
14
+
15
15
  mock_response = Kaminari.paginate_array(mock_docs).page(current_page).per(per_page)
16
16
 
17
17
  allow(mock_response).to receive(:docs).and_return(mock_docs.slice(start, per_page))
@@ -21,8 +21,8 @@ describe CatalogHelper do
21
21
  def render_grouped_response?
22
22
  false
23
23
  end
24
-
25
-
24
+
25
+
26
26
  describe "page_entries_info" do
27
27
  before(:all) do
28
28
  end
@@ -43,6 +43,13 @@ describe CatalogHelper do
43
43
  expect(html).to be_html_safe
44
44
  end
45
45
 
46
+ it "with an empty page of results" do
47
+ @response = double(limit_value: -1)
48
+
49
+ html = page_entries_info(@response)
50
+ expect(html).to be_blank
51
+ end
52
+
46
53
  describe "with a single result" do
47
54
  it "should use the provided entry name" do
48
55
  response = mock_response :total => 1
@@ -177,17 +184,17 @@ describe CatalogHelper do
177
184
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
178
185
  allow(helper).to receive_messages(:xyz => "some-thumbnail")
179
186
 
180
- allow(helper).to receive(:link_to_document).with(document, :label => "some-thumbnail")
187
+ allow(helper).to receive(:link_to_document).with(document, "some-thumbnail", {})
181
188
  helper.render_thumbnail_tag document
182
189
  end
183
190
 
184
191
  it "should create an image tag from the given field" do
185
192
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
186
-
193
+
187
194
  allow(document).to receive(:has?).with(:xyz).and_return(true)
188
195
  allow(document).to receive(:first).with(:xyz).and_return("http://example.com/some.jpg")
189
196
 
190
- allow(helper).to receive(:link_to_document).with(document, :label => image_tag("http://example.com/some.jpg"))
197
+ allow(helper).to receive(:link_to_document).with(document, image_tag("http://example.com/some.jpg"), {})
191
198
  helper.render_thumbnail_tag document
192
199
  end
193
200
 
@@ -206,7 +213,7 @@ describe CatalogHelper do
206
213
  result = helper.render_thumbnail_tag document, {}, suppress_link: true
207
214
  expect(result).to eq "some-thumbnail"
208
215
  end
209
-
216
+
210
217
 
211
218
  it "should return nil if no thumbnail is available" do
212
219
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new() ))
@@ -216,7 +223,7 @@ describe CatalogHelper do
216
223
  it "should return nil if no thumbnail is returned from the thumbnail method" do
217
224
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
218
225
  allow(helper).to receive_messages(:xyz => nil)
219
-
226
+
220
227
  expect(helper.render_thumbnail_tag document).to be_nil
221
228
  end
222
229
  end
@@ -257,4 +264,45 @@ describe CatalogHelper do
257
264
  end
258
265
  end
259
266
 
267
+ describe "render_document_class" do
268
+ before do
269
+ allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
270
+ end
271
+
272
+ let :blacklight_config do
273
+ Blacklight::Configuration.new
274
+ end
275
+
276
+ it "should pull data out of a document's field" do
277
+ blacklight_config.index.display_type_field = :type
278
+ doc = { :type => 'book' }
279
+ expect(helper.render_document_class(doc)).to eq "blacklight-book"
280
+ end
281
+
282
+ it "should support multivalued fields" do
283
+ blacklight_config.index.display_type_field = :type
284
+ doc = { :type => ['book', 'mss'] }
285
+ expect(helper.render_document_class(doc)).to eq "blacklight-book blacklight-mss"
286
+ end
287
+
288
+ it "should support empty fields" do
289
+ blacklight_config.index.display_type_field = :type
290
+ doc = { :type => [] }
291
+ expect(helper.render_document_class(doc)).to be_blank
292
+ end
293
+
294
+ it "should support missing fields" do
295
+ blacklight_config.index.display_type_field = :type
296
+ doc = { }
297
+ expect(helper.render_document_class(doc)).to be_blank
298
+ end
299
+
300
+ it "should support view-specific field configuration" do
301
+ allow(helper).to receive(:document_index_view_type).and_return(:some_view_type)
302
+ blacklight_config.view.some_view_type.display_type_field = :other_type
303
+ doc = { other_type: "document"}
304
+ expect(helper.render_document_class(doc)).to eq "blacklight-document"
305
+ end
306
+ end
307
+
260
308
  end
@@ -92,7 +92,7 @@ describe BlacklightConfigurationHelper do
92
92
  let(:document) { double }
93
93
  it "should look up the label to display for the given document and field" do
94
94
  allow(helper).to receive(:index_fields).and_return({ "my_field" => double(label: "some label") })
95
- allow(helper).to receive(:solr_field_label).with("some label", :"blacklight.search.fields.index.my_field", :"blacklight.search.fields.my_field")
95
+ allow(helper).to receive(:solr_field_label).with(:"blacklight.search.fields.index.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
96
96
  helper.index_field_label document, "my_field"
97
97
  end
98
98
  end
@@ -101,7 +101,7 @@ describe BlacklightConfigurationHelper do
101
101
  let(:document) { double }
102
102
  it "should look up the label to display for the given document and field" do
103
103
  allow(helper).to receive(:document_show_fields).and_return({ "my_field" => double(label: "some label") })
104
- allow(helper).to receive(:solr_field_label).with("some label", :"blacklight.search.fields.show.my_field", :"blacklight.search.fields.my_field")
104
+ allow(helper).to receive(:solr_field_label).with(:"blacklight.search.fields.show.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
105
105
  helper.document_show_field_label document, "my_field"
106
106
  end
107
107
  end
@@ -110,14 +110,14 @@ describe BlacklightConfigurationHelper do
110
110
  let(:document) { double }
111
111
  it "should look up the label to display for the given document and field" do
112
112
  allow(blacklight_config).to receive(:facet_fields).and_return({ "my_field" => double(label: "some label") })
113
- allow(helper).to receive(:solr_field_label).with("some label", :"blacklight.search.fields.facet.my_field", :"blacklight.search.fields.my_field")
113
+ allow(helper).to receive(:solr_field_label).with(:"blacklight.search.fields.facet.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
114
114
  helper.facet_field_label "my_field"
115
115
  end
116
116
  end
117
117
 
118
118
  describe "#solr_field_label" do
119
119
  it "should look up the label as an i18n string" do
120
- allow(helper).to receive(:t).with(:some_key).and_return "my label"
120
+ allow(helper).to receive(:t).with(:some_key, default: []).and_return "my label"
121
121
  label = helper.solr_field_label :some_key
122
122
 
123
123
  expect(label).to eq "my label"
@@ -126,7 +126,7 @@ describe BlacklightConfigurationHelper do
126
126
  it "should pass the provided i18n keys to I18n.t" do
127
127
  allow(helper).to receive(:t).with(:key_a, default: [:key_b, "default text"])
128
128
 
129
- label = helper.solr_field_label "default text", :key_a, :key_b
129
+ label = helper.solr_field_label :key_a, :key_b, "default text"
130
130
  end
131
131
  end
132
132
 
@@ -254,37 +254,44 @@ describe BlacklightUrlHelper do
254
254
  it "should consist of the document title wrapped in a <a>" do
255
255
  data = {'id'=>'123456','title_display'=>['654321'] }
256
256
  @document = SolrDocument.new(data)
257
- expect(helper.link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '654321', :count => 1)
257
+ expect(helper.link_to_document(@document, :title_display)).to have_selector("a", :text => '654321', :count => 1)
258
258
  end
259
259
 
260
- it "should accept and return a string label" do
260
+ it "should have the old deprecated behavior (second argument is a hash)" do
261
261
  data = {'id'=>'123456','title_display'=>['654321'] }
262
262
  @document = SolrDocument.new(data)
263
+ expect(Deprecation).to receive(:warn)
263
264
  expect(helper.link_to_document(@document, { :label => "title_display" })).to have_selector("a", :text => 'title_display', :count => 1)
264
265
  end
265
266
 
267
+ it "should accept and return a string label" do
268
+ data = {'id'=>'123456','title_display'=>['654321'] }
269
+ @document = SolrDocument.new(data)
270
+ expect(helper.link_to_document(@document, "title_display")).to have_selector("a", :text => 'title_display', :count => 1)
271
+ end
272
+
266
273
  it "should accept and return a Proc" do
267
274
  data = {'id'=>'123456','title_display'=>['654321'] }
268
275
  @document = SolrDocument.new(data)
269
- expect(helper.link_to_document(@document, { :label => Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) } })).to have_selector("a", :text => '123456: 654321', :count => 1)
276
+ expect(helper.link_to_document(@document, Proc.new { |doc, opts| doc.get(:id) + ": " + doc.get(:title_display) })).to have_selector("a", :text => '123456: 654321', :count => 1)
270
277
  end
271
278
 
272
279
  it "should return id when label is missing" do
273
280
  data = {'id'=>'123456'}
274
281
  @document = SolrDocument.new(data)
275
- expect(helper.link_to_document(@document, { :label => :title_display })).to have_selector("a", :text => '123456', :count => 1)
282
+ expect(helper.link_to_document(@document, :title_display)).to have_selector("a", :text => '123456', :count => 1)
276
283
  end
277
284
 
278
285
  it "should be html safe" do
279
286
  data = {'id'=>'123456'}
280
287
  @document = SolrDocument.new(data)
281
- expect(helper.link_to_document(@document, { :label => :title_display })).to be_html_safe
288
+ expect(helper.link_to_document(@document, :title_display)).to be_html_safe
282
289
  end
283
290
 
284
291
  it "should convert the counter parameter into a data- attribute" do
285
292
  data = {'id'=>'123456','title_display'=>['654321']}
286
293
  @document = SolrDocument.new(data)
287
- expect(helper.link_to_document(@document, { :label => :title_display, :counter => 5 })).to match /\/catalog\/123456\/track\?counter=5/
294
+ expect(helper.link_to_document(@document, :title_display, counter: 5)).to match /\/catalog\/123456\/track\?counter=5/
288
295
  end
289
296
 
290
297
  it "should merge the data- attributes from the options with the counter params" do
@@ -297,12 +304,12 @@ describe BlacklightUrlHelper do
297
304
 
298
305
  it "passes on the title attribute to the link_to_with_data method" do
299
306
  @document = SolrDocument.new('id'=>'123456')
300
- expect(helper.link_to_document(@document,:label=>"Some crazy long label...",:title=>"Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
307
+ expect(helper.link_to_document(@document, "Some crazy long label...", title: "Some crazy longer label")).to match(/title=\"Some crazy longer label\"/)
301
308
  end
302
309
 
303
310
  it "doesn't add an erroneous title attribute if one isn't provided" do
304
311
  @document = SolrDocument.new('id'=>'123456')
305
- expect(helper.link_to_document(@document,:label=>"Some crazy long label...")).to_not match(/title=/)
312
+ expect(helper.link_to_document(@document, "Some crazy long label...")).to_not match(/title=/)
306
313
  end
307
314
 
308
315
  it "should work with integer ids" do
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Blacklight::Catalog::ComponentConfiguration do
4
+ subject do
5
+ Class.new do
6
+ include Blacklight::Configurable
7
+ include Blacklight::Catalog::ComponentConfiguration
8
+
9
+ def some_existing_action
10
+ 1
11
+ end
12
+ end
13
+ end
14
+
15
+ describe ".add_show_tools_partial" do
16
+ it "should define an action method" do
17
+ subject.add_show_tools_partial :xyz
18
+ expect(subject.new).to respond_to :xyz
19
+ end
20
+
21
+ it "should not replace an existing method" do
22
+ subject.add_show_tools_partial :some_existing_action
23
+ expect(subject.new.some_existing_action).to eq 1
24
+ end
25
+ end
26
+
27
+
28
+
29
+ end
@@ -83,6 +83,21 @@ describe "Blacklight::Configuration" do
83
83
  expect(@config.a).to be_nil
84
84
  expect(@config.facet_fields).to_not include(@mock_facet)
85
85
  end
86
+
87
+ it "should provide cloned copies of mutable data structures" do
88
+ @config.a = { value: 1 }
89
+ @config.b = [1,2,3]
90
+
91
+ config_copy = @config.inheritable_copy
92
+
93
+ config_copy.a[:value] = 2
94
+ config_copy.b << 5
95
+
96
+ expect(@config.a[:value]).to eq 1
97
+ expect(config_copy.a[:value]).to eq 2
98
+ expect(@config.b).to match_array [1,2,3]
99
+ expect(config_copy.b).to match_array [1,2,3,5]
100
+ end
86
101
  end
87
102
 
88
103
  describe "add alternative solr fields" do
@@ -18,20 +18,17 @@ describe Blacklight::SolrHelper do
18
18
  include Blacklight::SolrHelper
19
19
 
20
20
  attr_accessor :blacklight_config
21
- attr_accessor :blacklight_solr
21
+ attr_accessor :solr_repository
22
22
 
23
23
  def initialize blacklight_config, blacklight_solr
24
24
  self.blacklight_config = blacklight_config
25
- self.blacklight_solr = blacklight_solr
25
+ self.solr_repository = Blacklight::SolrRepository.new(blacklight_config)
26
+ self.solr_repository.blacklight_solr = blacklight_solr
26
27
  end
27
28
 
28
29
  def params
29
30
  {}
30
31
  end
31
-
32
- def logger
33
- Rails.logger
34
- end
35
32
  end
36
33
 
37
34
  subject { SolrHelperTestClass.new blacklight_config, blacklight_solr }
@@ -52,70 +49,6 @@ describe Blacklight::SolrHelper do
52
49
  @subject_search_params = {:commit=>"search", :search_field=>"subject", :action=>"index", :"controller"=>"catalog", :"rows"=>"10", :"q"=>"wome"}
53
50
  end
54
51
 
55
- describe "#find" do
56
- it "should use the configured solr path" do
57
- blacklight_config.solr_path = 'xyz'
58
- allow(blacklight_solr).to receive(:send_and_receive).with('xyz', anything).and_return("{}".to_json)
59
- expect(subject.find({})).to be_a_kind_of Blacklight::SolrResponse
60
- end
61
-
62
- it "should override the configured solr path" do
63
- blacklight_config.solr_path = 'xyz'
64
- allow(blacklight_solr).to receive(:send_and_receive).with('abc', anything).and_return("{}".to_json)
65
- expect(subject.find('abc', {})).to be_a_kind_of Blacklight::SolrResponse
66
- end
67
-
68
- it "should use a default :qt param" do
69
- blacklight_config.qt = 'xyz'
70
- allow(blacklight_solr).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'xyz'})).and_return("{}".to_json)
71
- expect(subject.find({})).to be_a_kind_of Blacklight::SolrResponse
72
- end
73
-
74
- it "should use the provided :qt param" do
75
- blacklight_config.qt = 'xyz'
76
- allow(blacklight_solr).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'abc'})).and_return("{}".to_json)
77
- expect(subject.find({qt: 'abc'})).to be_a_kind_of Blacklight::SolrResponse
78
- end
79
-
80
- describe "http_method configuration" do
81
- describe "using default" do
82
-
83
- it "defaults to get" do
84
- expect(blacklight_config.http_method).to eq :get
85
- allow(blacklight_solr).to receive(:send_and_receive) do |path, params|
86
- expect(path).to eq 'select'
87
- expect(params[:method]).to eq :get
88
- expect(params[:params]).to include(:q)
89
- end.and_return({'response'=>{'docs'=>[]}})
90
- subject.find(:q => @all_docs_query)
91
- end
92
- end
93
-
94
- describe "setting to post" do
95
- let (:blacklight_config) {config = Blacklight::Configuration.new; config.http_method=:post; config}
96
-
97
- it "keep value set to post" do
98
- expect(blacklight_config.http_method).to eq :post
99
- allow(blacklight_solr).to receive(:send_and_receive) do |path, params|
100
- expect(path).to eq 'select'
101
- expect(params[:method]).to eq :post
102
- expect(params[:data]).to include(:q)
103
- end.and_return({'response'=>{'docs'=>[]}})
104
- subject.find(:q => @all_docs_query)
105
- end
106
- end
107
- end
108
- end
109
-
110
- describe "http_method configuration", :integration => true do
111
- let (:blacklight_config) {config = Blacklight::Configuration.new; config.http_method=:post; config}
112
-
113
- it "should send a post request to solr and get a response back" do
114
- response = subject.find(:q => @all_docs_query)
115
- expect(response.docs.length).to be >= 1
116
- end
117
- end
118
-
119
52
  # SPECS for actual search parameter generation
120
53
  describe "solr_search_params" do
121
54
  it "allows customization of solr_search_params_logic" do
@@ -688,28 +621,19 @@ describe Blacklight::SolrHelper do
688
621
  expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to be_blank
689
622
  end
690
623
 
691
- it "uses the field-specific sort" do
692
- solr_params = subject.solr_facet_params('format_ordered')
693
- expect(solr_params[:"f.format_ordered.facet.sort"]).to eq :count
694
- end
695
-
696
624
  it 'uses sort provided in the parameters' do
697
625
  solr_params = subject.solr_facet_params(@facet_field, @sort_key => "index")
698
626
  expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to eq 'index'
699
627
  end
628
+
700
629
  it "comes up with the same params as #solr_search_params to constrain context for facet list" do
701
630
  search_params = {:q => 'tibetan history', :f=> {:format=>'Book', :language_facet=>'Tibetan'}}
702
- solr_search_params = subject.solr_search_params( search_params )
703
631
  solr_facet_params = subject.solr_facet_params('format', search_params)
704
632
 
705
- solr_search_params.each_pair do |key, value|
706
- # The specific params used for fetching the facet list we
707
- # don't care about.
708
- next if ['facets', "facet.field", 'rows', 'facet.limit', 'facet.offset', 'facet.sort'].include?(key)
709
- # Everything else should match
710
- expect(solr_facet_params[key]).to eq value
711
- end
712
-
633
+ expect(solr_facet_params).to include :"facet.field" => "format"
634
+ expect(solr_facet_params).to include :"f.format.facet.limit" => 21
635
+ expect(solr_facet_params).to include :"f.format.facet.offset" => 0
636
+ expect(solr_facet_params).to include :"rows" => 0
713
637
  end
714
638
  end
715
639
  describe "for facet limit parameters config ed" do
@@ -1079,27 +1003,35 @@ describe Blacklight::SolrHelper do
1079
1003
 
1080
1004
  describe "solr_doc_params" do
1081
1005
  it "should default to using the 'document' requestHandler" do
1082
- doc_params = subject.solr_doc_params('asdfg')
1083
- expect(doc_params[:qt]).to eq 'document'
1006
+ Deprecation.silence(Blacklight::SolrHelper) do
1007
+ doc_params = subject.solr_doc_params('asdfg')
1008
+ expect(doc_params[:qt]).to eq 'document'
1009
+ end
1084
1010
  end
1085
1011
 
1086
1012
  it "should default to using the id parameter when sending solr queries" do
1087
- doc_params = subject.solr_doc_params('asdfg')
1088
- expect(doc_params[:id]).to eq 'asdfg'
1013
+ Deprecation.silence(Blacklight::SolrHelper) do
1014
+ doc_params = subject.solr_doc_params('asdfg')
1015
+ expect(doc_params[:id]).to eq 'asdfg'
1016
+ end
1089
1017
  end
1090
1018
 
1091
1019
  it "should use the document_unique_id_param configuration" do
1092
- allow(blacklight_config).to receive_messages(document_unique_id_param: :ids)
1093
- doc_params = subject.solr_doc_params('asdfg')
1094
- expect(doc_params[:ids]).to eq 'asdfg'
1020
+ Deprecation.silence(Blacklight::SolrHelper) do
1021
+ allow(blacklight_config).to receive_messages(document_unique_id_param: :ids)
1022
+ doc_params = subject.solr_doc_params('asdfg')
1023
+ expect(doc_params[:ids]).to eq 'asdfg'
1024
+ end
1095
1025
  end
1096
1026
 
1097
1027
  describe "blacklight config's default_document_solr_parameters" do
1098
1028
  it "should use parameters from the controller's default_document_solr_parameters" do
1099
- blacklight_config.default_document_solr_params = { :qt => 'my_custom_handler', :asdf => '1234' }
1100
- doc_params = subject.solr_doc_params('asdfg')
1101
- expect(doc_params[:qt]).to eq 'my_custom_handler'
1102
- expect(doc_params[:asdf]).to eq '1234'
1029
+ Deprecation.silence(Blacklight::SolrHelper) do
1030
+ blacklight_config.default_document_solr_params = { :qt => 'my_custom_handler', :asdf => '1234' }
1031
+ doc_params = subject.solr_doc_params('asdfg')
1032
+ expect(doc_params[:qt]).to eq 'my_custom_handler'
1033
+ expect(doc_params[:asdf]).to eq '1234'
1034
+ end
1103
1035
  end
1104
1036
  end
1105
1037
 
@@ -1116,8 +1048,10 @@ describe Blacklight::SolrHelper do
1116
1048
  end
1117
1049
  =end
1118
1050
  it "should respect the configuration-supplied unique id" do
1119
- doc_params = subject.solr_doc_params('"Strong Medicine speaks"')
1120
- expect(doc_params[:id]).to eq '"Strong Medicine speaks"'
1051
+ Deprecation.silence(Blacklight::SolrHelper) do
1052
+ doc_params = subject.solr_doc_params('"Strong Medicine speaks"')
1053
+ expect(doc_params[:id]).to eq '"Strong Medicine speaks"'
1054
+ end
1121
1055
  end
1122
1056
  end
1123
1057
 
@@ -1277,18 +1211,24 @@ describe Blacklight::SolrHelper do
1277
1211
  allow(@mock_response).to receive_messages(documents: [])
1278
1212
  end
1279
1213
  it "should contruct a solr query based on the field and value pair" do
1280
- allow(subject).to receive(:find).with(hash_including(:q => "field_name:(value)")).and_return(@mock_response)
1281
- subject.get_solr_response_for_field_values('field_name', 'value')
1214
+ Deprecation.silence(Blacklight::SolrHelper) do
1215
+ allow(subject.solr_repository).to receive(:send_and_receive).with('select', hash_including("q" => "{!lucene}field_name:(value)")).and_return(@mock_response)
1216
+ subject.get_solr_response_for_field_values('field_name', 'value')
1217
+ end
1282
1218
  end
1283
1219
 
1284
1220
  it "should OR multiple values together" do
1285
- allow(subject).to receive(:find).with(hash_including(:q => "field_name:(a OR b)")).and_return(@mock_response)
1286
- subject.get_solr_response_for_field_values('field_name', ['a', 'b'])
1221
+ Deprecation.silence(Blacklight::SolrHelper) do
1222
+ allow(subject.solr_repository).to receive(:send_and_receive).with('select', hash_including("q" => "{!lucene}field_name:(a OR b)")).and_return(@mock_response)
1223
+ subject.get_solr_response_for_field_values('field_name', ['a', 'b'])
1224
+ end
1287
1225
  end
1288
1226
 
1289
1227
  it "should escape crazy identifiers" do
1290
- allow(subject).to receive(:find).with(hash_including(:q => "field_name:(\"h://\\\"\\\'\")")).and_return(@mock_response)
1291
- subject.get_solr_response_for_field_values('field_name', 'h://"\'')
1228
+ Deprecation.silence(Blacklight::SolrHelper) do
1229
+ allow(subject.solr_repository).to receive(:send_and_receive).with('select', hash_including("q" => "{!lucene}field_name:(\"h://\\\"\\\'\")")).and_return(@mock_response)
1230
+ subject.get_solr_response_for_field_values('field_name', 'h://"\'')
1231
+ end
1292
1232
  end
1293
1233
  end
1294
1234
 
@@ -1301,7 +1241,7 @@ describe Blacklight::SolrHelper do
1301
1241
  # nearby on shelf
1302
1242
  it "should raise a Blacklight exception if RSolr can't connect to the Solr instance" do
1303
1243
  allow(blacklight_solr).to receive(:send_and_receive).and_raise(Errno::ECONNREFUSED)
1304
- expect { subject.find(:a => 123) }.to raise_exception(/Unable to connect to Solr instance/)
1244
+ expect { subject.query_solr }.to raise_exception(/Unable to connect to Solr instance/)
1305
1245
  end
1306
1246
 
1307
1247
  describe "grouped_key_for_results" do