blacklight 6.2.0 → 6.3.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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.solr_wrapper +5 -0
  4. data/.travis.yml +3 -5
  5. data/Gemfile +3 -3
  6. data/VERSION +1 -1
  7. data/app/assets/javascripts/blacklight/core.js +19 -5
  8. data/app/helpers/blacklight/blacklight_helper_behavior.rb +48 -20
  9. data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -1
  10. data/app/helpers/blacklight/url_helper_behavior.rb +2 -1
  11. data/app/presenters/blacklight/document_presenter.rb +58 -150
  12. data/app/presenters/blacklight/field_presenter.rb +31 -0
  13. data/app/presenters/blacklight/index_presenter.rb +69 -0
  14. data/app/presenters/blacklight/link_alternate_presenter.rb +29 -0
  15. data/app/presenters/blacklight/rendering/abstract_step.rb +24 -0
  16. data/app/presenters/blacklight/rendering/helper_method.rb +23 -0
  17. data/app/presenters/blacklight/rendering/join.rb +16 -0
  18. data/app/presenters/blacklight/rendering/link_to_facet.rb +35 -0
  19. data/app/presenters/blacklight/rendering/microdata.rb +17 -0
  20. data/app/presenters/blacklight/rendering/pipeline.rb +32 -0
  21. data/app/presenters/blacklight/rendering/terminator.rb +9 -0
  22. data/app/presenters/blacklight/show_presenter.rb +93 -0
  23. data/app/services/blacklight/field_retriever.rb +58 -0
  24. data/app/views/catalog/_document_default.atom.builder +2 -3
  25. data/app/views/catalog/_document_default.rss.builder +2 -2
  26. data/app/views/kaminari/blacklight/_next_page.html.erb +9 -3
  27. data/app/views/kaminari/blacklight/_prev_page.html.erb +10 -3
  28. data/lib/blacklight/configuration.rb +15 -3
  29. data/lib/blacklight/configuration/null_field.rb +13 -0
  30. data/lib/blacklight/configuration/view_config.rb +6 -0
  31. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -1
  32. data/lib/generators/blacklight/templates/config/blacklight.yml +1 -1
  33. data/lib/generators/blacklight/templates/config/jetty.yml +1 -1
  34. data/spec/controllers/alternate_controller_spec.rb +2 -2
  35. data/spec/controllers/application_controller_spec.rb +1 -1
  36. data/spec/controllers/blacklight/facet_spec.rb +3 -3
  37. data/spec/controllers/blacklight/search_fields_spec.rb +7 -7
  38. data/spec/controllers/blacklight/search_helper_spec.rb +44 -44
  39. data/spec/controllers/blacklight/suggest_search_spec.rb +1 -1
  40. data/spec/controllers/bookmarks_controller_spec.rb +6 -6
  41. data/spec/controllers/catalog_controller_spec.rb +125 -125
  42. data/spec/controllers/saved_searches_controller_spec.rb +4 -9
  43. data/spec/controllers/search_history_controller_spec.rb +3 -6
  44. data/spec/controllers/suggest_controller_spec.rb +2 -2
  45. data/spec/features/alternate_controller_spec.rb +3 -3
  46. data/spec/features/bookmarks_spec.rb +6 -6
  47. data/spec/features/did_you_mean_spec.rb +10 -10
  48. data/spec/features/facets_spec.rb +4 -4
  49. data/spec/features/record_view_spec.rb +4 -4
  50. data/spec/features/saved_searches_spec.rb +4 -4
  51. data/spec/features/search_context_spec.rb +4 -4
  52. data/spec/features/search_filters_spec.rb +10 -10
  53. data/spec/features/search_formats_spec.rb +2 -2
  54. data/spec/features/search_history_spec.rb +5 -5
  55. data/spec/features/search_pagination_spec.rb +4 -4
  56. data/spec/features/search_results_spec.rb +7 -7
  57. data/spec/features/search_sort_spec.rb +2 -2
  58. data/spec/features/search_spec.rb +6 -6
  59. data/spec/helpers/blacklight_helper_spec.rb +105 -65
  60. data/spec/helpers/catalog_helper_spec.rb +36 -36
  61. data/spec/helpers/configuration_helper_spec.rb +28 -28
  62. data/spec/helpers/facets_helper_spec.rb +39 -39
  63. data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -1
  64. data/spec/helpers/render_constraints_helper_spec.rb +1 -1
  65. data/spec/helpers/search_history_constraints_helper_spec.rb +7 -7
  66. data/spec/helpers/url_helper_spec.rb +20 -17
  67. data/spec/lib/blacklight/search_state_spec.rb +2 -2
  68. data/spec/lib/blacklight/utils_spec.rb +15 -15
  69. data/spec/lib/blacklight_spec.rb +1 -1
  70. data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
  71. data/spec/models/blacklight/configurable_spec.rb +3 -3
  72. data/spec/models/blacklight/configuration_spec.rb +52 -52
  73. data/spec/models/blacklight/document_spec.rb +10 -10
  74. data/spec/models/blacklight/facet_paginator_spec.rb +5 -5
  75. data/spec/models/blacklight/search_builder_spec.rb +34 -34
  76. data/spec/models/blacklight/user_spec.rb +4 -4
  77. data/spec/models/bookmark_spec.rb +5 -5
  78. data/spec/models/record_mailer_spec.rb +11 -11
  79. data/spec/models/search_spec.rb +1 -1
  80. data/spec/models/solr_document_spec.rb +4 -4
  81. data/spec/presenters/document_presenter_spec.rb +94 -50
  82. data/spec/presenters/index_presenter_spec.rb +147 -0
  83. data/spec/presenters/pipeline_spec.rb +28 -0
  84. data/spec/presenters/show_presenter_spec.rb +287 -0
  85. data/spec/routing/catalog_routing_spec.rb +11 -11
  86. data/spec/spec_helper.rb +10 -1
  87. data/spec/support/backport_test.rb +38 -0
  88. data/spec/test_app_templates/Gemfile.extra +2 -10
  89. data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
  90. data/spec/views/catalog/_constraints.html.erb_spec.rb +3 -3
  91. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +5 -5
  92. data/spec/views/catalog/_document.html.erb_spec.rb +2 -2
  93. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
  94. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +4 -4
  95. data/spec/views/catalog/_facets.html.erb_spec.rb +4 -4
  96. data/spec/views/catalog/_index_default.erb_spec.rb +5 -4
  97. data/spec/views/catalog/_index_header_default.html.erb_spec.rb +4 -3
  98. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +3 -3
  99. data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
  100. data/spec/views/catalog/_show_default.erb_spec.rb +6 -5
  101. data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -1
  102. data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
  103. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
  104. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -2
  105. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
  106. data/spec/views/catalog/facet.html.erb_spec.rb +3 -3
  107. data/spec/views/catalog/index.atom.builder_spec.rb +15 -14
  108. data/spec/views/catalog/index.html.erb_spec.rb +3 -3
  109. data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -1
  110. data/spec/views/catalog/show.html.erb_spec.rb +5 -4
  111. data/tasks/blacklight.rake +1 -1
  112. metadata +25 -4
  113. data/config/jetty.yml +0 -13
