blacklight 5.5.1 → 5.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/VERSION +1 -1
  4. data/app/helpers/blacklight/blacklight_helper_behavior.rb +8 -16
  5. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
  6. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
  7. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -1
  8. data/app/helpers/blacklight/url_helper_behavior.rb +5 -1
  9. data/app/views/catalog/_view_type_group.html.erb +1 -1
  10. data/blacklight.gemspec +2 -1
  11. data/gemfiles/rails3.gemfile +1 -1
  12. data/gemfiles/rails4.1.gemfile +1 -1
  13. data/gemfiles/rails4.gemfile +1 -1
  14. data/lib/blacklight/catalog.rb +0 -1
  15. data/lib/blacklight/solr/facet_paginator.rb +22 -10
  16. data/lib/generators/blacklight/install_generator.rb +1 -1
  17. data/spec/controllers/bookmarks_controller_spec.rb +6 -6
  18. data/spec/controllers/catalog_controller_spec.rb +48 -48
  19. data/spec/features/alternate_controller_spec.rb +3 -3
  20. data/spec/features/record_view_spec.rb +1 -1
  21. data/spec/features/search_filters_spec.rb +4 -4
  22. data/spec/features/search_results_spec.rb +12 -12
  23. data/spec/helpers/blacklight_helper_spec.rb +83 -83
  24. data/spec/helpers/catalog_helper_spec.rb +37 -37
  25. data/spec/helpers/configuration_helper_spec.rb +39 -39
  26. data/spec/helpers/facets_helper_spec.rb +37 -37
  27. data/spec/helpers/render_constraints_helper_spec.rb +6 -1
  28. data/spec/helpers/search_history_constraints_helper_spec.rb +9 -9
  29. data/spec/helpers/url_helper_spec.rb +49 -39
  30. data/spec/lib/blacklight/configurable_spec.rb +5 -5
  31. data/spec/lib/blacklight/configuration_spec.rb +8 -8
  32. data/spec/lib/blacklight/facet_paginator_spec.rb +25 -0
  33. data/spec/lib/blacklight/routes_spec.rb +4 -4
  34. data/spec/lib/blacklight/search_fields_spec.rb +3 -3
  35. data/spec/lib/blacklight/solr/document_spec.rb +2 -2
  36. data/spec/lib/blacklight/solr_helper_spec.rb +37 -37
  37. data/spec/lib/blacklight/solr_response/group_response_spec.rb +1 -1
  38. data/spec/lib/blacklight/solr_response_spec.rb +31 -31
  39. data/spec/lib/document_presenter_spec.rb +41 -41
  40. data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
  41. data/spec/models/record_mailer_spec.rb +1 -1
  42. data/spec/models/search_spec.rb +1 -1
  43. data/spec/routing/catalog_routing_spec.rb +2 -2
  44. data/spec/spec_helper.rb +1 -0
  45. data/spec/support/include_text.rb +2 -3
  46. data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
  47. data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
  48. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +2 -2
  49. data/spec/views/catalog/_facets.html.erb_spec.rb +6 -6
  50. data/spec/views/catalog/_index_default.erb_spec.rb +10 -10
  51. data/spec/views/catalog/_index_header_default.html.erb_spec.rb +5 -5
  52. data/spec/views/catalog/_show_default.erb_spec.rb +10 -10
  53. data/spec/views/catalog/_show_sidebar.erb_spec.rb +5 -5
  54. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -1
  55. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +4 -4
  56. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +5 -2
  57. data/spec/views/catalog/facet.html.erb_spec.rb +5 -5
  58. data/spec/views/catalog/index.atom.builder_spec.rb +2 -2
  59. data/spec/views/catalog/index.html.erb_spec.rb +5 -5
  60. data/spec/views/catalog/show.html.erb_spec.rb +8 -8
  61. data/tasks/blacklight.rake +1 -2
  62. metadata +18 -4
@@ -11,15 +11,20 @@ describe RenderConstraintsHelper do
11
11
  before do
12
12
  # the helper methods below infer paths from the current route
13
13
  controller.request.path_parameters["controller"] = 'catalog'
14
- helper.stub(:search_action_path) do |*args|
14
+ allow(helper).to receive(:search_action_path) do |*args|
15
15
  catalog_index_path *args
