blacklight 7.10.0 → 7.11.1
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +56 -7
- data/.rubocop_todo.yml +113 -98
- data/.travis.yml +0 -2
- data/Gemfile +0 -7
- data/README.md +1 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +1 -2
- data/app/components/blacklight/document/bookmark_component.html.erb +16 -0
- data/app/components/blacklight/document/bookmark_component.rb +19 -0
- data/app/components/blacklight/document/citation_component.html.erb +9 -0
- data/app/components/blacklight/document/citation_component.rb +24 -0
- data/app/components/blacklight/document/more_like_this_component.html.erb +12 -0
- data/app/components/blacklight/document/more_like_this_component.rb +21 -0
- data/app/components/blacklight/document_component.html.erb +29 -0
- data/app/components/blacklight/document_component.rb +121 -0
- data/app/components/blacklight/document_metadata_component.html.erb +5 -0
- data/app/components/blacklight/document_metadata_component.rb +21 -0
- data/app/components/blacklight/facet_item_component.rb +6 -6
- data/app/components/blacklight/metadata_field_component.html.erb +8 -0
- data/app/components/blacklight/metadata_field_component.rb +31 -0
- data/app/components/blacklight/metadata_field_layout_component.html.erb +2 -0
- data/app/components/blacklight/metadata_field_layout_component.rb +16 -0
- data/app/components/blacklight/response/facet_group_component.html.erb +25 -0
- data/app/components/blacklight/response/facet_group_component.rb +19 -0
- data/app/components/blacklight/response/pagination_component.html.erb +3 -0
- data/app/components/blacklight/response/pagination_component.rb +17 -0
- data/app/components/blacklight/response/sort_component.html.erb +6 -0
- data/app/components/blacklight/response/sort_component.rb +16 -0
- data/app/components/blacklight/response/spellcheck_component.html.erb +7 -0
- data/app/components/blacklight/response/spellcheck_component.rb +20 -0
- data/app/components/blacklight/search_bar_component.html.erb +29 -0
- data/app/components/blacklight/search_bar_component.rb +45 -0
- data/app/components/blacklight/search_context_component.html.erb +10 -0
- data/app/components/blacklight/search_context_component.rb +30 -0
- data/app/components/blacklight/system/dropdown_component.html.erb +12 -0
- data/app/components/blacklight/system/dropdown_component.rb +42 -0
- data/app/components/blacklight/system/modal_component.html.erb +25 -0
- data/app/components/blacklight/system/modal_component.rb +9 -0
- data/app/controllers/concerns/blacklight/catalog.rb +5 -4
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +2 -2
- data/app/controllers/concerns/blacklight/searchable.rb +11 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -3
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +6 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +7 -10
- data/app/helpers/blacklight/url_helper_behavior.rb +3 -3
- data/app/javascript/blacklight/search_context.js +0 -1
- data/app/models/blacklight/icon.rb +1 -0
- data/app/models/concerns/blacklight/document.rb +1 -0
- data/app/models/record_mailer.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +7 -1
- data/app/presenters/blacklight/field_presenter.rb +1 -0
- data/app/presenters/blacklight/rendering/microdata.rb +1 -1
- data/app/services/blacklight/field_retriever.rb +1 -0
- data/app/services/blacklight/search_service.rb +1 -0
- data/app/views/catalog/_bookmark_control.html.erb +1 -36
- data/app/views/catalog/_citation.html.erb +4 -25
- data/app/views/catalog/_did_you_mean.html.erb +1 -5
- data/app/views/catalog/_document.atom.builder +3 -3
- data/app/views/catalog/_document.html.erb +5 -5
- data/app/views/catalog/_facet_group.html.erb +5 -19
- data/app/views/catalog/_index.html.erb +1 -10
- data/app/views/catalog/_paginate_compact.html.erb +6 -6
- data/app/views/catalog/_per_page_widget.html.erb +9 -12
- data/app/views/catalog/_previous_next_doc.html.erb +1 -12
- data/app/views/catalog/_results_pagination.html.erb +1 -3
- data/app/views/catalog/_search_form.html.erb +6 -27
- data/app/views/catalog/_show.html.erb +6 -8
- data/app/views/catalog/_show_main_content.html.erb +19 -13
- data/app/views/catalog/_show_sidebar.html.erb +1 -11
- data/app/views/catalog/_sort_widget.html.erb +5 -12
- data/app/views/catalog/email.html.erb +7 -7
- data/app/views/catalog/email_success.html.erb +5 -12
- data/app/views/catalog/facet.html.erb +14 -17
- data/app/views/catalog/index.atom.builder +0 -1
- data/app/views/catalog/sms.html.erb +7 -7
- data/app/views/catalog/sms_success.html.erb +5 -12
- data/blacklight.gemspec +3 -2
- data/config/i18n-tasks.yml +3 -0
- data/config/locales/blacklight.ar.yml +2 -0
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +4 -2
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.hu.yml +2 -0
- data/config/locales/blacklight.it.yml +2 -0
- data/config/locales/blacklight.nl.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/config/locales/blacklight.sq.yml +2 -0
- data/config/locales/blacklight.zh.yml +2 -0
- data/lib/blacklight.rb +10 -0
- data/lib/blacklight/configuration.rb +8 -3
- data/lib/blacklight/configuration/fields.rb +5 -7
- data/lib/blacklight/engine.rb +1 -1
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -0
- data/lib/blacklight/search_state.rb +21 -7
- data/lib/blacklight/solr/response.rb +1 -0
- data/lib/blacklight/solr/response/facets.rb +9 -8
- data/lib/generators/blacklight/models_generator.rb +2 -0
- data/lib/generators/blacklight/templates/config/blacklight.yml +1 -0
- data/lib/railties/blacklight.rake +18 -13
- data/package.json +1 -1
- data/spec/components/blacklight/constraint_layout_component_spec.rb +1 -0
- data/spec/components/blacklight/document_component_spec.rb +129 -0
- data/spec/components/blacklight/document_metadata_component_spec.rb +0 -0
- data/spec/components/blacklight/metadata_field_component_spec.rb +41 -0
- data/spec/controllers/blacklight/search_fields_spec.rb +2 -2
- data/spec/controllers/catalog_controller_spec.rb +20 -0
- data/spec/features/search_context_spec.rb +12 -2
- data/spec/features/search_filters_spec.rb +4 -0
- data/spec/features/search_results_spec.rb +1 -0
- data/spec/features/sitelinks_search_box.rb +1 -0
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +3 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -0
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +14 -1
- data/spec/helpers/catalog_helper_spec.rb +1 -4
- data/spec/lib/blacklight/search_state_spec.rb +32 -0
- data/spec/models/blacklight/configuration_spec.rb +5 -0
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
- data/spec/models/blacklight/document/email_spec.rb +2 -0
- data/spec/models/blacklight/document/sms_spec.rb +2 -0
- data/spec/models/blacklight/facet_paginator_spec.rb +3 -0
- data/spec/models/blacklight/icon_spec.rb +6 -0
- data/spec/models/blacklight/solr/document_spec.rb +10 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_response_spec.rb +2 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +10 -0
- data/spec/models/record_mailer_spec.rb +9 -0
- data/spec/models/search_spec.rb +1 -0
- data/spec/presenters/blacklight/show_presenter_spec.rb +8 -0
- data/spec/routing/catalog_routing_spec.rb +4 -0
- data/spec/services/blacklight/search_service_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/views/catalog/_document.html.erb_spec.rb +13 -11
- data/spec/views/catalog/_facet_group.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +4 -0
- data/spec/views/catalog/index.atom.builder_spec.rb +40 -3
- data/spec/views/catalog/show.html.erb_spec.rb +14 -0
- data/tasks/blacklight.rake +7 -7
- metadata +56 -6
|
@@ -7,12 +7,12 @@ RSpec.describe "Search Results context", js: true do
|
|
|
7
7
|
click_on 'Pluvial nectar of blessings'
|
|
8
8
|
expect(page).to have_content "« Previous | 10 of 30 | Next »"
|
|
9
9
|
prev = page.find(".pagination-search-widgets .previous")
|
|
10
|
-
expect(prev['data-context-href']).to eq "/catalog/2003546302/track?counter=9&search_id=#{search_id}"
|
|
10
|
+
expect(prev['data-context-href']).to eq "/catalog/2003546302/track?counter=9&document_id=2003546302&search_id=#{search_id}"
|
|
11
11
|
|
|
12
12
|
click_on "« Previous"
|
|
13
13
|
|
|
14
14
|
prev = page.find(".pagination-search-widgets .previous")
|
|
15
|
-
expect(prev['data-context-href']).to eq "/catalog/2004310986/track?counter=8&search_id=#{search_id}"
|
|
15
|
+
expect(prev['data-context-href']).to eq "/catalog/2004310986/track?counter=8&document_id=2004310986&search_id=#{search_id}"
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "redirects context urls to the original url" do
|
|
@@ -31,6 +31,16 @@ RSpec.describe "Search Results context", js: true do
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
it "does not display stale previous and next links for direct item views" do
|
|
35
|
+
search_for ''
|
|
36
|
+
click_on 'Pluvial nectar of blessings'
|
|
37
|
+
|
|
38
|
+
# Go to the number 9 result separately
|
|
39
|
+
visit '/catalog/2003546302'
|
|
40
|
+
expect(page).not_to have_selector '.page-links'
|
|
41
|
+
expect(page).not_to have_content "« Previous | 10 of 30 | Next »"
|
|
42
|
+
end
|
|
43
|
+
|
|
34
44
|
context "navigating between search results using context pagination" do
|
|
35
45
|
it "updates the back to search link with the current search pagination context" do
|
|
36
46
|
search_for ''
|
|
@@ -166,6 +166,7 @@ RSpec.describe "Facets" do
|
|
|
166
166
|
expect(page).to have_content "history"
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
|
+
|
|
169
170
|
it "is collapsed when not selected", js: true do
|
|
170
171
|
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
|
171
172
|
visit root_path
|
|
@@ -178,6 +179,7 @@ RSpec.describe "Facets" do
|
|
|
178
179
|
expect(page).not_to have_selector(".card-body", visible: true)
|
|
179
180
|
end
|
|
180
181
|
end
|
|
182
|
+
|
|
181
183
|
it "expands when the heading button is clicked", js: true do
|
|
182
184
|
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
|
183
185
|
visit root_path
|
|
@@ -192,6 +194,7 @@ RSpec.describe "Facets" do
|
|
|
192
194
|
expect(page).to have_selector(".card-body", visible: true)
|
|
193
195
|
end
|
|
194
196
|
end
|
|
197
|
+
|
|
195
198
|
it "expands when the button is clicked", js: true do
|
|
196
199
|
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
|
197
200
|
visit root_path
|
|
@@ -206,6 +209,7 @@ RSpec.describe "Facets" do
|
|
|
206
209
|
expect(page).to have_selector(".card-body", visible: true)
|
|
207
210
|
end
|
|
208
211
|
end
|
|
212
|
+
|
|
209
213
|
it "keeps selected facets expanded on page load", js: true do
|
|
210
214
|
skip("Test passes locally but not on Travis.") if ENV['TRAVIS']
|
|
211
215
|
visit root_path
|
|
@@ -271,9 +271,11 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
|
271
271
|
it 'handles a found key' do
|
|
272
272
|
expect(helper.label_for_search_field('my-key')).to eq 'My Field'
|
|
273
273
|
end
|
|
274
|
+
|
|
274
275
|
it 'handles a missing key' do
|
|
275
276
|
expect(helper.label_for_search_field('not-found')).to eq 'Not Found'
|
|
276
277
|
end
|
|
278
|
+
|
|
277
279
|
it 'handles a missing field' do
|
|
278
280
|
expect(helper.label_for_search_field(nil)).to eq nil
|
|
279
281
|
end
|
|
@@ -285,6 +287,7 @@ RSpec.describe Blacklight::ConfigurationHelperBehavior do
|
|
|
285
287
|
it 'handles a found key' do
|
|
286
288
|
expect(helper.sort_field_label('my-key')).to eq 'My Field'
|
|
287
289
|
end
|
|
290
|
+
|
|
288
291
|
it 'handles a missing key' do
|
|
289
292
|
expect(helper.sort_field_label('not-found')).to eq 'Not Found'
|
|
290
293
|
end
|
|
@@ -70,6 +70,7 @@ RSpec.describe Blacklight::RenderPartialsHelperBehavior do
|
|
|
70
70
|
it "uses the value in the configured display type field" do
|
|
71
71
|
expect(helper.document_partial_name(document)).to eq 'xyz'
|
|
72
72
|
end
|
|
73
|
+
|
|
73
74
|
it "uses the value in the configured display type field if the action-specific field is empty" do
|
|
74
75
|
expect(helper.document_partial_name(document, :some_action)).to eq 'xyz'
|
|
75
76
|
end
|
|
@@ -28,6 +28,7 @@ RSpec.describe Blacklight::SearchHistoryConstraintsHelperBehavior do
|
|
|
28
28
|
end
|
|
29
29
|
expect(response).to be_html_safe
|
|
30
30
|
end
|
|
31
|
+
|
|
31
32
|
it "escapes them that need escaping" do
|
|
32
33
|
response = helper.render_search_to_s_element("key>", "value>")
|
|
33
34
|
expect(response).to have_selector("span.constraint") do |span|
|
|
@@ -43,6 +44,7 @@ RSpec.describe Blacklight::SearchHistoryConstraintsHelperBehavior do
|
|
|
43
44
|
end
|
|
44
45
|
expect(response).to be_html_safe
|
|
45
46
|
end
|
|
47
|
+
|
|
46
48
|
it "does not escape with options set thus" do
|
|
47
49
|
response = helper.render_search_to_s_element("key>", "value>", escape_key: false, escape_value: false)
|
|
48
50
|
expect(response).to have_selector("span.constraint") do |span|
|
|
@@ -233,7 +233,7 @@ RSpec.describe Blacklight::UrlHelperBehavior do
|
|
|
233
233
|
end
|
|
234
234
|
|
|
235
235
|
it "passes on the title attribute to the link_to_with_data method" do
|
|
236
|
-
expect(helper.link_to_document(document, "Some crazy long label...", title: "Some crazy longer label")).to match(/title
|
|
236
|
+
expect(helper.link_to_document(document, "Some crazy long label...", title: "Some crazy longer label")).to match(/title="Some crazy longer label"/)
|
|
237
237
|
end
|
|
238
238
|
|
|
239
239
|
it "doesn't add an erroneous title attribute if one isn't provided" do
|
|
@@ -48,10 +48,12 @@ RSpec.describe BlacklightHelper do
|
|
|
48
48
|
helper.content_for(:page_title) { "xyz" }
|
|
49
49
|
expect(helper.render_page_title).to eq "xyz"
|
|
50
50
|
end
|
|
51
|
+
|
|
51
52
|
it "looks in the @page_title ivar" do
|
|
52
53
|
assign(:page_title, "xyz")
|
|
53
54
|
expect(helper.render_page_title).to eq "xyz"
|
|
54
55
|
end
|
|
56
|
+
|
|
55
57
|
it "defaults to the application name" do
|
|
56
58
|
expect(helper.render_page_title).to eq helper.application_name
|
|
57
59
|
end
|
|
@@ -194,12 +196,14 @@ RSpec.describe BlacklightHelper do
|
|
|
194
196
|
field_config = double(field: 'asdf')
|
|
195
197
|
expect(helper.document_has_value?(doc, field_config)).to eq true
|
|
196
198
|
end
|
|
199
|
+
|
|
197
200
|
it "ifs the document has a highlight field value" do
|
|
198
201
|
allow(doc).to receive(:has?).with('asdf').and_return(false)
|
|
199
202
|
allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(true)
|
|
200
203
|
field_config = double(field: 'asdf', highlight: true)
|
|
201
204
|
expect(helper.document_has_value?(doc, field_config)).to eq true
|
|
202
205
|
end
|
|
206
|
+
|
|
203
207
|
it "ifs the field has a model accessor" do
|
|
204
208
|
allow(doc).to receive(:has?).with('asdf').and_return(false)
|
|
205
209
|
allow(doc).to receive(:has_highlight_field?).with('asdf').and_return(false)
|
|
@@ -250,14 +254,17 @@ RSpec.describe BlacklightHelper do
|
|
|
250
254
|
response = double(total: 10)
|
|
251
255
|
expect(helper.should_show_spellcheck_suggestions?(response)).to be false
|
|
252
256
|
end
|
|
257
|
+
|
|
253
258
|
it "only shows suggestions if there are very few results" do
|
|
254
259
|
response = double(total: 4, spelling: double(words: [1]))
|
|
255
260
|
expect(helper.should_show_spellcheck_suggestions?(response)).to be true
|
|
256
261
|
end
|
|
262
|
+
|
|
257
263
|
it "shows suggestions only if there are spelling suggestions available" do
|
|
258
264
|
response = double(total: 4, spelling: double(words: []))
|
|
259
265
|
expect(helper.should_show_spellcheck_suggestions?(response)).to be false
|
|
260
266
|
end
|
|
267
|
+
|
|
261
268
|
it "does not show suggestions if spelling is not available" do
|
|
262
269
|
response = double(total: 4, spelling: nil)
|
|
263
270
|
expect(helper.should_show_spellcheck_suggestions?(response)).to be false
|
|
@@ -270,12 +277,15 @@ RSpec.describe BlacklightHelper do
|
|
|
270
277
|
it "has a search rel" do
|
|
271
278
|
expect(subject).to have_selector "link[rel='search']", visible: false
|
|
272
279
|
end
|
|
280
|
+
|
|
273
281
|
it "has the correct mime type" do
|
|
274
282
|
expect(subject).to have_selector "link[type='application/opensearchdescription+xml']", visible: false
|
|
275
283
|
end
|
|
284
|
+
|
|
276
285
|
it "has a title attribute" do
|
|
277
286
|
expect(subject).to have_selector "link[title='title']", visible: false
|
|
278
287
|
end
|
|
288
|
+
|
|
279
289
|
it "has an href attribute" do
|
|
280
290
|
expect(subject).to have_selector "link[href='href']", visible: false
|
|
281
291
|
end
|
|
@@ -291,15 +301,18 @@ RSpec.describe BlacklightHelper do
|
|
|
291
301
|
|
|
292
302
|
describe "#render_document_index_with_view" do
|
|
293
303
|
let(:obj1) { SolrDocument.new }
|
|
304
|
+
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
|
|
294
305
|
|
|
295
306
|
before do
|
|
296
|
-
allow(helper).to receive(:blacklight_config).and_return(
|
|
307
|
+
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
|
297
308
|
assign(:response, instance_double(Blacklight::Solr::Response, grouped?: false, start: 0))
|
|
298
309
|
allow(helper).to receive(:link_to_document).and_return('<a/>')
|
|
299
310
|
allow(helper).to receive(:render_index_doc_actions).and_return('<div/>')
|
|
300
311
|
end
|
|
301
312
|
|
|
302
313
|
it "ignores missing templates" do
|
|
314
|
+
blacklight_config.view.view_type.partials = %w[index_header a b]
|
|
315
|
+
|
|
303
316
|
response = helper.render_document_index_with_view :view_type, [obj1, obj1]
|
|
304
317
|
expect(response).to have_selector "div#documents"
|
|
305
318
|
end
|
|
@@ -18,10 +18,6 @@ RSpec.describe CatalogHelper do
|
|
|
18
18
|
mock_response
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def render_grouped_response?
|
|
22
|
-
false
|
|
23
|
-
end
|
|
24
|
-
|
|
25
21
|
describe "page_entries_info" do
|
|
26
22
|
it "with no results" do
|
|
27
23
|
@response = mock_response total: 0
|
|
@@ -97,6 +93,7 @@ RSpec.describe CatalogHelper do
|
|
|
97
93
|
expect(html).to eq "<strong>41</strong> - <strong>47</strong> of <strong>47</strong>"
|
|
98
94
|
expect(html).to be_html_safe
|
|
99
95
|
end
|
|
96
|
+
|
|
100
97
|
it "works with rows the same as per_page" do
|
|
101
98
|
@response = mock_response total: 47, rows: 20, current_page: 2
|
|
102
99
|
|
|
@@ -46,6 +46,38 @@ RSpec.describe Blacklight::SearchState do
|
|
|
46
46
|
expect(search_state.to_h).to eq data.with_indifferent_access
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
|
+
|
|
50
|
+
context 'with facebooks badly mangled query parameters' do
|
|
51
|
+
let(:params) { { f: { field: { '0': 'first', '1': 'second' } } } }
|
|
52
|
+
|
|
53
|
+
it 'normalizes the facets to the expected format' do
|
|
54
|
+
expect(search_state.to_h).to include f: { field: %w[first second] }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context 'deleting item from to_h' do
|
|
59
|
+
let(:params) { { q: 'foo', q_1: 'bar' } }
|
|
60
|
+
|
|
61
|
+
it 'does not mutate search_state to mutate search_state.to_h' do
|
|
62
|
+
params = search_state.to_h
|
|
63
|
+
params.delete(:q_1)
|
|
64
|
+
|
|
65
|
+
expect(search_state.to_h).to eq('q' => 'foo', 'q_1' => 'bar')
|
|
66
|
+
expect(params).to eq('q' => 'foo')
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context 'deleting deep item from to_h' do
|
|
71
|
+
let(:params) { { foo: { bar: [] } } }
|
|
72
|
+
|
|
73
|
+
it 'does not mutate search_state to deep mutate search_state.to_h' do
|
|
74
|
+
params = search_state.to_h
|
|
75
|
+
params[:foo][:bar] << 'buzz'
|
|
76
|
+
|
|
77
|
+
expect(search_state.to_h).to eq('foo' => { 'bar' => [] })
|
|
78
|
+
expect(params).to eq('foo' => { 'bar' => ['buzz'] })
|
|
79
|
+
end
|
|
80
|
+
end
|
|
49
81
|
end
|
|
50
82
|
|
|
51
83
|
describe 'interface compatibility with params' do
|
|
@@ -55,6 +55,7 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
|
55
55
|
it "has the global blacklight configuration" do
|
|
56
56
|
expect(config.connection_config).to eq Blacklight.connection_config
|
|
57
57
|
end
|
|
58
|
+
|
|
58
59
|
it "is overridable with custom configuration" do
|
|
59
60
|
config.connection_config = custom_config
|
|
60
61
|
expect(config.connection_config).to eq custom_config
|
|
@@ -340,12 +341,14 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
|
340
341
|
expect(config.index_fields["title_tsim"]).not_to be_nil
|
|
341
342
|
expect(config.index_fields["title_tsim"].label).to eq "Title"
|
|
342
343
|
end
|
|
344
|
+
|
|
343
345
|
it "takes IndexField param" do
|
|
344
346
|
config.add_index_field("title_tsim", Blacklight::Configuration::IndexField.new(field: "title_display", label: "Title"))
|
|
345
347
|
|
|
346
348
|
expect(config.index_fields["title_tsim"]).not_to be_nil
|
|
347
349
|
expect(config.index_fields["title_tsim"].label).to eq "Title"
|
|
348
350
|
end
|
|
351
|
+
|
|
349
352
|
it "takes block form" do
|
|
350
353
|
config.add_index_field("title_tsim") do |field|
|
|
351
354
|
field.label = "Title"
|
|
@@ -388,12 +391,14 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
|
388
391
|
expect(config.show_fields["title_tsim"]).not_to be_nil
|
|
389
392
|
expect(config.show_fields["title_tsim"].label).to eq "Title"
|
|
390
393
|
end
|
|
394
|
+
|
|
391
395
|
it "takes ShowField argument" do
|
|
392
396
|
config.add_show_field("title_tsim", Blacklight::Configuration::ShowField.new(field: "title_display", label: "Title"))
|
|
393
397
|
|
|
394
398
|
expect(config.show_fields["title_tsim"]).not_to be_nil
|
|
395
399
|
expect(config.show_fields["title_tsim"].label).to eq "Title"
|
|
396
400
|
end
|
|
401
|
+
|
|
397
402
|
it "takes block form" do
|
|
398
403
|
config.add_show_field("title_tsim") do |f|
|
|
399
404
|
f.label = "Title"
|
|
@@ -24,6 +24,7 @@ RSpec.describe Blacklight::Document::CacheKey, api: true do
|
|
|
24
24
|
it 'provides a cache key with the id and version' do
|
|
25
25
|
expect(subject.cache_key).to eq 'solr_documents/12345-1497353774427013120'
|
|
26
26
|
end
|
|
27
|
+
|
|
27
28
|
describe 'as array' do
|
|
28
29
|
let(:attributes) { { id: '12345', _version_: %w[1234 4321] } }
|
|
29
30
|
|
|
@@ -11,11 +11,13 @@ RSpec.describe "Blacklight::Document::Email" do
|
|
|
11
11
|
expect(email_body).to match(/Title: My Title/)
|
|
12
12
|
expect(email_body).not_to match(/Author/)
|
|
13
13
|
end
|
|
14
|
+
|
|
14
15
|
it "handles multi-values fields correctly" do
|
|
15
16
|
doc = SolrDocument.new(id: "1234", title_tsim: ["My Title", "My Alt. Title"])
|
|
16
17
|
email_body = doc.to_email_text
|
|
17
18
|
expect(email_body).to match(/Title: My Title My Alt. Title/)
|
|
18
19
|
end
|
|
20
|
+
|
|
19
21
|
it "returns nil if there are no valid field semantics to build the email body from" do
|
|
20
22
|
doc = SolrDocument.new(id: "1234")
|
|
21
23
|
expect(doc.to_email_text).to be_nil
|
|
@@ -10,12 +10,14 @@ RSpec.describe "Blacklight::Document::Email" do
|
|
|
10
10
|
sms_text = doc.to_sms_text
|
|
11
11
|
expect(sms_text).to match(/My Title by Joe Schmoe/)
|
|
12
12
|
end
|
|
13
|
+
|
|
13
14
|
it "handles multi-values fields correctly and only take the first" do
|
|
14
15
|
doc = SolrDocument.new(id: "1234", title_tsim: ["My Title", "My Alt. Title"])
|
|
15
16
|
sms_text = doc.to_sms_text
|
|
16
17
|
expect(sms_text).to match(/My Title/)
|
|
17
18
|
expect(sms_text).not_to match(/My Alt\. Title/)
|
|
18
19
|
end
|
|
20
|
+
|
|
19
21
|
it "returns nil if there are no valid field semantics to build the email body from" do
|
|
20
22
|
doc = SolrDocument.new(id: "1234")
|
|
21
23
|
expect(doc.to_sms_text).to be_nil
|
|
@@ -20,6 +20,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
|
|
|
20
20
|
its(:current_page) { is_expected.to eq 1 }
|
|
21
21
|
its(:prev_page) { is_expected.to be_nil }
|
|
22
22
|
its(:next_page) { is_expected.to eq 2 }
|
|
23
|
+
|
|
23
24
|
it 'limits items to limit, if limit is smaller than items.length' do
|
|
24
25
|
expect(subject.items.size).to eq 6
|
|
25
26
|
end
|
|
@@ -33,6 +34,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
|
|
|
33
34
|
its(:current_page) { is_expected.to eq 2 }
|
|
34
35
|
its(:prev_page) { is_expected.to eq 1 }
|
|
35
36
|
its(:next_page) { is_expected.to be_nil }
|
|
37
|
+
|
|
36
38
|
it 'returns all items when limit is greater than items.length' do
|
|
37
39
|
expect(subject.items.size).to eq 1
|
|
38
40
|
end
|
|
@@ -46,6 +48,7 @@ RSpec.describe Blacklight::FacetPaginator, api: true do
|
|
|
46
48
|
its(:current_page) { is_expected.to eq 2 }
|
|
47
49
|
its(:prev_page) { is_expected.to eq 1 }
|
|
48
50
|
its(:next_page) { is_expected.to eq 3 }
|
|
51
|
+
|
|
49
52
|
it 'limits items to limit, if limit is smaller than items.length' do
|
|
50
53
|
expect(subject.items.size).to eq 6
|
|
51
54
|
end
|
|
@@ -7,18 +7,22 @@ RSpec.describe Blacklight::Icon do
|
|
|
7
7
|
it 'returns a string' do
|
|
8
8
|
expect(subject.svg).to be_an String
|
|
9
9
|
end
|
|
10
|
+
|
|
10
11
|
it 'returns raw svg' do
|
|
11
12
|
expect(Capybara.string(subject.svg))
|
|
12
13
|
.to have_css 'svg[width="24"]'
|
|
13
14
|
end
|
|
15
|
+
|
|
14
16
|
it 'adds role="img"' do
|
|
15
17
|
expect(Capybara.string(subject.svg))
|
|
16
18
|
.to have_css 'svg[role="img"]'
|
|
17
19
|
end
|
|
20
|
+
|
|
18
21
|
it 'adds title' do
|
|
19
22
|
expect(Capybara.string(subject.svg))
|
|
20
23
|
.to have_css 'title', text: 'Search'
|
|
21
24
|
end
|
|
25
|
+
|
|
22
26
|
context 'when label is false' do
|
|
23
27
|
subject { described_class.new(:search, classes: 'awesome', aria_hidden: true, label: false) }
|
|
24
28
|
|
|
@@ -42,9 +46,11 @@ RSpec.describe Blacklight::Icon do
|
|
|
42
46
|
it 'applies options classes and default class' do
|
|
43
47
|
expect(subject.options[:class]).to eq 'blacklight-icons blacklight-icon-search awesome'
|
|
44
48
|
end
|
|
49
|
+
|
|
45
50
|
it 'applies options aria-hidden=true' do
|
|
46
51
|
expect(subject.options[:'aria-hidden']).to be true
|
|
47
52
|
end
|
|
53
|
+
|
|
48
54
|
context 'no options provided' do
|
|
49
55
|
subject { described_class.new(:view) }
|
|
50
56
|
|
|
@@ -80,10 +80,12 @@ RSpec.describe "Blacklight::Solr::Document", api: true do
|
|
|
80
80
|
|
|
81
81
|
expect(MockDocument.registered_extensions.find { |a| a[:module_obj] == MockExtension }).not_to be_nil
|
|
82
82
|
end
|
|
83
|
+
|
|
83
84
|
it "lets you register an extension with a nil condition proc" do
|
|
84
85
|
MockDocument.use_extension(MockExtension) { |_doc| true }
|
|
85
86
|
expect(MockDocument.registered_extensions.find { |a| a[:module_obj] == MockExtension }).not_to be_nil
|
|
86
87
|
end
|
|
88
|
+
|
|
87
89
|
it "applies an extension whose condition is met" do
|
|
88
90
|
MockDocument.use_extension(MockExtension) { |_doc| true }
|
|
89
91
|
doc = MockDocument.new
|
|
@@ -91,6 +93,7 @@ RSpec.describe "Blacklight::Solr::Document", api: true do
|
|
|
91
93
|
expect(doc.methods.find { |name| name.to_s == "my_extension_method" }).not_to be_nil
|
|
92
94
|
expect(doc.my_extension_method.to_s).to eq "my_extension_results"
|
|
93
95
|
end
|
|
96
|
+
|
|
94
97
|
it "applies an extension based on a Solr field" do
|
|
95
98
|
MockDocument.use_extension(MockExtension) { |doc| doc.key?(:required_key) }
|
|
96
99
|
|
|
@@ -100,12 +103,14 @@ RSpec.describe "Blacklight::Solr::Document", api: true do
|
|
|
100
103
|
without_extension = MockDocument.new(other_key: "value")
|
|
101
104
|
expect(without_extension.methods.find { |name| name.to_s == "my_extension_method" }).to be_nil
|
|
102
105
|
end
|
|
106
|
+
|
|
103
107
|
it "does not apply an extension whose condition is not met" do
|
|
104
108
|
MockDocument.use_extension(MockExtension) { |_doc| false }
|
|
105
109
|
doc = MockDocument.new
|
|
106
110
|
|
|
107
111
|
expect(doc.methods.find { |name| name.to_s == "my_extension_method" }).to be_nil
|
|
108
112
|
end
|
|
113
|
+
|
|
109
114
|
it "treats a nil condition as always applyable" do
|
|
110
115
|
MockDocument.use_extension(MockExtension)
|
|
111
116
|
|
|
@@ -114,6 +119,7 @@ RSpec.describe "Blacklight::Solr::Document", api: true do
|
|
|
114
119
|
expect(doc.methods.find { |name| name.to_s == "my_extension_method" }).not_to be_nil
|
|
115
120
|
expect(doc.my_extension_method).to eq "my_extension_results"
|
|
116
121
|
end
|
|
122
|
+
|
|
117
123
|
it "lets last extension applied override earlier extensions" do
|
|
118
124
|
MockDocument.use_extension(MockExtension)
|
|
119
125
|
MockDocument.use_extension(MockSecondExtension)
|
|
@@ -176,6 +182,7 @@ RSpec.describe "Blacklight::Solr::Document", api: true do
|
|
|
176
182
|
it "registers format" do
|
|
177
183
|
expect(defined?("Mime::MOCK2")).to be_truthy
|
|
178
184
|
end
|
|
185
|
+
|
|
179
186
|
it "registers as alias only" do
|
|
180
187
|
expect(Mime::Type.lookup("application/mock2")).not_to equal Mime::Type.lookup_by_extension("mock2")
|
|
181
188
|
end
|
|
@@ -217,13 +224,16 @@ RSpec.describe "Blacklight::Solr::Document", api: true do
|
|
|
217
224
|
expect(@doc1.to_semantic_values)
|
|
218
225
|
.to eq title: ["doc1 title", "doc1 title other"], something: %w[val1 val2]
|
|
219
226
|
end
|
|
227
|
+
|
|
220
228
|
it "returns empty array for a key without a value" do
|
|
221
229
|
expect(@doc1.to_semantic_values[:author]).to be_empty
|
|
222
230
|
expect(@doc1.to_semantic_values[:nonexistent_token]).to be_empty
|
|
223
231
|
end
|
|
232
|
+
|
|
224
233
|
it "returns an array even for a single-value field" do
|
|
225
234
|
expect(@doc1.to_semantic_values[:title]).to be_kind_of(Array)
|
|
226
235
|
end
|
|
236
|
+
|
|
227
237
|
it "returns complete array for a multi-value field" do
|
|
228
238
|
expect(@doc1.to_semantic_values[:something]).to eq %w[val1 val2]
|
|
229
239
|
end
|