@@ -49,7 +49,7 @@ describe CatalogHelper do
49
49
  end
50
50
 
51
51
  describe "with a single result" do
52
- it "should use the provided entry name" do
52
+ it "uses the provided entry name" do
53
53
  response = mock_response :total => 1
54
54
 
55
55
  html = page_entries_info(response, { :entry_name => 'entry_name' })
@@ -57,7 +57,7 @@ describe CatalogHelper do
57
57
  expect(html).to be_html_safe
58
58
  end
59
59
 
60
- it "should infer a name" do
60
+ it "infers a name" do
61
61
  response = mock_response :total => 1
62
62
 
63
63
  html = page_entries_info(response)
@@ -65,7 +65,7 @@ describe CatalogHelper do
65
65
  expect(html).to be_html_safe
66
66
  end
67
67
 
68
- it "should use the model_name from the response" do
68
+ it "uses the model_name from the response" do
69
69
  response = mock_response :total => 1
70
70
  allow(response).to receive(:model_name).and_return(double(:human => 'thingy'))
71
71
 
@@ -106,7 +106,7 @@ describe CatalogHelper do
106
106
  expect(html).to eq "<strong>41</strong> - <strong>47</strong> of <strong>47</strong>"
107
107
  expect(html).to be_html_safe
108
108
  end
