blacklight 6.2.0 → 6.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -11,7 +11,7 @@ describe FacetsHelper do
11
11
  end
12
12
 
13
13
  describe "has_facet_values?" do
14
- it "should be true if there are any facets to display" do
14
+ it "is true if there are any facets to display" do
15
15
 
16
16
  a = double(:items => [1,2], :name => 'a')
17
17
  b = double(:items => ['b','c'], :name => 'b')
@@ -21,7 +21,7 @@ describe FacetsHelper do
21
21
  expect(helper.has_facet_values?(fields)).to be true
22
22
  end
23
23
 
24
- it "should be false if all facets are empty" do
24
+ it "is false if all facets are empty" do
25
25
 
26
26
  empty = double(:items => [])
27
27
 
@@ -29,7 +29,7 @@ describe FacetsHelper do
29
29
  expect(helper.has_facet_values?(fields)).to be false
30
30
  end
31
31
 
32
- it "should be false if no facets are displayable" do
32
+ it "is false if no facets are displayable" do
33
33
  @config = Blacklight::Configuration.new do |config|
34
34
  config.add_facet_field 'basic_field', :if => false
35
35
  end
@@ -57,34 +57,34 @@ describe FacetsHelper do
57
57
  allow(helper).to receive_messages(:blacklight_config => @config)
58
58
  end
59
59
 
60
- it "should render facets with items" do
60
+ it "renders facets with items" do
61
61
  a = double(:items => [1,2], :name=>'basic_field')
62
62
  expect(helper.should_render_facet?(a)).to be true
63
63
  end
64
- it "should not render facets without items" do
64
+ it "does not render facets without items" do
65
65
  empty = double(:items => [], :name=>'basic_field')
66
66
  expect(helper.should_render_facet?(empty)).to be false
67
67
  end
68
68
 
69
- it "should not render facets where show is set to false" do
69
+ it "does not render facets where show is set to false" do
70
70
  a = double(:items => [1,2], :name=>'no_show')
71
71
  expect(helper.should_render_facet?(a)).to be false
72
72
  end
73
73
 
74
- it "should call a helper to determine if it should render a field" do
74
+ it "calls a helper to determine if it should render a field" do
75
75
  allow(controller).to receive_messages(:my_custom_check => true)
76
76
  a = double(:items => [1,2], :name=>'helper_show')
77
77
  expect(helper.should_render_facet?(a)).to be true
78
78
  end
79
79
 
80
- it "should call a helper to determine if it should render a field" do
80
+ it "calls a helper to determine if it should render a field" do
81
81
  a = double(:items => [1,2], :name=>'helper_with_an_arg_show')
82
82
  allow(controller).to receive(:my_custom_check_with_an_arg).with(@config.facet_fields['helper_with_an_arg_show'], a).and_return(true)
83
83
  expect(helper.should_render_facet?(a)).to be true
84
84
  end
85
85
 
86
86
 
87
- it "should evaluate a Proc to determine if it should render a field" do
87
+ it "evaluates a Proc to determine if it should render a field" do
88
88
  a = double(:items => [1,2], :name=>'lambda_show')
89
89
  expect(helper.should_render_facet?(a)).to be true
90
90
 
@@ -103,15 +103,15 @@ describe FacetsHelper do
103
103
  allow(helper).to receive_messages(blacklight_config: @config)
104
104
  end
105
105
 
106
- it "should be collapsed by default" do
106
+ it "is collapsed by default" do
107
107
  expect(helper.should_collapse_facet?(@config.facet_fields['basic_field'])).to be true
108
108
  end
109
109
 
110
- it "should not be collapsed if the configuration says so" do
110
+ it "does not be collapsed if the configuration says so" do
111
111
  expect(helper.should_collapse_facet?(@config.facet_fields['no_collapse'])).to be false
112
112
  end
113
113
 
114
- it "should not be collapsed if it is in the params" do
114
+ it "does not be collapsed if it is in the params" do
115
115
  params[:f] = ActiveSupport::HashWithIndifferentAccess.new(basic_field: [1], no_collapse: [2])
116
116
  expect(helper.should_collapse_facet?(@config.facet_fields['basic_field'])).to be false
117
117
  expect(helper.should_collapse_facet?(@config.facet_fields['no_collapse'])).to be false