16
16
  end
17
17
  end
18
18
 
19
19
  describe '#render_constraints_query' do
20
+ let(:my_engine) { double("Engine") }
20
21
  it "should have a link relative to the current url" do
21
22
  expect(helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'})).to have_selector "a[href='/?f%5Btype%5D=journal']"
22
23
  end
24
+ it "should accept an optional route set" do
25
+ expect(my_engine).to receive(:url_for).and_return('/?f%5Btype%5D=journal')
26
+ expect(helper.render_constraints_query(:q=>'foobar', :f=>{:type=>'journal'}, :route_set => my_engine)).to have_selector "a[href='/?f%5Btype%5D=journal']"
27
+ end
23
28
  end
24
29
 
25
30
  describe '#render_filter_element' do
@@ -12,14 +12,14 @@ describe SearchHistoryConstraintsHelper do
12
12
  end
13
13
 
14
14
  before(:each) do
15
- helper.stub(:blacklight_config).and_return(@config)
15
+ allow(helper).to receive(:blacklight_config).and_return(@config)
16
16
  end
17
17
 
18
18
  describe "render_search_to_s_*" do
19
19
  describe "render_search_to_s_element" do
20
20
  it "should render basic element" do
21
21
  response = helper.render_search_to_s_element("key", "value")
22
- response.should have_selector("span.constraint") do |span|
22
+ expect(response).to have_selector("span.constraint") do |span|
23
23
  expect(span).to have_selector("span.filterName", :content => "key:")
24
24
  expect(span).to have_selector("span.filterValue", :content => "value")
25
25
  end
@@ -27,14 +27,14 @@ describe SearchHistoryConstraintsHelper do
27
27
  end
28
28
  it "should escape them that need escaping" do
29
29
  response = helper.render_search_to_s_element("key>", "value>")
30
- response.should have_selector("span.constraint") do |span|
31
- span.should have_selector("span.filterName") do |s2|
30
+ expect(response).to have_selector("span.constraint") do |span|
31
+ expect(span).to have_selector("span.filterName") do |s2|
32
32
  # Note: nokogiri's gettext will unescape the inner html
33
33
  # which seems to be what rspecs "contains" method calls on
34
34
  # text nodes - thus the to_s inserted below.
35
35
  expect(s2).to match(/key>:/)
36
36
  end
37
- span.should have_selector("span.filterValue") do |s3|
37
+ expect(span).to have_selector("span.filterValue") do |s3|
38
38
  expect(s3).to match(/value>/)
39
39
  end
40
40
  end
@@ -42,7 +42,7 @@ describe SearchHistoryConstraintsHelper do
42
42
  end
43
43
  it "should not escape with options set thus" do
44
44
  response = helper.render_search_to_s_element("key>", "value>", :escape_key => false, :escape_value => false)
45
- response.should have_selector("span.constraint") do |span|
45
+ expect(response).to have_selector("span.constraint") do |span|
46
46
  expect(span).to have_selector("span.filterName", :content => "key>:")
47
47
  expect(span).to have_selector("span.filterValue", :content => "value>")
48
48
  end
@@ -55,9 +55,9 @@ describe SearchHistoryConstraintsHelper do
55
55
  @params = {:q => "history", :f => {"some_facet" => ["value1", "value1"], "other_facet" => ["other1"]}}
56
56
  end
57
57
  it "should call lesser methods" do
58
- helper.stub(:blacklight_config).and_return(@config)
59
- helper.stub(:default_search_field).and_return(Blacklight::Configuration::SearchField.new(:key => 'default_search_field', :display_label => 'Default'))
60
- helper.stub(:label_for_search_field).with(nil).and_return('')
58
+ allow(helper).to receive(:blacklight_config).and_return(@config)
59
+ allow(helper).to receive(:default_search_field).and_return(Blacklight::Configuration::SearchField.new(:key => 'default_search_field', :display_label => 'Default'))
60
+ allow(helper).to receive(:label_for_search_field).with(nil).and_return('')
61
61
  # API hooks expect this to be so
62
62
  response = helper.render_search_to_s(@params)
63
63
 
@@ -3,37 +3,36 @@ require 'spec_helper'
3
3
  describe BlacklightUrlHelper do
4
4
 
5
5
  let(:blacklight_config) do
6
- @config ||= Blacklight::Configuration.new.configure do |config|
6
+ Blacklight::Configuration.new.configure do |config|
7
7
  config.index.title_field = 'title_display'
8
8
  config.index.display_type_field = 'format'
9
9
  end
10
10
  end
11
11
 
12
- before(:each) do
13
- helper.stub(:search_action_path) do |*args|
12
+ before do
13
+ allow(helper).to receive(:search_action_path) do |*args|
14
14
  catalog_index_url *args
15
15
  end
16
16
 
17
- helper.stub(blacklight_config: blacklight_config)
18
- helper.stub(current_search_session: nil)
19
- helper.stub(:search_session).and_return({})
17
+ allow(helper).to receive_messages(blacklight_config: blacklight_config)
18
+ allow(helper).to receive_messages(current_search_session: nil)
19
+ allow(helper).to receive(:search_session).and_return({})
20
20
  end
21
21
 
22
22
  describe "url_for_document" do
23
23
  let(:controller_class) { ::CatalogController.new }
24
+ let(:doc) { SolrDocument.new }
24
25
 
25
26
  before do
26
- helper.stub(controller: controller_class)
27
- helper.stub(controller_name: controller_class.controller_name)
27
+ allow(helper).to receive_messages(controller: controller_class)
28
+ allow(helper).to receive_messages(controller_name: controller_class.controller_name)
28
29
  end
29
30
 
30
31
  it "should be a polymorphic routing-ready object" do
31
- doc = SolrDocument.new
32
32
  expect(helper.url_for_document(doc)).to eq doc
33
33
  end
34
34
 
35
35
  it "should allow for custom show routes" do
36
- doc = SolrDocument.new
37
36
  helper.blacklight_config.show.route = { controller: 'catalog' }
38
37
  expect(helper.url_for_document(doc)).to eq({controller: 'catalog', action: :show, id: doc})
39
38
  end
@@ -42,7 +41,6 @@ describe BlacklightUrlHelper do
42
41
  let(:controller_class) { ::BookmarksController.new }
43
42
 
44
43
  it "should use polymorphic routing" do
45
- doc = SolrDocument.new
46
44
  expect(helper.url_for_document(doc)).to eq doc
47
45
  end
48
46
  end
@@ -53,7 +51,6 @@ describe BlacklightUrlHelper do
53
51
  helper.blacklight_config.show.route = { controller: :current }
54
52
  end
55
53
  it "should support the :current controller configuration" do
56
- doc = SolrDocument.new
57
54
  expect(helper.url_for_document(doc)).to eq({controller: 'alternate', action: :show, id: doc})
58
55
  end
59
56
  end
@@ -61,7 +58,7 @@ describe BlacklightUrlHelper do
61
58
  it "should be a polymorphic route if the solr document responds to #to_model with a non-SolrDocument" do
62
59
  some_model = double
63
60
  doc = SolrDocument.new
64
- doc.stub(to_model: some_model)
61
+ allow(doc).to receive_messages(to_model: some_model)
65
62
  expect(helper.url_for_document(doc)).to eq doc
66
63
  end
67
64
  end
@@ -71,7 +68,7 @@ describe BlacklightUrlHelper do
71
68
  let(:bookmarks_query_params) {{ :controller=>'bookmarks'}}
72
69
 
73
70
  it "should build a link tag to catalog using session[:search] for query params" do
74
- helper.stub(:current_search_session).and_return double(:query_params => query_params)
71
+ allow(helper).to receive(:current_search_session).and_return double(:query_params => query_params)
75
72
  tag = helper.link_back_to_catalog
76
73
  expect(tag).to match /q=query/
77
74
  expect(tag).to match /f=facets/
@@ -80,7 +77,7 @@ describe BlacklightUrlHelper do
80
77
  end
81
78
 
82
79
  it "should build a link tag to bookmarks using session[:search] for query params" do
83
- helper.stub(:current_search_session).and_return double(:query_params => bookmarks_query_params)
80
+ allow(helper).to receive(:current_search_session).and_return double(:query_params => bookmarks_query_params)
84
81
  tag = helper.link_back_to_catalog
85
82
  expect(tag).to match /Back to Bookmarks/
86
83
  expect(tag).to match /\/bookmarks/
@@ -89,27 +86,40 @@ describe BlacklightUrlHelper do
89
86
  context "with a search context" do
90
87
 
91
88
  it "should use the current search session counter and per page information to construct the appropriate pagination context" do
92
- helper.stub(current_search_session: double(query_params: query_params))
93
- helper.stub(search_session: { 'per_page' => 15, 'counter' => 31 })
89
+ allow(helper).to receive_messages(current_search_session: double(query_params: query_params))
90
+ allow(helper).to receive_messages(search_session: { 'per_page' => 15, 'counter' => 31 })
94
91
  tag = helper.link_back_to_catalog
95
92
  expect(tag).to match /page=3/
96
93
  expect(tag).to match /per_page=15/
97
94
  end
98
95
 
99
96
  it "should omit per_page if the value is the same as the default" do
100
- helper.stub(current_search_session: double(query_params: query_params))
101
- helper.stub(search_session: { 'per_page' => 10, 'counter' => 31 })
97
+ allow(helper).to receive_messages(current_search_session: double(query_params: query_params))
98
+ allow(helper).to receive_messages(search_session: { 'per_page' => 10, 'counter' => 31 })
102
99
  tag = helper.link_back_to_catalog
103
100
  expect(tag).to match /page=4/
104
101
  expect(tag).to_not match /per_page=/
105
102
  end
106
103
  end
107
104
 
108
- describe "when an alternate scope is passed in" do
105
+ context "without current search context" do
106
+ before do
107
+ controller.request.assign_parameters(Rails.application.routes, 'catalog', 'show', id: '123')
108
+ allow(helper).to receive_messages(current_search_session: nil)
109
+ end
110
+
111
+ subject { helper.link_back_to_catalog }
112
+
113
+ it "should link to the catalog" do
114
+ expect(subject).to eq '<a href="/catalog">Back to Search</a>'
115
+ end
116
+ end
117
+
118
+ context "when an alternate scope is passed in" do
109
119
  let(:my_engine) { double("Engine") }
110
120
 
111
121
  it "should call url_for on the engine scope" do
112
- helper.stub(:current_search_session).and_return double(:query_params => query_params)
122
+ allow(helper).to receive(:current_search_session).and_return double(:query_params => query_params)
113
123
  expect(my_engine).to receive(:url_for).and_return(url_for(query_params))
114
124
  tag = helper.link_back_to_catalog(route_set: my_engine)
115
125
  expect(tag).to match /Back to Search/
@@ -122,28 +132,28 @@ describe BlacklightUrlHelper do
122
132
  describe "link_to_query" do
123
133
  it "should build a link tag to catalog using query string (no other params)" do
124
134
  query = "brilliant"
125
- helper.stub(params: {})
135
+ allow(helper).to receive_messages(params: {})
126
136
  tag = helper.link_to_query(query)
127
137
  expect(tag).to match /q=#{query}/
128
138
  expect(tag).to match />#{query}<\/a>/
129
139
  end
130
140
  it "should build a link tag to catalog using query string and other existing params" do
131
141
  query = "wonderful"
132
- helper.stub(params: {:qt => "title_search", :per_page => "50"})
142
+ allow(helper).to receive_messages(params: {:qt => "title_search", :per_page => "50"})
133
143
  tag = helper.link_to_query(query)
134
144
  expect(tag).to match /qt=title_search/
135
145
  expect(tag).to match /per_page=50/
136
146
  end
137
147
  it "should ignore existing :page param" do
138
148
  query = "yes"
139
- helper.stub(params: {:page => "2", :qt => "author_search"})
149
+ allow(helper).to receive_messages(params: {:page => "2", :qt => "author_search"})
140
150
  tag = helper.link_to_query(query)
141
151
  expect(tag).to match /qt=author_search/
142
152
  expect(tag).to_not match /page/
143
153
  end
144
154
  it "should be html_safe" do
145
155
  query = "brilliant"
146
- helper.stub(params: {:page => "2", :qt => "author_search"})
156
+ allow(helper).to receive_messages(params: {:page => "2", :qt => "author_search"})
147
157
  tag = helper.link_to_query(query)
148
158
  expect(tag).to be_html_safe
149
159
  end
@@ -164,7 +174,7 @@ describe BlacklightUrlHelper do
164
174
 
165
175
  describe "params_for_search" do
166
176
  before do
167
- helper.stub(params: { 'default' => 'params'})
177
+ allow(helper).to receive_messages(params: { 'default' => 'params'})
168
178
  end
169
179
 
170
180
  it "should default to using the controller's params" do
@@ -216,7 +226,7 @@ describe BlacklightUrlHelper do
216
226
  params[:d] = 'd'
217
227
  end
218
228
 
219
- result.keys.should_not include(:a, :b)
229
+ expect(result.keys).to_not include(:a, :b)
220
230
  expect(result[:c]).to eq 3
221
231
  expect(result[:d]).to eq 'd'
222
232
  end
@@ -228,14 +238,14 @@ describe BlacklightUrlHelper do
228
238
 
229
239
  describe "start_over_path" do
230
240
  it 'should be the catalog path with the current view type' do
231
- blacklight_config.stub(:view) { { list: nil, abc: nil} }
232
- helper.stub(:blacklight_config => blacklight_config)
241
+ allow(blacklight_config).to receive(:view) { { list: nil, abc: nil} }
242
+ allow(helper).to receive_messages(:blacklight_config => blacklight_config)
233
243
  expect(helper.start_over_path(:view => 'abc')).to eq catalog_index_url(:view => 'abc')
234
244
  end
235
245
 
236
246
  it 'should not include the current view type if it is the default' do
237
- blacklight_config.stub(:view) { { list: nil, asdf: nil} }
238
- helper.stub(:blacklight_config => blacklight_config)
247
+ allow(blacklight_config).to receive(:view) { { list: nil, asdf: nil} }
248
+ allow(helper).to receive_messages(:blacklight_config => blacklight_config)
239
249
  expect(helper.start_over_path(:view => 'list')).to eq catalog_index_url
240
250
  end
241
251
  end
@@ -306,7 +316,7 @@ describe BlacklightUrlHelper do
306
316
  describe "link_to_previous_search" do
307
317
  it "should link to the given search parameters" do
308
318
  params = {}
309
- helper.should_receive(:render_search_to_s).with(params).and_return "link text"
319
+ allow(helper).to receive(:render_search_to_s).with(params).and_return "link text"
310
320
  expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", helper.search_action_path)
311
321
  end
312
322
  end
@@ -318,7 +328,7 @@ describe BlacklightUrlHelper do
318
328
  end
319
329
 
320
330
  it "should add facet value for no pre-existing facets" do
321
- helper.stub(:params).and_return(@params_no_existing_facet)
331
+ allow(helper).to receive(:params).and_return(@params_no_existing_facet)
322
332
 
323
333
  result_params = helper.add_facet_params("facet_field", "facet_value")
324
334
  expect(result_params[:f]).to be_a_kind_of(Hash)
@@ -327,7 +337,7 @@ describe BlacklightUrlHelper do
327
337
  end
328
338
 
329
339
  it "should add a facet param to existing facet constraints" do
330
- helper.stub(:params).and_return(@params_existing_facets)
340
+ allow(helper).to receive(:params).and_return(@params_existing_facets)
331
341
 
332
342
  result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
333
343
 
@@ -345,7 +355,7 @@ describe BlacklightUrlHelper do
345
355
  end
346
356
  it "should leave non-facet params alone" do
347
357
  [@params_existing_facets, @params_no_existing_facet].each do |params|
348
- helper.stub(:params).and_return(params)
358
+ allow(helper).to receive(:params).and_return(params)
349
359
 
350
360
  result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
351
361
 
@@ -357,9 +367,9 @@ describe BlacklightUrlHelper do
357
367
  end
358
368
 
359
369
  it "should replace facets for facets configured as single" do
360
- helper.should_receive(:facet_configuration_for_field).with('single_value_facet_field').and_return(double(:single => true))
370
+ allow(helper).to receive(:facet_configuration_for_field).with('single_value_facet_field').and_return(double(:single => true))
361
371
  params = { :f => { 'single_value_facet_field' => 'other_value'}}
362
- helper.stub(:params).and_return params
372
+ allow(helper).to receive(:params).and_return params
363
373
 
364
374
  result_params = helper.add_facet_params('single_value_facet_field', 'my_value')
365
375
 
@@ -403,7 +413,7 @@ describe BlacklightUrlHelper do
403
413
  Blacklight::Solr::FacetPaginator.request_keys[:sort] => "index",
404
414
  :id => 'facet_field_name'
405
415
  }