109
- it "should work with rows the same as per_page" do
109
+ it "works with rows the same as per_page" do
110
110
  @response = mock_response :total => 47, :rows => 20, :current_page => 2
111
111
 
112
112
  html = page_entries_info(@response, { :entry_name => 'entry_name' })
@@ -131,47 +131,47 @@ describe CatalogHelper do
131
131
  end
132
132
 
133
133
  describe "should_autofocus_on_search_box?" do
134
- it "should be focused if we're on a catalog-like index page without query or facet parameters" do
134
+ it "is focused if we're on a catalog-like index page without query or facet parameters" do
135
135
  allow(helper).to receive_messages(controller: CatalogController.new, action_name: "index", has_search_parameters?: false)
136
136
  expect(helper.should_autofocus_on_search_box?).to be true
137
137
  end
138
138
 
139
- it "should not be focused if we're not on a catalog controller" do
139
+ it "does not be focused if we're not on a catalog controller" do
140
140
  allow(helper).to receive_messages(controller: ApplicationController.new)
141
141
  expect(helper.should_autofocus_on_search_box?).to be false
142
142
  end
143
143
 
144
- it "should not be focused if we're not on a catalog controller index" do
144
+ it "does not be focused if we're not on a catalog controller index" do
145
145
  allow(helper).to receive_messages(controller: CatalogController.new, action_name: "show")
146
146
  expect(helper.should_autofocus_on_search_box?).to be false
147
147
  end
148
148
 
149
- it "should not be focused if a search parameters are provided" do
149
+ it "does not be focused if a search parameters are provided" do
150
150
  allow(helper).to receive_messages(controller: CatalogController.new, action_name: "index", has_search_parameters?: true)
151
151
  expect(helper.should_autofocus_on_search_box?).to be false
152
152
  end
153
153
  end
154
154
 
155
155
  describe "has_thumbnail?" do
156
- it "should have a thumbnail if a thumbnail_method is configured" do
156
+ it "has a thumbnail if a thumbnail_method is configured" do
157
157
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
158
158
  document = double()
159
159
  expect(helper.has_thumbnail? document).to be true
160
160
  end
161
161
 
162
- it "should have a thumbnail if a thumbnail_field is configured and it exists in the document" do
162
+ it "has a thumbnail if a thumbnail_field is configured and it exists in the document" do
163
163
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
164
164
  document = double(:has? => true)
165
165
  expect(helper.has_thumbnail? document).to be true
166
166
  end
167
167
 
168
- it "should not have a thumbnail if the thumbnail_field is missing from the document" do
168
+ it "does not have a thumbnail if the thumbnail_field is missing from the document" do
169
169
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
170
170
  document = double(:has? => false)
171
171
  expect(helper.has_thumbnail? document).to be false
172
172
  end
173
173
 
174
- it "should not have a thumbnail if none of the fields are configured" do
174
+ it "does not have a thumbnail if none of the fields are configured" do
175
175
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new() ))
176
176
  expect(helper.has_thumbnail? double()).to be_falsey
177
177
  end
@@ -179,25 +179,25 @@ describe CatalogHelper do
179
179
 
180
180
  describe "render_thumbnail_tag" do