@@ -120,7 +120,7 @@ describe FacetsHelper do
120
120
  end
121
121
 
122
122
  describe "facet_by_field_name" do
123
- it "should retrieve the facet from the response given a string" do
123
+ it "retrieves the facet from the response given a string" do
124
124
  facet_config = double(:query => nil, field: 'a', key: 'a')
125
125
  facet_field = double()
126
126
  allow(helper).to receive(:facet_configuration_for_field).with(anything()).and_return(facet_config)
@@ -134,7 +134,7 @@ describe FacetsHelper do
134
134
 
135
135
 
136
136
  describe "render_facet_partials" do
137
- it "should try to render all provided facets " do
137
+ it "tries to render all provided facets" do
138
138
  a = double(:items => [1,2])
139
139
  b = double(:items => ['b','c'])
140
140
  empty = double(:items => [])
@@ -148,7 +148,7 @@ describe FacetsHelper do
148
148
  helper.render_facet_partials fields
149
149
  end
150
150
 
151
- it "should default to the configured facets" do
151
+ it "defaults to the configured facets" do
152
152
  a = double(:items => [1,2])
153
153
  b = double(:items => ['b','c'])
154
154
  allow(helper).to receive(:facet_field_names) { [a,b] }
@@ -175,7 +175,7 @@ describe FacetsHelper do
175
175
  @response = double()
176
176
  end
177
177
 
178
- it "should set basic local variables" do
178
+ it "sets basic local variables" do
179
179
  @mock_facet = double(:name => 'basic_field', :items => [1,2,3])