406
- helper.stub(:params).and_return(catalog_facet_params)
416
+ allow(helper).to receive(:params).and_return(catalog_facet_params)
407
417
  end
408
418
  it "should not include request parameters used by the facet paginator" do
409
419
  params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
@@ -427,7 +437,7 @@ describe BlacklightUrlHelper do
427
437
 
428
438
  describe "#bookmarks_export_url" do
429
439
  it "should be the bookmark url with an encrypted user token" do
430
- helper.stub(encrypt_user_id: 'xyz', current_or_guest_user: double(id: 123))
440
+ allow(helper).to receive_messages(encrypt_user_id: 'xyz', current_or_guest_user: double(id: 123))
431
441
  url = helper.bookmarks_export_url(:html)
432
442
  expect(url).to eq helper.bookmarks_url(format: :html, encrypted_user_id: 'xyz')
433
443
  end
@@ -18,17 +18,17 @@ describe "Blacklight::Configurable" do
18
18
  end
19
19
  end
20
20
  it "should inherit the configuration when subclassed" do
21
- TestCaseInheritence::Child.blacklight_config.list.should include(1,2,3)
21
+ expect(TestCaseInheritence::Child.blacklight_config.list).to include(1,2,3)
22
22
  end
23
23
 
24
24
  it "inherited version should be a deep copy, not original" do