181
181
  let(:document) { double }
182
- it "should call the provided thumbnail method" do
182
+ it "calls the provided thumbnail method" do
183
183
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
184
- allow(helper).to receive_messages(:xyz => "some-thumbnail")
184
+ expect(helper).to receive_messages(:xyz => "some-thumbnail")
185
185
 
186
186
  allow(helper).to receive(:link_to_document).with(document, "some-thumbnail", {})
187
187
  helper.render_thumbnail_tag document
188
188
  end
189
189
 
190
- it "should create an image tag from the given field" do
190
+ it "creates an image tag from the given field" do
191
191
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
192
192
 
193
193
  allow(document).to receive(:has?).with(:xyz).and_return(true)
194
194
  allow(document).to receive(:first).with(:xyz).and_return("http://example.com/some.jpg")
195
195
 
196
- allow(helper).to receive(:link_to_document).with(document, image_tag("http://example.com/some.jpg"), {})
196
+ expect(helper).to receive(:link_to_document).with(document, image_tag("http://example.com/some.jpg"), {})
197
197
  helper.render_thumbnail_tag document
198
198
  end
199
199
 
200
- it "should not link to the document if the url options are false" do
200
+ it "does not link to the document if the url options are false" do
201
201
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
202
202
  allow(helper).to receive_messages(:xyz => "some-thumbnail")
203
203
 
@@ -205,7 +205,7 @@ describe CatalogHelper do
205
205
  expect(result).to eq "some-thumbnail"
206
206
  end
207
207
 
208
- it "should not link to the document if the url options have :suppress_link" do
208
+ it "does not link to the document if the url options have :suppress_link" do
209
209
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
210
210
  allow(helper).to receive_messages(:xyz => "some-thumbnail")
211
211
 
@@ -214,19 +214,19 @@ describe CatalogHelper do
214
214
  end
215
215
 
216
216
 
217
- it "should return nil if no thumbnail is available" do
217
+ it "returns nil if no thumbnail is available" do
218
218
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new() ))
219
219
  expect(helper.render_thumbnail_tag document).to be_nil
220
220
  end
221
221
 
222
- it "should return nil if no thumbnail is returned from the thumbnail method" do
222
+ it "returns nil if no thumbnail is returned from the thumbnail method" do
223
223
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_method => :xyz) ))
224
224
  allow(helper).to receive_messages(:xyz => nil)
225
225
 
226
226
  expect(helper.render_thumbnail_tag document).to be_nil
227
227
  end
228
228
 
229
- it "should return nil if no thumbnail is in the document" do
229
+ it "returns nil if no thumbnail is in the document" do
230
230
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
231
231
 
232
232
  allow(document).to receive(:has?).with(:xyz).and_return(false)
@@ -236,7 +236,7 @@ describe CatalogHelper do
236
236
  end
237
237
 
238
238
  describe "thumbnail_url" do
239
- it "should pull the configured thumbnail field out of the document" do
239
+ it "pulls the configured thumbnail field out of the document" do
240
240
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
241
241
  document = double()
242
242
  allow(document).to receive(:has?).with(:xyz).and_return(true)
@@ -244,7 +244,7 @@ describe CatalogHelper do
244
244
  expect(helper.thumbnail_url document).to eq("asdf")
245
245
  end
246
246
 
247
- it "should return nil if the thumbnail field doesn't exist" do
247
+ it "returns nil if the thumbnail field doesn't exist" do
248
248
  allow(helper).to receive_messages(:blacklight_config => Blacklight::Configuration.new(:index => Blacklight::OpenStructWithHashAccess.new(:thumbnail_field => :xyz) ))
249
249
  document = double()
250
250
  allow(document).to receive(:has?).with(:xyz).and_return(false)
@@ -253,19 +253,19 @@ describe CatalogHelper do
253
253
  end
254
254
 
255
255
  describe "document_counter_with_offset" do