180
180
  allow(helper).to receive(:render).with(hash_including(:partial => 'facet_limit',
181
181
  :locals => {
@@ -187,37 +187,37 @@ describe FacetsHelper do
187
187
  helper.render_facet_limit(@mock_facet)
188
188
  end
189
189
 
190
- it "should render a facet _not_ declared in the configuration" do
190
+ it "renders a facet _not_ declared in the configuration" do
191
191
  @mock_facet = double(:name => 'asdf', :items => [1,2,3])
192
192
  allow(helper).to receive(:render).with(hash_including(:partial => 'facet_limit'))
193
193
  helper.render_facet_limit(@mock_facet)
194
194
  end
195
195
 
196
- it "should get the partial name from the configuration" do
196
+ it "gets the partial name from the configuration" do
197
197
  @mock_facet = double(:name => 'my_facet_field_with_custom_partial', :items => [1,2,3])
198
198
  allow(helper).to receive(:render).with(hash_including(:partial => 'custom_facet_partial'))
199
199
  helper.render_facet_limit(@mock_facet)
200
200
  end
201
201
 
202
- it "should use a partial layout for rendering the facet frame" do
202
+ it "uses a partial layout for rendering the facet frame" do
203
203
  @mock_facet = double(:name => 'my_facet_field_with_custom_partial', :items => [1,2,3])
204
204
  allow(helper).to receive(:render).with(hash_including(:layout => 'facet_layout'))
205
205
  helper.render_facet_limit(@mock_facet)
206
206
  end
207
207
 
208
- it "should allow the caller to opt-out of facet layouts" do
208
+ it "allows the caller to opt-out of facet layouts" do
209
209
  @mock_facet = double(:name => 'my_facet_field_with_custom_partial', :items => [1,2,3])
210
210
  allow(helper).to receive(:render).with(hash_including(:layout => nil))
211
211
  helper.render_facet_limit(@mock_facet, :layout => nil)
212
212
  end
213
213
 
214
- it "should render the facet_pivot partial for pivot facets" do
214
+ it "renders the facet_pivot partial for pivot facets" do
215
215
  @mock_facet = double(:name => 'pivot_facet_field', :items => [1,2,3])
216
216
  allow(helper).to receive(:render).with(hash_including(:partial => 'facet_pivot'))
217
217
  helper.render_facet_limit(@mock_facet)
218
218
  end
219
219
 
220
- it "should let you override the rendered partial for pivot facets" do
220
+ it "lets you override the rendered partial for pivot facets" do
221
221
  @mock_facet = double(:name => 'my_pivot_facet_field_with_custom_partial', :items => [1,2,3])
222
222
  allow(helper).to receive(:render).with(hash_including(:partial => 'custom_facet_partial'))
223
223
  helper.render_facet_limit(@mock_facet)
@@ -234,7 +234,7 @@ describe FacetsHelper do
234
234
  search_catalog_path *args
235
235
  end
236
236
  end
237
- it "should draw a list of elements" do
237
+ it "draws a list of elements" do
238
238
  expect(subject).to have_selector 'li', count: 2
239
239
  expect(subject).to have_selector 'li:first-child a.facet_select', text: 'Book'
240
240
  expect(subject).to have_selector 'li:nth-child(2) a.facet_select', text: 'Musical Score'
@@ -245,7 +245,7 @@ describe FacetsHelper do
245
245
 
246
246
  before { allow(helper).to receive(:render_facet_item).and_return("<a class=\"facet_select\">Book</a>".html_safe, nil) }
247
247
 
248
- it "should draw a list of elements" do
248
+ it "draws a list of elements" do
249
249
  expect(subject).to have_selector 'li', count: 1
250
250
  expect(subject).to have_selector 'li:first-child a.facet_select', text: 'Book'
251
251
  end
@@ -254,7 +254,7 @@ describe FacetsHelper do
254
254
  end
255
255
 
256
256
  describe "facet_field_in_params?" do
257
- it "should check if the facet field is selected in the user params" do
257
+ it "checks if the facet field is selected in the user params" do
258
258
  allow(helper).to receive_messages(:params => { :f => { "some-field" => ["x"]}})
259
259
  expect(helper.facet_field_in_params?("some-field")).to be_truthy
260
260
  expect(helper.facet_field_in_params?("other-field")).to_not be true
@@ -262,12 +262,12 @@ describe FacetsHelper do
262
262
  end
263
263
 
264
264
  describe "facet_params" do
265
- it "should extract the facet parameters for a field" do
265
+ it "extracts the facet parameters for a field" do
266
266
  allow(helper).to receive_messages(params: { f: { "some-field" => ["x"] }})
267
267
  expect(helper.facet_params("some-field")).to match_array ["x"]
268
268
  end
269
269
 
270
- it "should use the blacklight key to extract the right fields" do
270
+ it "uses the blacklight key to extract the right fields" do
271
271
  blacklight_config.add_facet_field "some-key", field: "some-field"
272
272
  allow(helper).to receive_messages(params: { f: { "some-key" => ["x"] }})
273
273
  expect(helper.facet_params("some-key")).to match_array ["x"]
@@ -276,25 +276,25 @@ describe FacetsHelper do
276
276
  end
277
277
 
278
278
  describe "facet_field_in_params?" do
279
- it "should check if any value is selected for a given facet" do
279
+ it "checks if any value is selected for a given facet" do
280
280
  allow(helper).to receive_messages(facet_params: ["x"])
281
281
  expect(helper.facet_field_in_params?("some-facet")).to eq true
282
282
  end
283
283
 
284
- it "should be false if no value for facet is selected" do
284
+ it "is false if no value for facet is selected" do
285
285
  allow(helper).to receive_messages(facet_params: nil)
286
286
  expect(helper.facet_field_in_params?("some-facet")).to eq false
287
287
  end
288
288
  end
289
289
 
290
290
  describe "facet_in_params?" do
291
- it "should check if a particular value is set in the facet params" do
291
+ it "checks if a particular value is set in the facet params" do
292
292
  allow(helper).to receive_messages(facet_params: ["x"])
293
293
  expect(helper.facet_in_params?("some-facet", "x")).to eq true
294
294
  expect(helper.facet_in_params?("some-facet", "y")).to eq false
295
295
  end
296
296
 
297
- it "should be false if no value for facet is selected" do
297
+ it "is false if no value for facet is selected" do
298
298
  allow(helper).to receive_messages(facet_params: nil)
299
299
  expect(helper.facet_in_params?("some-facet", "x")).to eq false
300
300
  end
@@ -322,7 +322,7 @@ describe FacetsHelper do
322
322
 
323
323
  describe "when :url_method is set" do
324
324
  let(:expected_html) { "<span class=\"facet-label\"><a class=\"facet_select\" href=\"/blabla\">Z</a></span><span class=\"facet-count\">10</span>" }
325
- it "should use that method" do
325
+ it "uses that method" do
326
326
  allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(:query => nil, :date => nil, :helper_method => nil, :single => false, :url_method => :test_method))
327
327
  allow(helper).to receive(:test_method).with('simple_field', item).and_return('/blabla')
328
328
  result = helper.render_facet_value('simple_field', item)
@@ -332,7 +332,7 @@ describe FacetsHelper do
332
332
 
333
333
  describe "when :suppress_link is set" do
334
334
  let(:expected_html) { "<span class=\"facet-label\">Z</span><span class=\"facet-count\">10</span>" }
335
- it "should suppress the link" do
335
+ it "suppresses the link" do
336
336
  result = helper.render_facet_value('simple_field', item, :suppress_link => true)
337
337
  expect(result).to be_equivalent_to(expected_html).respecting_element_order
338
338
  end
@@ -340,12 +340,12 @@ describe FacetsHelper do
340
340
  end
341
341
 
342
342
  describe "#facet_display_value" do
343
- it "should just be the facet value for an ordinary facet" do
343
+ it "justs be the facet value for an ordinary facet" do
344
344
  allow(helper).to receive(:facet_configuration_for_field).with('simple_field').and_return(double(:query => nil, :date => nil, :helper_method => nil, :url_method => nil))
345
345
  expect(helper.facet_display_value('simple_field', 'asdf')).to eq 'asdf'
346
346
  end
347
347
 
348
- it "should allow you to pass in a :helper_method argument to the configuration" do
348
+ it "allows you to pass in a :helper_method argument to the configuration" do
349
349
  allow(helper).to receive(:facet_configuration_for_field).with('helper_field').and_return(double(:query => nil, :date => nil, :url_method => nil, :helper_method => :my_facet_value_renderer))
350
350
 
351
351
  allow(helper).to receive(:my_facet_value_renderer).with('qwerty').and_return('abc')
@@ -353,24 +353,24 @@ describe FacetsHelper do
353
353
  expect(helper.facet_display_value('helper_field', 'qwerty')).to eq 'abc'
354
354
  end
355
355
 
356
- it "should extract the configuration label for a query facet" do
356
+ it "extracts the configuration label for a query facet" do
357
357
  allow(helper).to receive(:facet_configuration_for_field).with('query_facet').and_return(double(:query => { 'query_key' => { :label => 'XYZ'}}, :date => nil, :helper_method => nil, :url_method => nil))
358
358
  expect(helper.facet_display_value('query_facet', 'query_key')).to eq 'XYZ'
359
359
  end
360
360
 
361
- it "should localize the label for date-type facets" do
361
+ it "localizes the label for date-type facets" do
362
362
  allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => true, :query => nil, :helper_method => nil, :url_method => nil))