25
- TestCaseInheritence::Child.blacklight_config.should_not be(TestCaseInheritence::Parent.blacklight_config)
25
+ expect(TestCaseInheritence::Child.blacklight_config).to_not be(TestCaseInheritence::Parent.blacklight_config)
26
26
 
27
27
  TestCaseInheritence::Child.blacklight_config.list << "child_only"
28
28
 
29
29
 
30
- TestCaseInheritence::Child.blacklight_config.list.should include("child_only")
31
- TestCaseInheritence::Parent.blacklight_config.list.should_not include("child_only")
30
+ expect(TestCaseInheritence::Child.blacklight_config.list).to include("child_only")
31
+ expect(TestCaseInheritence::Parent.blacklight_config.list).to_not include("child_only")
32
32
  end
33
33
  end
34
34
 
@@ -45,7 +45,7 @@ describe "Blacklight::Configurable" do
45
45
  a = Class.new
46
46
  a.send(:include, Blacklight::Configurable)
47
47
 
48
- a.blacklight_config.default_solr_params.should be_empty
48
+ expect(a.blacklight_config.default_solr_params).to be_empty
49
49
  end
50
50
 
51
51
  it "should allow the user to provide a default configuration" do
@@ -15,7 +15,7 @@ describe "Blacklight::Configuration" do
15
15
 