256
- it "should render the document index with the appropriate offset" do
256
+ it "renders the document index with the appropriate offset" do
257
257
  assign(:response, double(start: 0, grouped?: false))
258
258
  expect(helper.document_counter_with_offset(0)).to be(1)
259
259
  expect(helper.document_counter_with_offset(1)).to be(2)
260
260
  end
261
261
 
262
- it "should render the document index with the appropriate offset" do
262
+ it "renders the document index with the appropriate offset" do
263
263
  assign(:response, double(start: 10, grouped?: false))
264
264
  expect(helper.document_counter_with_offset(0)).to be(11)
265
265
  expect(helper.document_counter_with_offset(1)).to be(12)
266
266
  end
267
267
 
268
- it "should not provide a counter for grouped responses" do
268
+ it "does not provide a counter for grouped responses" do
269
269
  assign(:response, double(start: 10, grouped?: true))
270
270
  expect(helper.document_counter_with_offset(0)).to be_nil
271
271
  end
@@ -280,31 +280,31 @@ describe CatalogHelper do
280
280
  Blacklight::Configuration.new
281
281
  end
282
282
 
283
- it "should pull data out of a document's field" do
283
+ it "pulls data out of a document's field" do
284
284
  blacklight_config.index.display_type_field = :type
285
285
  doc = { :type => 'book' }
286
286
  expect(helper.render_document_class(doc)).to eq "blacklight-book"
287
287
  end
288
288
 
289
- it "should support multivalued fields" do
289
+ it "supports multivalued fields" do
290
290
  blacklight_config.index.display_type_field = :type
291
291
  doc = { :type => ['book', 'mss'] }
292
292
  expect(helper.render_document_class(doc)).to eq "blacklight-book blacklight-mss"
293
293
  end
294
294
 
295
- it "should support empty fields" do
295
+ it "supports empty fields" do
296
296
  blacklight_config.index.display_type_field = :type
297
297
  doc = { :type => [] }
298
298
  expect(helper.render_document_class(doc)).to be_blank
299
299
  end
300
300
 
301
- it "should support missing fields" do
301
+ it "supports missing fields" do
302
302
  blacklight_config.index.display_type_field = :type
303
303
  doc = { }
304
304
  expect(helper.render_document_class(doc)).to be_blank
305
305
  end
306
306
 
307
- it "should support view-specific field configuration" do
307
+ it "supports view-specific field configuration" do
308
308
  allow(helper).to receive(:document_index_view_type).and_return(:some_view_type)
309
309
  blacklight_config.view.some_view_type.display_type_field = :other_type
310
310
  doc = { other_type: "document"}
@@ -321,11 +321,11 @@ describe CatalogHelper do
321
321
  allow(helper).to receive(:current_bookmarks).and_return([bookmark])
322
322
  end
323
323
 
324
- it "should be bookmarked if the document is in the bookmarks" do
324
+ it "is bookmarked if the document is in the bookmarks" do
325
325
  expect(helper.bookmarked?(bookmarked_document)).to eq true
326
326
  end
327
327
 
328
- it "should not be bookmarked if the document is not listed in the bookmarks" do
328
+ it "does not be bookmarked if the document is not listed in the bookmarks" do
329
329
  expect(helper.bookmarked?(SolrDocument.new(id: 'b'))).to eq false
330
330
  end
331
331
  end
@@ -339,15 +339,15 @@ describe CatalogHelper do
339
339
  Blacklight::Configuration.new
340
340
  end
341
341
 
342
- it "should render a facet with a single value" do
342
+ it "renders a facet with a single value" do
343
343
  expect(helper.render_search_to_page_title_filter('foo', ['bar'])).to eq "Foo: bar"
344
344
  end
345
345
 
346
- it "should render a facet with two values" do
346
+ it "renders a facet with two values" do
347
347
  expect(helper.render_search_to_page_title_filter('foo', ['bar', 'baz'])).to eq "Foo: bar and baz"