363
363
  expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq 'Sun, 01 Jan 2012 00:00:00 +0000'
364
364
  end
365
365
 
366
- it "should localize the label for date-type facets with the supplied localization options" do
366
+ it "localizes the label for date-type facets with the supplied localization options" do
367
367
  allow(helper).to receive(:facet_configuration_for_field).with('date_facet').and_return(double('date' => { :format => :short }, :query => nil, :helper_method => nil, :url_method => nil))
368
368
  expect(helper.facet_display_value('date_facet', '2012-01-01')).to eq '01 Jan 00:00'
369
369
  end
370
370
  end
371
371
 
372
372
  describe "#facet_field_id" do
373
- it "should be the parameterized version of the facet field" do
373
+ it "is the parameterized version of the facet field" do
374
374
  expect(helper.facet_field_id double(key: 'some field')).to eq "facet-some-field"
375
375
  end
376
376
  end
@@ -7,7 +7,7 @@ describe HashAsHiddenFieldsHelper do
7
7
  @hash = {:q => "query", :search_field => "search_field", :per_page=>10, :page=>5, :extra_arbitrary_key=>"arbitrary_value", :f=> {:field1 => ["a", "b"], :field2=> ["z"]}}
8
8
  end
9
9
 
10
- it "should convert a hash with nested complex data to Rails-style hidden form fields" do
10
+ it "converts a hash with nested complex data to Rails-style hidden form fields" do
11
11
 
12
12
  generated = render_hash_as_hidden_fields(@hash)