16
16
  describe "initialization" do
17
17
  it "should be an OpenStructWithHashAccess" do
18
- @config.should be_a_kind_of Blacklight::OpenStructWithHashAccess
18
+ expect(@config).to be_a_kind_of Blacklight::OpenStructWithHashAccess
19
19
  end
20
20
 
21
21
  it "should accept a block for configuration" do
@@ -119,7 +119,7 @@ describe "Blacklight::Configuration" do
119
119
 
120
120
  expect(@config.facet_fields["format"]).to_not be_nil
121
121
  expect(@config.facet_fields["format"]["label"]).to eq "Format"
122
- expect(@config.facet_fields["format"]["limit"]).to be_true
122
+ expect(@config.facet_fields["format"]["limit"]).to be true
123
123
  end
124
124
 
125
125
  it "should accept FacetField obj arg" do
@@ -136,7 +136,7 @@ describe "Blacklight::Configuration" do
136
136
  end
137
137
 
138
138
  expect(@config.facet_fields["format"]).to_not be_nil
139
- expect(@config.facet_fields["format"].limit).to be_true
139
+ expect(@config.facet_fields["format"].limit).to be true
140
140
  end
141
141
 
142
142
  it "should accept block form" do
@@ -175,7 +175,7 @@ describe "Blacklight::Configuration" do
175
175
  it "should allow you to not show the facet in the facet bar" do