348
348
  end
349
349
 
350
- it "should render a facet with more than two values" do
350
+ it "renders a facet with more than two values" do
351
351
  expect(helper.render_search_to_page_title_filter('foo', ['bar', 'baz', 'foobar'])).to eq "Foo: 3 selected"
352
352
  end
353
353
  end
@@ -10,42 +10,42 @@ describe BlacklightConfigurationHelper do
10
10
  end
11
11
 
12
12
  describe "#index_fields" do
13
- it "should pass through the configuration" do
13
+ it "passes through the configuration" do
14
14
  allow(blacklight_config).to receive_messages(index_fields: config_value)
15
15
  expect(helper.index_fields).to eq config_value
16
16
  end
17
17
  end
18
18
 
19
19
  describe "#sort_fields" do
20
- it "should convert the sort fields to select-ready values" do
20
+ it "converts the sort fields to select-ready values" do
21
21
  allow(blacklight_config).to receive_messages(sort_fields: { 'a' => double(key: 'a', label: 'a'), 'b' => double(key: 'b', label: 'b'), c: double(key: 'c', if: false) })
22
22
  expect(helper.sort_fields).to eq [['a', 'a'], ['b', 'b']]
23
23
  end
24
24
  end
25
25
 
26
26
  describe "#active_sort_fields" do
27
- it "should restrict the configured sort fields to only those that should be displayed" do
27
+ it "restricts the configured sort fields to only those that should be displayed" do
28
28
  allow(blacklight_config).to receive_messages(sort_fields: { a: double(if: false, unless: false), b: double(if:true, unless: true) })
29
29
  expect(helper.active_sort_fields).to be_empty
30
30
  end
31
31
  end
32
32
 
33
33
  describe "#document_show_fields" do
34
- it "should pass through the configuration" do
34
+ it "passes through the configuration" do
35
35
  allow(blacklight_config).to receive_messages(show_fields: config_value)
36
36
  expect(helper.document_show_fields).to eq config_value
37
37
  end
38
38
  end
39
39
 
40
40
  describe "#default_document_index_view_type" do
41
- it "should use the first view with default set to true" do
41
+ it "uses the first view with default set to true" do
42
42
  blacklight_config.view.a
43
43
  blacklight_config.view.b
44
44
  blacklight_config.view.b.default = true
45
45
  expect(helper.default_document_index_view_type).to eq :b
46
46
  end
47
47
 
48
- it "should default to the first configured index view" do
48
+ it "defaults to the first configured index view" do
49
49
  allow(blacklight_config).to receive_messages(view: { a: true, b: true})
50
50
  expect(helper.default_document_index_view_type).to eq :a
51
51
  end
@@ -58,7 +58,7 @@ describe BlacklightConfigurationHelper do
58
58
  blacklight_config.view.xyz.unless = true
59
59
  end
60
60
 
61
- it "should filter views using :if/:unless configuration" do
61
+ it "filters views using :if/:unless configuration" do
62
62
  expect(helper.document_index_views).to have_key :list
63
63
  expect(helper.document_index_views).to_not have_key :abc
64
64
  expect(helper.document_index_views).to_not have_key :def
@@ -83,7 +83,7 @@ describe BlacklightConfigurationHelper do
83
83
  end
84
84
 
85
85
  describe "#spell_check_max" do
86
- it "should pass through the configuration" do
86
+ it "passes through the configuration" do
87
87
  allow(blacklight_config).to receive_messages(spell_max: config_value)
88
88
  expect(helper.spell_check_max).to eq config_value
89
89
  end
@@ -92,19 +92,19 @@ describe BlacklightConfigurationHelper do
92
92
  describe "#document_show_link_field" do
93
93
  let(:document) { SolrDocument.new id: 123, a: 1, b: 2, c: 3 }
94
94
 
95
- it "should allow single values" do
95
+ it "allows single values" do
96
96
  blacklight_config.index.title_field = :a