13
13
 
@@ -58,7 +58,7 @@ describe RenderConstraintsHelper do
58
58
  end
59
59
  subject { helper.render_constraints_filters(params) }
60
60
 
61
- it "should render nothing for empty facet limit param" do
61
+ it "renders nothing for empty facet limit param" do
62
62
  expect(subject).to be_blank
63
63
  end
64
64
  end
@@ -22,7 +22,7 @@ describe SearchHistoryConstraintsHelper do
22
22
 
23
23
  describe "render_search_to_s_*" do
24
24
  describe "render_search_to_s_element" do
25
- it "should render basic element" do
25
+ it "renders basic element" do
26
26
  response = helper.render_search_to_s_element("key", "value")
27
27
  expect(response).to have_selector("span.constraint") do |span|
28
28
  expect(span).to have_selector("span.filterName", :content => "key:")
@@ -30,7 +30,7 @@ describe SearchHistoryConstraintsHelper do
30
30
  end
31
31
  expect(response).to be_html_safe
32
32
  end
33
- it "should escape them that need escaping" do
33
+ it "escapes them that need escaping" do
34
34
  response = helper.render_search_to_s_element("key>", "value>")
35
35
  expect(response).to have_selector("span.constraint") do |span|
36
36
  expect(span).to have_selector("span.filterName") do |s2|
@@ -45,7 +45,7 @@ describe SearchHistoryConstraintsHelper do
45
45
  end
46
46
  expect(response).to be_html_safe
47
47
  end
48
- it "should not escape with options set thus" do
48
+ it "does not escape with options set thus" do
49
49
  response = helper.render_search_to_s_element("key>", "value>", :escape_key => false, :escape_value => false)
50
50
  expect(response).to have_selector("span.constraint") do |span|
51
51
  expect(span).to have_selector("span.filterName", :content => "key>:")
@@ -59,7 +59,7 @@ describe SearchHistoryConstraintsHelper do
59
59
  before do
60
60
  @params = {:q => "history", :f => {"some_facet" => ["value1", "value1"], "other_facet" => ["other1"]}}
61
61
  end
62
- it "should call lesser methods" do
62
+ it "calls lesser methods" do
63
63
  allow(helper).to receive(:blacklight_config).and_return(@config)
64
64
  allow(helper).to receive(:default_search_field).and_return(Blacklight::Configuration::SearchField.new(:key => 'default_search_field', :display_label => 'Default'))
65
65
  allow(helper).to receive(:label_for_search_field).with(nil).and_return('')
@@ -73,12 +73,12 @@ describe SearchHistoryConstraintsHelper do
73
73
  end
74
74
 
75
75
  describe "render_search_to_s_filters" do
76
- it "should render a constraint for a selected facet in the config" do
76
+ it "renders a constraint for a selected facet in the config" do
77
77
  response = helper.render_search_to_s_filters(:f => {"some_facet" => ["value1", "value2"]})
78
78
  expect(response).to eq("<span class=\"constraint\"><span class=\"filterName\">Some:</span><span class=\"filterValues\"><span class=\"filterValue\">value1</span><span class=\"filterSeparator\"> and </span><span class=\"filterValue\">value2</span></span></span>")
79
79
  end
80
80
 
81
- it "should render a constraint for a selected facet not in the config" do
81
+ it "renders a constraint for a selected facet not in the config" do
82
82
  response = helper.render_search_to_s_filters(:f => {"undefined_facet" => ["value1", "value2"]})
83
83
  expect(response).to eq("<span class=\"constraint\"><span class=\"filterName\">#{'undefined_facet'.humanize}:</span><span class=\"filterValues\"><span class=\"filterValue\">value1</span><span class=\"filterSeparator\"> and </span><span class=\"filterValue\">value2</span></span></span>")
84
84
  end
@@ -92,7 +92,7 @@ describe SearchHistoryConstraintsHelper do
92
92
  I18n.locale = @orig_locale
93
93
  end
94
94
 
95
- it 'should render the correct I18n label for a selected facet with I18n translations' do
95
+ it 'renders the correct I18n label for a selected facet with I18n translations' do
96
96
  {en: 'English facet label', de: 'German facet label'}.each do |locale, label|
97
97
  I18n.locale = locale