176
176
  @config.add_facet_field("publication_date", :show=>false)
177
177
 
178
- expect(@config.facet_fields["publication_date"]['show']).to be_false
178
+ expect(@config.facet_fields["publication_date"]['show']).to be false
179
179
  end
180
180
 
181
181
  it "should raise on nil solr field name" do
@@ -183,7 +183,7 @@ describe "Blacklight::Configuration" do
183
183
  end
184
184
 
185
185
  it "should take wild-carded field names and dereference them to solr fields" do
186
- @config.stub(luke_fields: {
186
+ allow(@config).to receive_messages(luke_fields: {
187
187
  "some_field_facet" => {},
188
188
  "another_field_facet" => {},
189
189
  "a_facet_field" => {},
@@ -227,7 +227,7 @@ describe "Blacklight::Configuration" do
227
227
  end
228
228
 
229
229
  it "should take wild-carded field names and dereference them to solr fields" do
230
- @config.stub(luke_fields: {
230
+ allow(@config).to receive_messages(luke_fields: {
231
231
  "some_field_display" => {},
232
232
  "another_field_display" => {},
233
233
  "a_facet_field" => {},
@@ -272,7 +272,7 @@ describe "Blacklight::Configuration" do
272
272
  end
273
273
 
274
274
  it "should take wild-carded field names and dereference them to solr fields" do
275
- @config.stub(luke_fields: {
275
+ allow(@config).to receive_messages(luke_fields: {
276
276
  "some_field_display" => {},
277
277
  "another_field_display" => {},
278
278
  "a_facet_field" => {},
@@ -289,7 +289,7 @@ describe "Blacklight::Configuration" do
289
289
  it "should accept hash form" do
290
290
  c = Blacklight::Configuration.new
291
291
  c.add_search_field(:key => "my_search_key")
292
- c.search_fields["my_search_key"].should_not be_nil
292
+ expect(c.search_fields["my_search_key"]).to_not be_nil
293
293
  end
294
294
 
295
295
  it "should accept two-arg hash form" do
@@ -37,6 +37,18 @@ describe 'Blacklight::Solr::FacetPaginator' do
37
37
  end
38
38
  end
39
39
 
40
+ context 'on the second page of three pages' do
41
+ subject { Blacklight::Solr::FacetPaginator.new(seven_facet_values, offset: 6, limit: limit) }
42
+ it { should_not be_first_page }
43
+ it { should_not be_last_page }
44
+ its(:current_page) { should eq 2 }
45
+ its(:prev_page) { should eq 1 }
46
+ its(:next_page) { should eq 3 }
47
+ it 'should limit items to limit, if limit is smaller than items.length' do
48
+ expect(subject.items.size).to eq 6
49
+ end
50
+ end
51
+
40
52
  context 'on the first page of one page' do
41
53
  subject { Blacklight::Solr::FacetPaginator.new(six_facet_values, offset: 0, limit: limit) }
42
54
  it { should be_first_page }
@@ -65,4 +77,17 @@ describe 'Blacklight::Solr::FacetPaginator' do
65
77
  end
66
78
  end
67
79
 
80
+ describe "#as_json" do
81
+ subject { Blacklight::Solr::FacetPaginator.new([f1], offset: 0, limit: nil).as_json }
82
+ it "should be well structured" do
83
+ expect(subject).to eq("items" => [{"hits"=>"792", "value"=>"Book"}], "limit" => 0,
84
+ "offset" => 0, "sort" => "count")
85
+ end
86
+ end
87
+
88
+ describe "#total_pages" do
89
+ # this method is just for API compatability with kaminari 0.16.1
90
+ subject { Blacklight::Solr::FacetPaginator.new([f1], offset: 0, limit: nil).total_pages }
91
+ it { should eq -1 }
92
+ end
68
93
  end