blacklight 6.2.0 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.solr_wrapper +5 -0
- data/.travis.yml +3 -5
- data/Gemfile +3 -3
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/core.js +19 -5
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +48 -20
- data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +2 -1
- data/app/presenters/blacklight/document_presenter.rb +58 -150
- data/app/presenters/blacklight/field_presenter.rb +31 -0
- data/app/presenters/blacklight/index_presenter.rb +69 -0
- data/app/presenters/blacklight/link_alternate_presenter.rb +29 -0
- data/app/presenters/blacklight/rendering/abstract_step.rb +24 -0
- data/app/presenters/blacklight/rendering/helper_method.rb +23 -0
- data/app/presenters/blacklight/rendering/join.rb +16 -0
- data/app/presenters/blacklight/rendering/link_to_facet.rb +35 -0
- data/app/presenters/blacklight/rendering/microdata.rb +17 -0
- data/app/presenters/blacklight/rendering/pipeline.rb +32 -0
- data/app/presenters/blacklight/rendering/terminator.rb +9 -0
- data/app/presenters/blacklight/show_presenter.rb +93 -0
- data/app/services/blacklight/field_retriever.rb +58 -0
- data/app/views/catalog/_document_default.atom.builder +2 -3
- data/app/views/catalog/_document_default.rss.builder +2 -2
- data/app/views/kaminari/blacklight/_next_page.html.erb +9 -3
- data/app/views/kaminari/blacklight/_prev_page.html.erb +10 -3
- data/lib/blacklight/configuration.rb +15 -3
- data/lib/blacklight/configuration/null_field.rb +13 -0
- data/lib/blacklight/configuration/view_config.rb +6 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +1 -1
- data/lib/generators/blacklight/templates/config/blacklight.yml +1 -1
- data/lib/generators/blacklight/templates/config/jetty.yml +1 -1
- data/spec/controllers/alternate_controller_spec.rb +2 -2
- data/spec/controllers/application_controller_spec.rb +1 -1
- data/spec/controllers/blacklight/facet_spec.rb +3 -3
- data/spec/controllers/blacklight/search_fields_spec.rb +7 -7
- data/spec/controllers/blacklight/search_helper_spec.rb +44 -44
- data/spec/controllers/blacklight/suggest_search_spec.rb +1 -1
- data/spec/controllers/bookmarks_controller_spec.rb +6 -6
- data/spec/controllers/catalog_controller_spec.rb +125 -125
- data/spec/controllers/saved_searches_controller_spec.rb +4 -9
- data/spec/controllers/search_history_controller_spec.rb +3 -6
- data/spec/controllers/suggest_controller_spec.rb +2 -2
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/bookmarks_spec.rb +6 -6
- data/spec/features/did_you_mean_spec.rb +10 -10
- data/spec/features/facets_spec.rb +4 -4
- data/spec/features/record_view_spec.rb +4 -4
- data/spec/features/saved_searches_spec.rb +4 -4
- data/spec/features/search_context_spec.rb +4 -4
- data/spec/features/search_filters_spec.rb +10 -10
- data/spec/features/search_formats_spec.rb +2 -2
- data/spec/features/search_history_spec.rb +5 -5
- data/spec/features/search_pagination_spec.rb +4 -4
- data/spec/features/search_results_spec.rb +7 -7
- data/spec/features/search_sort_spec.rb +2 -2
- data/spec/features/search_spec.rb +6 -6
- data/spec/helpers/blacklight_helper_spec.rb +105 -65
- data/spec/helpers/catalog_helper_spec.rb +36 -36
- data/spec/helpers/configuration_helper_spec.rb +28 -28
- data/spec/helpers/facets_helper_spec.rb +39 -39
- data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -1
- data/spec/helpers/render_constraints_helper_spec.rb +1 -1
- data/spec/helpers/search_history_constraints_helper_spec.rb +7 -7
- data/spec/helpers/url_helper_spec.rb +20 -17
- data/spec/lib/blacklight/search_state_spec.rb +2 -2
- data/spec/lib/blacklight/utils_spec.rb +15 -15
- data/spec/lib/blacklight_spec.rb +1 -1
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/models/blacklight/configurable_spec.rb +3 -3
- data/spec/models/blacklight/configuration_spec.rb +52 -52
- data/spec/models/blacklight/document_spec.rb +10 -10
- data/spec/models/blacklight/facet_paginator_spec.rb +5 -5
- data/spec/models/blacklight/search_builder_spec.rb +34 -34
- data/spec/models/blacklight/user_spec.rb +4 -4
- data/spec/models/bookmark_spec.rb +5 -5
- data/spec/models/record_mailer_spec.rb +11 -11
- data/spec/models/search_spec.rb +1 -1
- data/spec/models/solr_document_spec.rb +4 -4
- data/spec/presenters/document_presenter_spec.rb +94 -50
- data/spec/presenters/index_presenter_spec.rb +147 -0
- data/spec/presenters/pipeline_spec.rb +28 -0
- data/spec/presenters/show_presenter_spec.rb +287 -0
- data/spec/routing/catalog_routing_spec.rb +11 -11
- data/spec/spec_helper.rb +10 -1
- data/spec/support/backport_test.rb +38 -0
- data/spec/test_app_templates/Gemfile.extra +2 -10
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_constraints.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_document.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_facets.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_index_default.erb_spec.rb +5 -4
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +4 -3
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_default.erb_spec.rb +6 -5
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +2 -1
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -2
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
- data/spec/views/catalog/facet.html.erb_spec.rb +3 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +15 -14
- data/spec/views/catalog/index.html.erb_spec.rb +3 -3
- data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -1
- data/spec/views/catalog/show.html.erb_spec.rb +5 -4
- data/tasks/blacklight.rake +1 -1
- metadata +25 -4
- 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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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
|
-
|
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 "
|
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
|
-
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
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 "
|
212
|
+
it "is true" do
|
213
213
|
expect(helper.should_render_field?(field_config)).to be true
|
214
214
|
end
|
215
215
|
|
216
|
-
it "
|
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 "
|
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 "
|
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 "
|
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"])
|