98
98
  response = helper.render_search_to_s_filters(f: {'i18n_facet' => ['value1', 'value2']})
@@ -32,11 +32,11 @@ describe BlacklightUrlHelper do
32
32
  allow(helper).to receive_messages(params: parameter_class.new)
33
33
  end
34
34
 
35
- it "should be a polymorphic routing-ready object" do
35
+ it "is a polymorphic routing-ready object" do
36
36
  expect(helper.url_for_document(doc)).to eq doc
37
37
  end
38
38
 
39
- it "should allow for custom show routes" do
39
+ it "allows for custom show routes" do
40
40
  helper.blacklight_config.show.route = { controller: 'catalog' }
41
41
  expect(helper.url_for_document(doc)).to eq({controller: 'catalog', action: :show, id: doc})
42
42
  end
@@ -44,7 +44,7 @@ describe BlacklightUrlHelper do
44
44
  context "within bookmarks" do
45
45
  let(:controller_class) { ::BookmarksController.new }
46
46
 
47
- it "should use polymorphic routing" do
47
+ it "uses polymorphic routing" do
48
48
  expect(helper.url_for_document(doc)).to eq doc
49
49
  end
50
50
  end
@@ -57,12 +57,12 @@ describe BlacklightUrlHelper do
57
57
  allow(helper).to receive(:params).and_return(parameter_class.new controller: 'alternate')
58
58
  end
59
59
 
60
- it "should support the :current controller configuration" do
60
+ it "supports the :current controller configuration" do
61
61
  expect(helper.url_for_document(doc)).to eq(controller: 'alternate', action: :show, id: doc)
62
62
  end
63
63
  end
64
64
 
65
- it "should be a polymorphic route if the solr document responds to #to_model with a non-SolrDocument" do
65
+ it "is a polymorphic route if the solr document responds to #to_model with a non-SolrDocument" do
66
66
  some_model = double
67
67
  doc = SolrDocument.new
68
68
  allow(doc).to receive_messages(to_model: some_model)
@@ -74,7 +74,7 @@ describe BlacklightUrlHelper do
74
74
  let(:query_params) {{:q => "query", :f => "facets", :controller=>'catalog'}}
75
75
  let(:bookmarks_query_params) {{ :controller=>'bookmarks'}}
76
76
 
77
- it "should build a link tag to catalog using session[:search] for query params" do
77
+ it "builds a link tag to catalog using session[:search] for query params" do
78
78
  allow(helper).to receive(:current_search_session).and_return double(:query_params => query_params)
79
79
  tag = helper.link_back_to_catalog
80
80
  expect(tag).to match /q=query/
@@ -83,7 +83,7 @@ describe BlacklightUrlHelper do
83
83
  expect(tag).to_not match /per_page=/
84
84
  end
85
85
 
86
- it "should build a link tag to bookmarks using session[:search] for query params" do
86
+ it "builds a link tag to bookmarks using session[:search] for query params" do
87
87
  allow(helper).to receive(:current_search_session).and_return double(:query_params => bookmarks_query_params)
88
88
  tag = helper.link_back_to_catalog
89
89
  expect(tag).to match /Back to Bookmarks/
@@ -92,7 +92,7 @@ describe BlacklightUrlHelper do
92
92
 
93
93
  context "with a search context" do
94
94
 
95
- it "should use the current search session counter and per page information to construct the appropriate pagination context" do
95
+ it "uses the current search session counter and per page information to construct the appropriate pagination context" do
96
96
  allow(helper).to receive_messages(current_search_session: double(query_params: query_params))
97
97
  allow(helper).to receive_messages(search_session: { 'per_page' => 15, 'counter' => 31 })
98
98
  tag = helper.link_back_to_catalog
@@ -100,7 +100,7 @@ describe BlacklightUrlHelper do
100
100
  expect(tag).to match /per_page=15/
101
101
  end
102
102
 
103
- it "should omit per_page if the value is the same as the default" do
103
+ it "omits per_page if the value is the same as the default" do
104
104
  allow(helper).to receive_messages(current_search_session: double(query_params: query_params))
105
105
  allow(helper).to receive_messages(search_session: { 'per_page' => 10, 'counter' => 31 })
106
106
  tag = helper.link_back_to_catalog
