blacklight 7.15.1 → 7.17.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/VERSION +1 -1
- data/app/components/blacklight/advanced_search_form_component.html.erb +9 -3
- data/app/components/blacklight/advanced_search_form_component.rb +48 -35
- data/app/components/blacklight/constraints_component.html.erb +19 -3
- data/app/components/blacklight/constraints_component.rb +5 -1
- data/app/components/blacklight/content_areas_shim.rb +12 -0
- data/app/components/blacklight/document/action_component.html.erb +1 -1
- data/app/components/blacklight/document/action_component.rb +6 -1
- data/app/components/blacklight/document/actions_component.html.erb +3 -5
- data/app/components/blacklight/document/actions_component.rb +16 -2
- data/app/components/blacklight/document_component.html.erb +4 -7
- data/app/components/blacklight/document_component.rb +73 -73
- data/app/components/blacklight/document_metadata_component.html.erb +2 -2
- data/app/components/blacklight/document_metadata_component.rb +13 -2
- data/app/components/blacklight/document_title_component.html.erb +17 -0
- data/app/components/blacklight/document_title_component.rb +59 -0
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_component.rb +4 -1
- data/app/components/blacklight/facet_field_list_component.html.erb +2 -2
- data/app/components/blacklight/facet_field_no_layout_component.rb +4 -1
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_layout_component.html.erb +3 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +26 -1
- data/app/components/blacklight/response/view_type_button_component.html.erb +4 -0
- data/app/components/blacklight/response/view_type_button_component.rb +38 -0
- data/app/components/blacklight/response/view_type_component.html.erb +2 -5
- data/app/components/blacklight/response/view_type_component.rb +9 -13
- data/app/components/blacklight/search_bar_component.rb +9 -2
- data/app/components/blacklight/system/dropdown_component.html.erb +4 -7
- data/app/components/blacklight/system/dropdown_component.rb +24 -0
- data/app/components/blacklight/system/flash_message_component.html.erb +1 -1
- data/app/components/blacklight/system/flash_message_component.rb +7 -1
- data/app/components/blacklight/system/modal_component.rb +7 -1
- data/app/controllers/concerns/blacklight/catalog.rb +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -4
- data/app/helpers/blacklight/catalog_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/presenters/blacklight/document_presenter.rb +8 -4
- data/app/services/blacklight/search_service.rb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_document.html.erb +2 -2
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_show_main_content.html.erb +3 -3
- data/app/views/catalog/email.html.erb +2 -2
- data/app/views/catalog/email_success.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +3 -3
- data/app/views/catalog/sms.html.erb +2 -2
- data/app/views/catalog/sms_success.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.de.yml +2 -2
- data/lib/blacklight/configuration.rb +50 -5
- data/lib/blacklight/configuration/view_config.rb +18 -5
- data/lib/blacklight/engine.rb +3 -1
- data/lib/blacklight/open_struct_with_hash_access.rb +22 -1
- data/lib/blacklight/search_state.rb +2 -2
- data/lib/blacklight/solr/facet_paginator.rb +2 -0
- data/lib/blacklight/solr/request.rb +31 -0
- data/lib/blacklight/solr/response.rb +2 -16
- data/lib/blacklight/solr/response/facets.rb +76 -22
- data/lib/blacklight/solr/response/params.rb +104 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +57 -27
- data/lib/generators/blacklight/assets_generator.rb +6 -2
- data/lib/generators/blacklight/user_generator.rb +1 -1
- data/spec/components/blacklight/document_component_spec.rb +3 -3
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +20 -0
- data/spec/models/blacklight/configuration_spec.rb +64 -0
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +4 -0
- data/spec/models/blacklight/solr/request_spec.rb +62 -29
- data/spec/models/blacklight/solr/response/facets_spec.rb +109 -0
- data/spec/models/blacklight/solr/response_spec.rb +10 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +49 -0
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +8 -9
- data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
- metadata +10 -4
@@ -68,11 +68,15 @@ module Blacklight
|
|
68
68
|
private
|
69
69
|
|
70
70
|
def turbolinks?
|
71
|
-
@turbolinks ||=
|
71
|
+
@turbolinks ||= application_js.include?('turbolinks')
|
72
72
|
end
|
73
73
|
|
74
74
|
def has_blacklight_assets?
|
75
|
-
|
75
|
+
application_js.include?('blacklight/blacklight')
|
76
|
+
end
|
77
|
+
|
78
|
+
def application_js
|
79
|
+
IO.read(File.expand_path("app/assets/javascripts/application.js", destination_root))
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -47,7 +47,7 @@ module Blacklight
|
|
47
47
|
# Add Blacklight to the user model
|
48
48
|
def inject_blacklight_user_behavior
|
49
49
|
file_path = "app/models/#{model_name.underscore}.rb"
|
50
|
-
if File.exist?(file_path)
|
50
|
+
if File.exist?(File.expand_path(file_path, destination_root))
|
51
51
|
inject_into_class file_path, model_name.classify do
|
52
52
|
"\n # Connects this user object to Blacklights Bookmarks." \
|
53
53
|
"\n include Blacklight::User\n"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::DocumentComponent, type: :component do
|
6
|
-
subject(:component) { described_class.new(document: document, **attr) }
|
6
|
+
subject(:component) { described_class.new(document: document, presenter: view_context.document_presenter(document), **attr) }
|
7
7
|
|
8
8
|
let(:attr) { {} }
|
9
9
|
let(:view_context) { controller.view_context }
|
@@ -47,7 +47,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
47
47
|
component.with(:embed, 'Embed')
|
48
48
|
component.with(:metadata, 'Metadata')
|
49
49
|
component.with(:thumbnail, 'Thumbnail')
|
50
|
-
component.with(:actions
|
50
|
+
component.with(:actions) { 'Actions' }
|
51
51
|
|
52
52
|
expect(rendered).to have_content 'Title'
|
53
53
|
expect(rendered).to have_content 'Embed'
|
@@ -65,7 +65,7 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
65
65
|
|
66
66
|
context 'with a provided body' do
|
67
67
|
it 'opts-out of normal component content' do
|
68
|
-
component.with(:body
|
68
|
+
component.with(:body) { 'Body content' }
|
69
69
|
|
70
70
|
expect(rendered).to have_content 'Body content'
|
71
71
|
expect(rendered).not_to have_selector 'header'
|
@@ -9,7 +9,7 @@ RSpec.describe Blacklight::Configuration::ViewConfig do
|
|
9
9
|
describe '#display_label' do
|
10
10
|
it "looks up the label to display for the given document and field" do
|
11
11
|
allow(I18n).to receive(:t).with(:"blacklight.search.view_title.my_view", default: [:"blacklight.search.view.my_view", label, nil, "My view"]).and_return('x')
|
12
|
-
expect(subject.display_label
|
12
|
+
expect(subject.display_label).to eq 'x'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -123,6 +123,18 @@ RSpec.describe Blacklight::OpenStructWithHashAccess do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
describe '#reverse_merge' do
|
127
|
+
before do
|
128
|
+
@h = described_class.new
|
129
|
+
@h[:a] = 1
|
130
|
+
@h[:b] = 2
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'reverse merges the object with the hash, preserving the object class' do
|
134
|
+
expect(@h.reverse_merge(b: 3, c: 4)).to have_attributes a: 1, b: 2, c: 4
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
126
138
|
describe "#to_json" do
|
127
139
|
subject { described_class.new a: 1, b: 2 }
|
128
140
|
|
@@ -145,4 +157,12 @@ RSpec.describe Blacklight::OpenStructWithHashAccess do
|
|
145
157
|
expect(copy.b[:c]).to eq 2
|
146
158
|
end
|
147
159
|
end
|
160
|
+
|
161
|
+
describe "#try" do
|
162
|
+
subject { described_class.new a: 1 }
|
163
|
+
|
164
|
+
it "works (and doesn't throw a stack error...)" do
|
165
|
+
expect(subject.try(:a)).to eq 1
|
166
|
+
end
|
167
|
+
end
|
148
168
|
end
|
@@ -557,4 +557,68 @@ RSpec.describe "Blacklight::Configuration", api: true do
|
|
557
557
|
expect(config.facet_paginator_class).to eq Blacklight::Solr::FacetPaginator
|
558
558
|
end
|
559
559
|
end
|
560
|
+
|
561
|
+
describe '#view_config' do
|
562
|
+
before do
|
563
|
+
config.index.title_field = 'title_tsim'
|
564
|
+
end
|
565
|
+
|
566
|
+
context 'with a view that does not exist' do
|
567
|
+
it 'defaults to the index config' do
|
568
|
+
expect(config.view_config('this-doesnt-exist')).to have_attributes config.index.to_h
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
context 'with the :show view' do
|
573
|
+
it 'includes the show config' do
|
574
|
+
expect(config.view_config(:show)).to have_attributes config.show.to_h
|
575
|
+
end
|
576
|
+
|
577
|
+
it 'uses the show document presenter' do
|
578
|
+
expect(config.view_config(:show)).to have_attributes document_presenter_class: Blacklight::ShowPresenter
|
579
|
+
end
|
580
|
+
|
581
|
+
it 'includes index config defaults' do
|
582
|
+
expect(config.view_config(:show)).to have_attributes title_field: 'title_tsim'
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
context 'with just an action name' do
|
587
|
+
it 'includes the action config' do
|
588
|
+
expect(config.view_config(action_name: :show)).to have_attributes config.show.to_h
|
589
|
+
end
|
590
|
+
|
591
|
+
it 'includes the default action mapping configuration' do
|
592
|
+
config.action_mapping.default.whatever = :some_value
|
593
|
+
|
594
|
+
expect(config.view_config(action_name: :show)).to have_attributes whatever: :some_value
|
595
|
+
end
|
596
|
+
|
597
|
+
it 'includes the action-specific mappings' do
|
598
|
+
config.action_mapping.foo.document_presenter_class = Blacklight::DocumentPresenter
|
599
|
+
|
600
|
+
expect(config.view_config(action_name: :foo)).to have_attributes config.action_mapping.foo.to_h
|
601
|
+
end
|
602
|
+
|
603
|
+
it 'allows the action mapping to specific a parent configuration with some more defaults' do
|
604
|
+
config.action_mapping.foo.parent_config = :bar
|
605
|
+
config.action_mapping.bar.whatever = :bar_value
|
606
|
+
|
607
|
+
expect(config.view_config(action_name: :foo)).to have_attributes whatever: :bar_value
|
608
|
+
end
|
609
|
+
|
610
|
+
context 'with the :citation action' do
|
611
|
+
it 'also includes the show config' do
|
612
|
+
expect(config.view_config(action_name: :citation)).to have_attributes config.show.to_h
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
context 'with a view' do
|
618
|
+
it 'includes the configuration-level view parameters' do
|
619
|
+
expect(config.view_config(:atom)).to have_attributes config.index.to_h.except(:partials)
|
620
|
+
expect(config.view_config(:atom)).to have_attributes partials: [:document]
|
621
|
+
end
|
622
|
+
end
|
623
|
+
end
|
560
624
|
end
|
@@ -20,5 +20,9 @@ RSpec.describe Blacklight::Solr::FacetPaginator, api: true do
|
|
20
20
|
it 'defaults to "index" if no limit is given' do
|
21
21
|
expect(described_class.new([]).sort).to eq 'index'
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'handles json facet api-style parameter sorts' do
|
25
|
+
expect(described_class.new([], sort: { count: :desc }).sort).to eq 'count'
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
@@ -1,36 +1,69 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RSpec.describe Blacklight::Solr::Request, api: true do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
context 'with some solr parameter keys' do
|
5
|
+
before do
|
6
|
+
subject[:qt] = 'hey'
|
7
|
+
subject[:fq] = ["what's up.", "dood"]
|
8
|
+
subject['q'] = "what's"
|
9
|
+
subject[:wt] = "going"
|
10
|
+
subject[:start] = "on"
|
11
|
+
subject[:rows] = "Man"
|
12
|
+
subject['hl'] = "I"
|
13
|
+
subject['hl.fl'] = "wish"
|
14
|
+
subject['group'] = "I"
|
15
|
+
subject['defType'] = "had"
|
16
|
+
subject['spellcheck'] = "a"
|
17
|
+
subject['spellcheck.q'] = "fleece"
|
18
|
+
subject['f.title_facet.facet.limit'] = "vest"
|
19
|
+
subject['facet.field'] = []
|
20
|
+
end
|
21
|
+
|
22
|
+
it "accepts valid parameters" do
|
23
|
+
expect(subject.to_hash).to eq("defType" => "had",
|
24
|
+
"f.title_facet.facet.limit" => "vest",
|
25
|
+
"fq" => ["what's up.", "dood"],
|
26
|
+
"group" => "I",
|
27
|
+
"hl" => "I",
|
28
|
+
"hl.fl" => "wish",
|
29
|
+
"q" => "what's",
|
30
|
+
"qt" => "hey",
|
31
|
+
"rows" => "Man",
|
32
|
+
"spellcheck" => "a",
|
33
|
+
"spellcheck.q" => "fleece",
|
34
|
+
"start" => "on",
|
35
|
+
"wt" => "going")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#append_query' do
|
40
|
+
it 'populates the q parameter' do
|
41
|
+
subject.append_query 'this is my query'
|
42
|
+
expect(subject['q']).to eq 'this is my query'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'handles multiple queries by converting it to a boolean query' do
|
46
|
+
subject.append_query 'this is my query'
|
47
|
+
subject.append_query 'another:query'
|
48
|
+
expect(subject).not_to have_key 'q'
|
49
|
+
expect(subject.dig('json', 'query', 'bool', 'must')).to match_array ['this is my query', 'another:query']
|
50
|
+
end
|
19
51
|
end
|
20
52
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
53
|
+
describe '#append_boolean_query' do
|
54
|
+
it 'populates the boolean query with the queries' do
|
55
|
+
subject.append_boolean_query :must, 'required'
|
56
|
+
subject.append_boolean_query :should, 'optional'
|
57
|
+
subject.append_boolean_query :should, 'also optional'
|
58
|
+
|
59
|
+
expect(subject.dig('json', 'query', 'bool')).to include should: ['optional', 'also optional'], must: ['required']
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'converts existing q parameters to a boolean query' do
|
63
|
+
subject['q'] = 'some query'
|
64
|
+
subject.append_boolean_query :must, 'also required'
|
65
|
+
|
66
|
+
expect(subject.dig('json', 'query', 'bool', 'must')).to match_array ['some query', 'also required']
|
67
|
+
end
|
35
68
|
end
|
36
69
|
end
|
@@ -160,6 +160,12 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
|
|
160
160
|
expect(missing.label).to eq "[Missing]"
|
161
161
|
expect(missing.fq).to eq "-some_field:[* TO *]"
|
162
162
|
end
|
163
|
+
|
164
|
+
it 'extracts the missing field data to a separate facet field attribute' do
|
165
|
+
missing = subject.aggregations["some_field"].missing
|
166
|
+
|
167
|
+
expect(missing).to have_attributes(label: '[Missing]', hits: 2)
|
168
|
+
end
|
163
169
|
end
|
164
170
|
|
165
171
|
describe "query facets" do
|
@@ -278,4 +284,107 @@ RSpec.describe Blacklight::Solr::Response::Facets, api: true do
|
|
278
284
|
expect(field.items.first.items.first.fq).to eq('field_a' => 'a')
|
279
285
|
end
|
280
286
|
end
|
287
|
+
|
288
|
+
describe 'json facets' do
|
289
|
+
subject { Blacklight::Solr::Response.new(response, {}, blacklight_config: blacklight_config) }
|
290
|
+
|
291
|
+
let(:response) do
|
292
|
+
{
|
293
|
+
facets: {
|
294
|
+
"count": 32,
|
295
|
+
"categories": {
|
296
|
+
"buckets": [
|
297
|
+
{
|
298
|
+
"val": "electronics",
|
299
|
+
"count": 12,
|
300
|
+
"max_price": 60
|
301
|
+
},
|
302
|
+
{
|
303
|
+
"val": "currency",
|
304
|
+
"count": 4
|
305
|
+
},
|
306
|
+
{
|
307
|
+
"val": "memory",
|
308
|
+
"count": 3
|
309
|
+
}
|
310
|
+
]
|
311
|
+
}
|
312
|
+
}
|
313
|
+
}
|
314
|
+
end
|
315
|
+
let(:facet_config) do
|
316
|
+
Blacklight::Configuration::FacetField.new(key: 'categories', json: true, query: false)
|
317
|
+
end
|
318
|
+
|
319
|
+
let(:blacklight_config) { double(facet_fields: { 'categories' => facet_config }) }
|
320
|
+
let(:field) { subject.aggregations['categories'] }
|
321
|
+
|
322
|
+
it 'has access to the original response data' do
|
323
|
+
expect(field.data).to include 'buckets'
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'converts buckets into facet items' do
|
327
|
+
expect(field.items.length).to eq 3
|
328
|
+
end
|
329
|
+
|
330
|
+
context 'with nested buckets' do
|
331
|
+
let(:response) do
|
332
|
+
{
|
333
|
+
facets: {
|
334
|
+
"categories": {
|
335
|
+
"buckets": [
|
336
|
+
{
|
337
|
+
"val": "electronics",
|
338
|
+
"count": 12,
|
339
|
+
"top_manufacturer": {
|
340
|
+
"buckets": [{
|
341
|
+
"val": "corsair",
|
342
|
+
"count": 3
|
343
|
+
}]
|
344
|
+
}
|
345
|
+
},
|
346
|
+
{
|
347
|
+
"val": "currency",
|
348
|
+
"count": 4,
|
349
|
+
"top_manufacturer": {
|
350
|
+
"buckets": [{
|
351
|
+
"val": "boa",
|
352
|
+
"count": 1
|
353
|
+
}]
|
354
|
+
}
|
355
|
+
}
|
356
|
+
]
|
357
|
+
}
|
358
|
+
}
|
359
|
+
}
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'converts nested buckets into pivot facets' do
|
363
|
+
expect(field.items.first).to have_attributes hits: 12
|
364
|
+
expect(field.items.first.items.first).to have_attributes field: 'top_manufacturer', value: 'corsair', hits: 3, fq: { "categories" => "electronics" }
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
context 'with missing values' do
|
369
|
+
let(:response) do
|
370
|
+
{
|
371
|
+
facets: {
|
372
|
+
"categories": {
|
373
|
+
"missing" => { "count" => 13 },
|
374
|
+
"buckets" => [{ "val" => "India", "count" => 2 }, { "val" => "Iran", "count" => 2 }]
|
375
|
+
}
|
376
|
+
}
|
377
|
+
}
|
378
|
+
end
|
379
|
+
|
380
|
+
it 'converts "missing" facet data into a missing facet item' do
|
381
|
+
expect(field.items.length).to eq 2
|
382
|
+
expect(field.missing).to have_attributes(hits: 13)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
it 'exposes any extra query function results' do
|
387
|
+
expect(field.items.first.data).to include 'max_price' => 60
|
388
|
+
end
|
389
|
+
end
|
281
390
|
end
|
@@ -120,6 +120,16 @@ RSpec.describe Blacklight::Solr::Response, api: true do
|
|
120
120
|
expect(r.params['test']).to eq :test
|
121
121
|
end
|
122
122
|
|
123
|
+
it 'extracts json params' do
|
124
|
+
raw_response = eval(mock_query_response)
|
125
|
+
raw_response['responseHeader']['params']['test'] = 'from query'
|
126
|
+
raw_response['responseHeader']['params'].delete('rows')
|
127
|
+
raw_response['responseHeader']['params']['json'] = { limit: 5, params: { test: 'from json params' } }.to_json
|
128
|
+
r = described_class.new(raw_response, raw_response['params'])
|
129
|
+
expect(r.params['test']).to eq 'from query'
|
130
|
+
expect(r.rows).to eq 5
|
131
|
+
end
|
132
|
+
|
123
133
|
it 'provides the solr-returned params and "rows" should be 11' do
|
124
134
|
raw_response = eval(mock_query_response)
|
125
135
|
r = described_class.new(raw_response, {})
|
@@ -259,6 +259,23 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
+
describe 'with a json facet' do
|
263
|
+
let(:user_params) { { f: { json_facet: ['value'] } }.with_indifferent_access }
|
264
|
+
|
265
|
+
before do
|
266
|
+
blacklight_config.add_facet_field 'json_facet', field: 'foo', json: { bar: 'baz' }
|
267
|
+
end
|
268
|
+
|
269
|
+
it "has proper solr parameters" do
|
270
|
+
expect(subject[:fq]).to include('{!term f=foo}value')
|
271
|
+
expect(subject.dig(:json, :facet, 'json_facet')).to include(
|
272
|
+
field: 'foo',
|
273
|
+
type: 'terms',
|
274
|
+
bar: 'baz'
|
275
|
+
)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
262
279
|
describe 'with multi-valued facets' do
|
263
280
|
let(:user_params) { { f_inclusive: { format: %w[Book Movie CD] } } }
|
264
281
|
|
@@ -321,6 +338,38 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, api: true do
|
|
321
338
|
end
|
322
339
|
end
|
323
340
|
|
341
|
+
describe "solr json query parameters from the fielded search" do
|
342
|
+
let(:user_params) { subject_search_params }
|
343
|
+
|
344
|
+
before do
|
345
|
+
blacklight_config.search_fields['subject'].solr_parameters = {
|
346
|
+
some: :parameter
|
347
|
+
}
|
348
|
+
|
349
|
+
blacklight_config.search_fields['subject'].clause_params = {
|
350
|
+
edismax: {
|
351
|
+
another: :parameter
|
352
|
+
}
|
353
|
+
}
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'sets solr parameters from the field' do
|
357
|
+
expect(subject[:some]).to eq :parameter
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'does not set a q parameter' do
|
361
|
+
expect(subject).not_to have_key :q
|
362
|
+
end
|
363
|
+
|
364
|
+
it 'includes the user query in the JSON query DSL request' do
|
365
|
+
expect(subject.dig(:json, :query, :bool, :must, 0, :edismax)).to include query: 'wome'
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'includes addtional clause parameters for the field' do
|
369
|
+
expect(subject.dig(:json, :query, :bool, :must, 0, :edismax)).to include another: :parameter
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
324
373
|
describe "overriding of qt parameter" do
|
325
374
|
let(:user_params) do
|
326
375
|
{ qt: 'overridden' }
|