97
97
  f = helper.document_show_link_field document
98
98
  expect(f).to eq :a
99
99
  end
100
100
 
101
- it "should retrieve the first field with data" do
101
+ it "retrieves the first field with data" do
102
102
  blacklight_config.index.title_field = [:zzz, :b]
103
103
  f = helper.document_show_link_field document
104
104
  expect(f).to eq :b
105
105
  end
106
106
 
107
- it "should fallback on the id" do
107
+ it "fallbacks on the id" do
108
108
  blacklight_config.index.title_field = [:zzz, :yyy]
109
109
  f = helper.document_show_link_field document
110
110
  expect(f).to eq 123
@@ -113,7 +113,7 @@ describe BlacklightConfigurationHelper do
113
113
 
114
114
  describe "#index_field_label" do
115
115
  let(:document) { double }
116
- it "should look up the label to display for the given document and field" do
116
+ it "looks up the label to display for the given document and field" do
117
117
  allow(helper).to receive(:index_fields).and_return({ "my_field" => double(label: "some label") })
118
118
  allow(helper).to receive(:field_label).with(:"blacklight.search.fields.index.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
119
119
  helper.index_field_label document, "my_field"
@@ -122,7 +122,7 @@ describe BlacklightConfigurationHelper do
122
122
 
123
123
  describe "#document_show_field_label" do
124
124
  let(:document) { double }
125
- it "should look up the label to display for the given document and field" do
125
+ it "looks up the label to display for the given document and field" do
126
126
  allow(helper).to receive(:document_show_fields).and_return({ "my_field" => double(label: "some label") })
127
127
  allow(helper).to receive(:field_label).with(:"blacklight.search.fields.show.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
128
128
  helper.document_show_field_label document, "my_field"
@@ -131,7 +131,7 @@ describe BlacklightConfigurationHelper do
131
131
 
132
132
  describe "#facet_field_label" do
133
133
  let(:document) { double }
134
- it "should look up the label to display for the given document and field" do
134
+ it "looks up the label to display for the given document and field" do
135
135
  allow(blacklight_config).to receive(:facet_fields).and_return({ "my_field" => double(label: "some label") })
136
136
  allow(helper).to receive(:field_label).with(:"blacklight.search.fields.facet.my_field", :"blacklight.search.fields.my_field", "some label", "My field")
137
137
  helper.facet_field_label "my_field"
@@ -139,7 +139,7 @@ describe BlacklightConfigurationHelper do
139
139
  end
140
140
 
141
141
  describe "#view_label" do
142
- it "should look up the label to display for the view" do
142
+ it "looks up the label to display for the view" do
143
143
  allow(blacklight_config).to receive(:view).and_return({ "my_view" => double(label: "some label", title: nil) })
144
144
  allow(helper).to receive(:field_label).with(:"blacklight.search.view_title.my_view", :"blacklight.search.view.my_view", "some label", nil, "My view")
145
145
 
@@ -148,20 +148,20 @@ describe BlacklightConfigurationHelper do
148
148
  end
149
149
 
150
150
  describe "#field_label" do
151
- it "should look up the label as an i18n string" do
151
+ it "looks up the label as an i18n string" do
152
152
  allow(helper).to receive(:t).with(:some_key, default: []).and_return "my label"
153
153
  label = helper.field_label :some_key
154
154
 
155
155
  expect(label).to eq "my label"
156
156
  end
157
157
 
158
- it "should pass the provided i18n keys to I18n.t" do
158
+ it "passes the provided i18n keys to I18n.t" do
159
159
  allow(helper).to receive(:t).with(:key_a, default: [:key_b, "default text"])
160
160
 
161
161
  label = helper.field_label :key_a, :key_b, "default text"
162
162
  end
163
163
 
164
- it "should compact nil keys (fixes rails/rails#19419)" do
164
+ it "compacts nil keys (fixes rails/rails#19419)" do
165
165
  allow(helper).to receive(:t).with(:key_a, default: [:key_b])
166
166
 
167
167
  label = helper.field_label :key_a, nil, :key_b
@@ -170,31 +170,31 @@ describe BlacklightConfigurationHelper do
170
170
  end
171
171
 
172
172
  describe "#default_per_page" do
173
- it "should be the configured default per page" do
173
+ it "is the configured default per page" do
174
174
  allow(helper).to receive_messages(blacklight_config: double(default_per_page: 42))
175
175
  expect(helper.default_per_page).to eq 42
176
176
  end
177
177
 
178
- it "should be the first per-page value if a default isn't set" do
178
+ it "is the first per-page value if a default isn't set" do
179
179
  allow(helper).to receive_messages(blacklight_config: double(default_per_page: nil, per_page: [11, 22]))
180
180
  expect(helper.default_per_page).to eq 11
181
181
  end
182
182
  end
183
183
 
184
184
  describe "#default_sort_field" do
185
- it "should be the configured default field" do
185
+ it "is the configured default field" do
186
186
  allow(helper).to receive_messages(blacklight_config: double(sort_fields: { a: double(default: nil), b: double(key: 'b', default: true) }))
187
187
  expect(helper.default_sort_field.key).to eq 'b'
188
188
  end
189
189
 
190
- it "should be the first per-page value if a default isn't set" do
190
+ it "is the first per-page value if a default isn't set" do
191
191
  allow(helper).to receive_messages(blacklight_config: double(sort_fields: { a: double(key: 'a', default: nil), b: double(key: 'b', default: nil) }))
192
192
  expect(helper.default_sort_field.key).to eq 'a'
193
193
  end
194
194
  end
195
195
 
196
196
  describe "#per_page_options_for_select" do
197
- it "should be the per-page values formatted as options_for_select" do
197
+ it "is the per-page values formatted as options_for_select" do
198
198
  allow(helper).to receive_messages(blacklight_config: double(per_page: [11, 22, 33]))
199
199
  expect(helper.per_page_options_for_select).to include ["11<span class=\"sr-only\"> per page</span>", 11]
200
200
  expect(helper.per_page_options_for_select).to include ["22<span class=\"sr-only\"> per page</span>", 22]
@@ -209,16 +209,16 @@ describe BlacklightConfigurationHelper do
209
209
  allow(helper).to receive_messages(document_has_value?: true)
210
210
  end
211
211
 
212
- it "should be true" do
212
+ it "is true" do
213
213
  expect(helper.should_render_field?(field_config)).to be true
214
214
  end
215
215
 
216
- it "should be false if the :if condition is false" do
216
+ it "is false if the :if condition is false" do
217
217
  allow(field_config).to receive_messages(if: false)
218
218
  expect(helper.should_render_field?(field_config)).to be false
219
219
  end
220
220
 
221
- it "should be false if the :unless condition is true" do
221
+ it "is false if the :unless condition is true" do
222
222
  allow(field_config).to receive_messages(unless: true)
223
223
  expect(helper.should_render_field?(field_config)).to be false
224
224
  end
@@ -241,7 +241,7 @@ describe BlacklightConfigurationHelper do
241
241
  allow(helper).to receive_messages(blacklight_config: @config)
242
242
  end
243
243
 
244
- it "should return proper options_for_select arguments" do
244
+ it "returns proper options_for_select arguments" do
245
245
 
246
246
  select_arguments = helper.search_field_options_for_select
247
247
 
@@ -253,7 +253,7 @@ describe BlacklightConfigurationHelper do
253
253
  end
254
254
  end
255
255
 
256
- it "should not include fields in select if :display_in_simple_search=>false" do
256
+ it "does not include fields in select if :display_in_simple_search=>false" do
257
257
  select_arguments = helper.search_field_options_for_select
258
258
 
259
259
  expect(select_arguments).not_to include(["No Display", "no_display"])