@@ -121,7 +121,7 @@ describe BlacklightUrlHelper do
121
121
 
122
122
  subject { helper.link_back_to_catalog }
123
123
 
124
- it "should link to the catalog" do
124
+ it "links to the catalog" do
125
125
  expect(subject).to eq '<a href="/catalog">Back to Search</a>'
126
126
  end
127
127
  end
@@ -129,7 +129,7 @@ describe BlacklightUrlHelper do
129
129
  context "when an alternate scope is passed in" do
130
130
  let(:my_engine) { double("Engine") }
131
131
 
132
- it "should call url_for on the engine scope" do
132
+ it "calls url_for on the engine scope" do
133
133
  allow(helper).to receive(:current_search_session).and_return double(:query_params => query_params)
134
134
  expect(my_engine).to receive(:url_for).and_return(url_for(query_params))
135
135
  tag = helper.link_back_to_catalog(route_set: my_engine)
@@ -181,13 +181,13 @@ describe BlacklightUrlHelper do
181
181
  end
182
182
 
183
183
  describe "start_over_path" do
184
- it 'should be the catalog path with the current view type' do
184
+ it 'is the catalog path with the current view type' do
185
185
  allow(blacklight_config).to receive(:view) { { list: nil, abc: nil} }
186
186
  allow(helper).to receive_messages(:blacklight_config => blacklight_config)
187
187
  expect(helper.start_over_path(:view => 'abc')).to eq search_catalog_url(:view => 'abc')
188
188
  end
189
189
 
190
- it 'should not include the current view type if it is the default' do
190
+ it 'does not include the current view type if it is the default' do
191
191
  allow(blacklight_config).to receive(:view) { { list: nil, asdf: nil} }
192
192
  allow(helper).to receive_messages(:blacklight_config => blacklight_config)
193
193
  expect(helper.start_over_path(:view => 'list')).to eq search_catalog_url
@@ -199,6 +199,9 @@ describe BlacklightUrlHelper do
199
199
  let(:id) { '123456' }
200
200
  let(:data) { { 'id' => id, 'title_display' => [title_display] } }
201
201
  let(:document) { SolrDocument.new(data) }
202
+ before do
203
+ allow(controller).to receive(:action_name).and_return('index')
204
+ end
202
205
 
203
206
  it "consists of the document title wrapped in a <a>" do
204
207
  expect(helper.link_to_document(document, :title_display)).to have_selector("a", :text => '654321', :count => 1)
@@ -264,14 +267,14 @@ describe BlacklightUrlHelper do
264
267
 
265
268
  describe "link_to_previous_search" do
266
269
  let(:params) { {} }
267
- it "should link to the given search parameters" do
270
+ it "links to the given search parameters" do
268
271
  allow(helper).to receive(:render_search_to_s).with(params).and_return "link text"
269
272
  expect(helper.link_to_previous_search({})).to eq helper.link_to("link text", helper.search_action_path)
270
273
  end
271
274
  end
272
275
 
273
276
  describe "#bookmarks_export_url" do
274
- it "should be the bookmark url with an encrypted user token" do
277
+ it "is the bookmark url with an encrypted user token" do
275
278
  allow(helper).to receive_messages(encrypt_user_id: 'xyz', current_or_guest_user: double(id: 123))
276
279
  url = helper.bookmarks_export_url(:html)
277
280
  expect(url).to eq helper.bookmarks_url(format: :html, encrypted_user_id: 'xyz')
@@ -280,12 +283,12 @@ describe BlacklightUrlHelper do
280
283
 
281
284
  describe "#session_tracking_path" do
282
285
  let(:document) { SolrDocument.new(id: 1) }
283
- it "should determine the correct route for the document class" do
286
+ it "determines the correct route for the document class" do
284
287
  allow(helper).to receive(:track_test_path).with(id: 1).and_return('x')
285
288
  expect(helper.session_tracking_path(document)).to eq 'x'
286
289
  end
287
290
 
288
- it "should pass through tracking parameters" do
291
+ it "passes through tracking parameters" do
289
292
  allow(helper).to receive(:track_test_path).with(id: 1, x: 1).and_return('x')
290
293
  expect(helper.session_tracking_path(document, x: 1)).to eq 'x'
291
294
  end