blacklight 9.0.0.beta7 → 9.0.0.beta8
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/.docker/app/Dockerfile +2 -1
- data/.github/matrix.json +14 -3
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js +7 -4
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +7 -4
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +2 -1
- data/app/components/blacklight/document_component.rb +10 -13
- data/app/components/blacklight/facets/filters_component.rb +1 -1
- data/app/components/blacklight/facets/suggest_component.rb +2 -3
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +2 -1
- data/app/components/blacklight/metadata_field_layout_component.rb +9 -4
- data/app/components/blacklight/search_bar_component.html.erb +1 -1
- data/app/javascript/blacklight-frontend/modal.js +7 -4
- data/app/presenters/blacklight/document_presenter.rb +6 -5
- data/app/presenters/blacklight/facet_field_presenter.rb +10 -3
- data/app/presenters/blacklight/field_presenter.rb +4 -2
- data/app/presenters/blacklight/rendering/abstract_step.rb +7 -1
- data/app/presenters/blacklight/rendering/join.rb +9 -5
- data/app/presenters/blacklight/rendering/terminator.rb +1 -1
- data/app/views/catalog/_show_main_content.html.erb +9 -5
- data/app/views/catalog/index.html.erb +0 -1
- data/app/views/catalog/show.html.erb +2 -2
- data/config/locales/blacklight.en.yml +1 -1
- data/lib/blacklight/component.rb +2 -0
- data/lib/blacklight/configuration/facet_field.rb +2 -0
- data/lib/blacklight/configuration/view_config.rb +30 -16
- data/lib/blacklight/configuration.rb +56 -5
- data/lib/blacklight/search_state/pivot_filter_field.rb +1 -1
- data/lib/blacklight/solr/field_reflection_search_builder.rb +11 -0
- data/lib/blacklight/solr/repository.rb +5 -5
- data/lib/blacklight/solr/search_builder_behavior.rb +19 -2
- data/lib/blacklight/solr/single_doc_search_builder.rb +25 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +26 -4
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -67
- data/package.json +1 -1
- data/spec/components/blacklight/document_component_spec.rb +0 -7
- data/spec/components/blacklight/facets/filters_component_spec.rb +2 -2
- data/spec/components/blacklight/facets/suggest_component_spec.rb +13 -0
- data/spec/components/blacklight/search_bar_component_spec.rb +24 -1
- data/spec/controllers/blacklight/catalog_spec.rb +1 -1
- data/spec/features/advanced_search_spec.rb +39 -20
- data/spec/models/blacklight/configuration_spec.rb +126 -0
- data/spec/models/blacklight/solr/repository_spec.rb +6 -0
- data/spec/models/blacklight/solr/search_builder_behavior_spec.rb +52 -6
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -3
- data/spec/presenters/blacklight/field_presenter_spec.rb +103 -22
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +130 -14
- metadata +4 -5
- data/app/views/shared/_sitelinks_search_box.html.erb +0 -12
- data/spec/features/sitelinks_search_box_spec.rb +0 -13
|
@@ -98,73 +98,6 @@
|
|
|
98
98
|
</arr>
|
|
99
99
|
</requestHandler>
|
|
100
100
|
|
|
101
|
-
<requestHandler name="/advanced" class="solr.SearchHandler">
|
|
102
|
-
<!-- a lucene request handler for using the JSON Query DSL,
|
|
103
|
-
specifically for advanced search.
|
|
104
|
-
Using a separate requestHandler is a workaround to
|
|
105
|
-
https://issues.apache.org/jira/browse/SOLR-16916, although
|
|
106
|
-
it could be desirable for other reasons as well.
|
|
107
|
-
-->
|
|
108
|
-
<lst name="defaults">
|
|
109
|
-
<str name="defType">lucene</str>
|
|
110
|
-
<str name="echoParams">explicit</str>
|
|
111
|
-
<str name="df">title_tsim</str>
|
|
112
|
-
<str name="qf">
|
|
113
|
-
id
|
|
114
|
-
full_title_tsim
|
|
115
|
-
short_title_tsim
|
|
116
|
-
alternative_title_tsim
|
|
117
|
-
title_tsim
|
|
118
|
-
author_tsim
|
|
119
|
-
subject_tsim
|
|
120
|
-
all_text_timv
|
|
121
|
-
</str>
|
|
122
|
-
<str name="pf">
|
|
123
|
-
all_text_timv^10
|
|
124
|
-
</str>
|
|
125
|
-
|
|
126
|
-
<str name="author_qf">
|
|
127
|
-
author_tsim
|
|
128
|
-
</str>
|
|
129
|
-
<str name="author_pf">
|
|
130
|
-
</str>
|
|
131
|
-
<str name="title_qf">
|
|
132
|
-
title_tsim
|
|
133
|
-
full_title_tsim
|
|
134
|
-
short_title_tsim
|
|
135
|
-
alternative_title_tsim
|
|
136
|
-
</str>
|
|
137
|
-
<str name="title_pf">
|
|
138
|
-
</str>
|
|
139
|
-
<str name="subject_qf">
|
|
140
|
-
subject_tsim
|
|
141
|
-
</str>
|
|
142
|
-
<str name="subject_pf">
|
|
143
|
-
</str>
|
|
144
|
-
|
|
145
|
-
<str name="fl">
|
|
146
|
-
*,
|
|
147
|
-
score
|
|
148
|
-
</str>
|
|
149
|
-
|
|
150
|
-
<str name="facet">true</str>
|
|
151
|
-
<str name="facet.mincount">1</str>
|
|
152
|
-
<str name="facet.limit">10</str>
|
|
153
|
-
<str name="facet.field">subject_ssim</str>
|
|
154
|
-
|
|
155
|
-
<str name="spellcheck">true</str>
|
|
156
|
-
<str name="spellcheck.dictionary">default</str>
|
|
157
|
-
<str name="spellcheck.onlyMorePopular">true</str>
|
|
158
|
-
<str name="spellcheck.extendedResults">true</str>
|
|
159
|
-
<str name="spellcheck.collate">false</str>
|
|
160
|
-
<str name="spellcheck.count">5</str>
|
|
161
|
-
|
|
162
|
-
</lst>
|
|
163
|
-
<arr name="last-components">
|
|
164
|
-
<str>spellcheck</str>
|
|
165
|
-
</arr>
|
|
166
|
-
</requestHandler>
|
|
167
|
-
|
|
168
101
|
<requestHandler name="permissions" class="solr.SearchHandler" >
|
|
169
102
|
<lst name="defaults">
|
|
170
103
|
<str name="facet">off</str>
|
data/package.json
CHANGED
|
@@ -136,13 +136,6 @@ RSpec.describe Blacklight::DocumentComponent, type: :component do
|
|
|
136
136
|
vc_test_controller.action_name = "show"
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
-
it 'renders with an id' do
|
|
140
|
-
component.with_body { '-' }
|
|
141
|
-
render_inline component
|
|
142
|
-
|
|
143
|
-
expect(page).to have_css 'article#document'
|
|
144
|
-
end
|
|
145
|
-
|
|
146
139
|
it 'renders a title' do
|
|
147
140
|
render_inline component
|
|
148
141
|
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
RSpec.describe Blacklight::Facets::FiltersComponent, type: :component do
|
|
6
|
-
let(:facet_field) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest
|
|
6
|
+
let(:facet_field) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest?: true }
|
|
7
7
|
let(:presenter) do
|
|
8
8
|
instance_double(Blacklight::FacetFieldPresenter, facet_field: facet_field, label: 'Lang',
|
|
9
|
-
view_context: view_context, suggest
|
|
9
|
+
view_context: view_context, suggest?: true, key: 'lang')
|
|
10
10
|
end
|
|
11
11
|
let(:view_context) { vc_test_controller.view_context }
|
|
12
12
|
|
|
@@ -58,6 +58,7 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
|
|
58
58
|
|
|
59
59
|
context 'when the facet is not explicitly configured with a suggest key' do
|
|
60
60
|
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet' }
|
|
61
|
+
let(:presenter) { Blacklight::FacetFieldPresenter.new(facet, nil, vc_test_controller.view_context, nil) }
|
|
61
62
|
|
|
62
63
|
it 'displays' do
|
|
63
64
|
with_request_url "/catalog/facet/language_facet" do
|
|
@@ -65,5 +66,17 @@ RSpec.describe Blacklight::Facets::SuggestComponent, type: :component do
|
|
|
65
66
|
expect(rendered.css("input.facet-suggest").count).to eq 1
|
|
66
67
|
end
|
|
67
68
|
end
|
|
69
|
+
|
|
70
|
+
context "with blacklight_config.default_facet_suggest = false" do
|
|
71
|
+
before do
|
|
72
|
+
allow(vc_test_controller.view_context.blacklight_config).to receive(:default_facet_suggest).and_return(false)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'does not display' do
|
|
76
|
+
with_request_url "/catalog/facet/language_facet" do
|
|
77
|
+
expect(render_inline(component).to_s).to eq ''
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
68
81
|
end
|
|
69
82
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
6
|
-
let(:instance) { described_class.new(url: search_action_url, params: params_for_search) }
|
|
6
|
+
let(:instance) { described_class.new(url: search_action_url, params: params_for_search, advanced_search_url: '/advanced') }
|
|
7
7
|
|
|
8
8
|
let(:search_action_url) { '/catalog' }
|
|
9
9
|
let(:params_for_search) { { q: 'testParamValue' } }
|
|
@@ -104,4 +104,27 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
|
104
104
|
expect(render.css('.rounded-0')).to be_present
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
+
|
|
108
|
+
context 'advanced search link' do
|
|
109
|
+
subject(:render) { render_inline(instance) }
|
|
110
|
+
|
|
111
|
+
context 'when enabled (default)' do
|
|
112
|
+
it 'renders the advanced search link' do
|
|
113
|
+
expect(render.css("a.advanced_search.btn.btn-link[href='/advanced']")).to be_present
|
|
114
|
+
expect(render.css("a.advanced_search").text).to eq('Advanced search')
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
context 'when disabled via configuration' do
|
|
119
|
+
let(:blacklight_config) do
|
|
120
|
+
Blacklight::Configuration.new.configure do |config|
|
|
121
|
+
config.advanced_search.enabled = false
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'does not render the advanced search link' do
|
|
126
|
+
expect(render.css("a.advanced_search")).not_to be_present
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
107
130
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
RSpec.describe Blacklight::Catalog do
|
|
4
4
|
subject { controller }
|
|
5
5
|
|
|
6
|
-
let(:controller) {
|
|
6
|
+
let(:controller) { Class.new(ApplicationController) { include Blacklight::Catalog }.new }
|
|
7
7
|
|
|
8
8
|
describe "#search_state" do
|
|
9
9
|
subject { controller.send(:search_state) }
|
|
@@ -5,25 +5,7 @@ require 'spec_helper'
|
|
|
5
5
|
RSpec.describe "Blacklight Advanced Search Form" do
|
|
6
6
|
describe "advanced search form" do
|
|
7
7
|
before do
|
|
8
|
-
|
|
9
|
-
edismax: {}
|
|
10
|
-
}
|
|
11
|
-
CatalogController.blacklight_config.search_fields['author']['clause_params'] = {
|
|
12
|
-
edismax: { qf: '${author_qf}' }
|
|
13
|
-
}
|
|
14
|
-
CatalogController.blacklight_config.search_fields['title']['clause_params'] = {
|
|
15
|
-
edismax: { qf: '${title_qf}' }
|
|
16
|
-
}
|
|
17
|
-
CatalogController.blacklight_config.search_fields['subject']['clause_params'] = {
|
|
18
|
-
edismax: { qf: '${subject_qf}' }
|
|
19
|
-
}
|
|
20
|
-
visit '/catalog/advanced?hypothetical_existing_param=true&q=ignore+this+existing+query'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
after do
|
|
24
|
-
%w[all_fields author title subject].each do |field|
|
|
25
|
-
CatalogController.blacklight_config.search_fields[field].delete(:clause_params)
|
|
26
|
-
end
|
|
8
|
+
visit '/catalog/advanced'
|
|
27
9
|
end
|
|
28
10
|
|
|
29
11
|
it "has field and facet blocks" do
|
|
@@ -56,6 +38,16 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
56
38
|
expect(page).to have_content 'Language'
|
|
57
39
|
end
|
|
58
40
|
end
|
|
41
|
+
|
|
42
|
+
it "omits facets configured with include_in_advanced_search: false" do
|
|
43
|
+
expect(page).to have_no_css('.blacklight-example_pivot_field')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "lists all the values for an included facet" do
|
|
47
|
+
within('.blacklight-subject_ssim') do
|
|
48
|
+
expect(page).to have_css('ul.facet-values li', count: 45)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
59
51
|
end
|
|
60
52
|
|
|
61
53
|
it 'scopes searches to fields' do
|
|
@@ -66,6 +58,14 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
66
58
|
expect(page).to have_css('article.document', count: 1)
|
|
67
59
|
end
|
|
68
60
|
|
|
61
|
+
it 'does not render spellcheck/did you mean? section' do
|
|
62
|
+
fill_in 'All Fields', with: 'tibet'
|
|
63
|
+
click_on 'advanced-search-submit'
|
|
64
|
+
expect(page).to have_content 'Remove constraint All Fields: tibet'
|
|
65
|
+
expect(page).to have_css('article.document', count: 2)
|
|
66
|
+
expect(page).to have_no_css('#spell')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
69
|
it 'can limit to facets' do
|
|
70
70
|
fill_in 'Subject', with: 'Women'
|
|
71
71
|
click_on 'Language'
|
|
@@ -107,7 +107,7 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
107
107
|
|
|
108
108
|
describe "prepopulated advanced search form" do
|
|
109
109
|
before do
|
|
110
|
-
visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&sort=author'
|
|
110
|
+
visit '/catalog/advanced?op=must&clause[1][field]=title&clause[1]query=medicine&f_inclusive[language_ssim][]=Tibetan&f[format][]=Book&sort=author'
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it 'prepopulates the expected fields' do
|
|
@@ -117,6 +117,12 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
117
117
|
expect(page).to have_select 'sort', selected: 'author'
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
it 'creates hidden inputs for fields not included in the advanced search form' do
|
|
121
|
+
within('form.advanced') do
|
|
122
|
+
expect(page).to have_field 'f[format][]', type: :hidden, with: 'Book'
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
120
126
|
it "does not create hidden inputs for fields included in adv search form" do
|
|
121
127
|
within('form.advanced') do
|
|
122
128
|
expect(page).to have_no_field('clause[1][query]', type: :hidden, with: 'medicine')
|
|
@@ -140,5 +146,18 @@ RSpec.describe "Blacklight Advanced Search Form" do
|
|
|
140
146
|
expect(page).to have_no_field 'Title', with: 'medicine'
|
|
141
147
|
expect(page).to have_no_field 'Tibetan', checked: true
|
|
142
148
|
end
|
|
149
|
+
|
|
150
|
+
it 'creates constraints for fields not included in advanced search form' do
|
|
151
|
+
within('div.constraints') do
|
|
152
|
+
expect(page).to have_content('Format:Book')
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'does not create constraints for fields included in the advanced search form' do
|
|
157
|
+
within('div.constraints') do
|
|
158
|
+
expect(page).to have_no_content('Title:medicine')
|
|
159
|
+
expect(page).to have_no_content('Language:Tibetan')
|
|
160
|
+
end
|
|
161
|
+
end
|
|
143
162
|
end
|
|
144
163
|
end
|
|
@@ -735,4 +735,130 @@ RSpec.describe Blacklight::Configuration, :api do
|
|
|
735
735
|
described_class.default_configuration.delete_at(2)
|
|
736
736
|
end
|
|
737
737
|
end
|
|
738
|
+
|
|
739
|
+
describe "#copy_search_field_config_to_advanced!" do
|
|
740
|
+
let(:config) { described_class.new }
|
|
741
|
+
|
|
742
|
+
before do
|
|
743
|
+
config.add_search_field('title',
|
|
744
|
+
solr_parameters: {
|
|
745
|
+
'spellcheck.dictionary': 'title',
|
|
746
|
+
qf: '${title_qf}',
|
|
747
|
+
pf: '${title_pf}'
|
|
748
|
+
})
|
|
749
|
+
config.add_search_field('excluded_field',
|
|
750
|
+
solr_parameters: { qf: '${excluded_qf}' },
|
|
751
|
+
include_in_advanced_search: false)
|
|
752
|
+
config.add_search_field('already_configured',
|
|
753
|
+
solr_parameters: { qf: '${configured_qf}' },
|
|
754
|
+
clause_params: { edismax: { existing_custom: 'params' } })
|
|
755
|
+
end
|
|
756
|
+
|
|
757
|
+
it "copies solr_parameters to clause_params for eligible search fields" do
|
|
758
|
+
config.copy_search_field_config_to_advanced!
|
|
759
|
+
|
|
760
|
+
title_field = config.search_fields['title']
|
|
761
|
+
expect(title_field.clause_params).to be_present
|
|
762
|
+
expect(title_field.clause_params[:edismax]).to eq({ 'spellcheck.dictionary': 'title', qf: '${title_qf}', pf: '${title_pf}' })
|
|
763
|
+
end
|
|
764
|
+
|
|
765
|
+
it "skips fields with include_in_advanced_search set to false" do
|
|
766
|
+
config.copy_search_field_config_to_advanced!
|
|
767
|
+
|
|
768
|
+
excluded_field = config.search_fields['excluded_field']
|
|
769
|
+
expect(excluded_field.clause_params).to be_nil
|
|
770
|
+
end
|
|
771
|
+
|
|
772
|
+
it "skips fields that already have a clause_params config" do
|
|
773
|
+
config.copy_search_field_config_to_advanced!
|
|
774
|
+
|
|
775
|
+
already_configured_field = config.search_fields['already_configured']
|
|
776
|
+
expect(already_configured_field.clause_params).to eq({ edismax: { existing_custom: 'params' } })
|
|
777
|
+
end
|
|
778
|
+
|
|
779
|
+
it "handles fields with nil solr_parameters" do
|
|
780
|
+
config.add_search_field('no_solr_params')
|
|
781
|
+
|
|
782
|
+
expect { config.copy_search_field_config_to_advanced! }.not_to raise_error
|
|
783
|
+
|
|
784
|
+
field = config.search_fields['no_solr_params']
|
|
785
|
+
expect(field.clause_params).to be_present
|
|
786
|
+
expect(field.clause_params[:edismax]).to eq({})
|
|
787
|
+
end
|
|
788
|
+
end
|
|
789
|
+
|
|
790
|
+
describe "#copy_facet_field_config_to_advanced!" do
|
|
791
|
+
let(:config) { described_class.new }
|
|
792
|
+
|
|
793
|
+
before do
|
|
794
|
+
config.add_facet_field('format',
|
|
795
|
+
field: 'format')
|
|
796
|
+
config.add_facet_field('subject_ssim')
|
|
797
|
+
config.add_facet_field('excluded_facet',
|
|
798
|
+
field: 'excluded_field',
|
|
799
|
+
include_in_advanced_search: false)
|
|
800
|
+
config.add_facet_field('query_facet',
|
|
801
|
+
query: { 'recent' => { fq: 'pub_date_ssim:[2020 TO *]' } })
|
|
802
|
+
config.add_facet_field('pivot_facet',
|
|
803
|
+
pivot: %w[author_ssim subject_ssim])
|
|
804
|
+
config.add_facet_field('range_facet',
|
|
805
|
+
range: true,
|
|
806
|
+
field: 'pub_date_ssim')
|
|
807
|
+
end
|
|
808
|
+
|
|
809
|
+
it "sets default facet.sort to 'count'" do
|
|
810
|
+
config.copy_facet_field_config_to_advanced!
|
|
811
|
+
|
|
812
|
+
expect(config.advanced_search.form_solr_parameters['facet.sort']).to eq 'count'
|
|
813
|
+
end
|
|
814
|
+
|
|
815
|
+
it "adds eligible facet fields to facet.field array" do
|
|
816
|
+
config.copy_facet_field_config_to_advanced!
|
|
817
|
+
|
|
818
|
+
facet_fields = config.advanced_search.form_solr_parameters['facet.field']
|
|
819
|
+
expect(facet_fields).to eq(%w[format subject_ssim])
|
|
820
|
+
end
|
|
821
|
+
|
|
822
|
+
it "skips fields with include_in_advanced_search set to false" do
|
|
823
|
+
config.copy_facet_field_config_to_advanced!
|
|
824
|
+
|
|
825
|
+
facet_fields = config.advanced_search.form_solr_parameters['facet.field']
|
|
826
|
+
expect(facet_fields).not_to include('excluded_field')
|
|
827
|
+
end
|
|
828
|
+
|
|
829
|
+
it "skips fields that are query, pivot, or range facets" do
|
|
830
|
+
config.copy_facet_field_config_to_advanced!
|
|
831
|
+
|
|
832
|
+
facet_fields = config.advanced_search.form_solr_parameters['facet.field']
|
|
833
|
+
expect(facet_fields).not_to include('query_facet', 'pivot_facet', 'range_facet')
|
|
834
|
+
end
|
|
835
|
+
|
|
836
|
+
it "sets facet limit to -1 to show all values for eligible fields" do
|
|
837
|
+
config.copy_facet_field_config_to_advanced!
|
|
838
|
+
|
|
839
|
+
expect(config.advanced_search.form_solr_parameters['f.format.facet.limit']).to eq(-1)
|
|
840
|
+
expect(config.advanced_search.form_solr_parameters['f.subject_ssim.facet.limit']).to eq(-1)
|
|
841
|
+
end
|
|
842
|
+
|
|
843
|
+
context "preserving existing advanced search config if present" do
|
|
844
|
+
before do
|
|
845
|
+
config.advanced_search.form_solr_parameters = {
|
|
846
|
+
'facet.sort' => 'index',
|
|
847
|
+
'f.subject_ssim.facet.limit' => 50
|
|
848
|
+
}
|
|
849
|
+
end
|
|
850
|
+
|
|
851
|
+
it "preserves existing facet.limit configuration if set" do
|
|
852
|
+
config.copy_facet_field_config_to_advanced!
|
|
853
|
+
|
|
854
|
+
expect(config.advanced_search.form_solr_parameters['f.subject_ssim.facet.limit']).to eq(50)
|
|
855
|
+
end
|
|
856
|
+
|
|
857
|
+
it "preserves existing default facet.sort configuration if set" do
|
|
858
|
+
config.copy_facet_field_config_to_advanced!
|
|
859
|
+
|
|
860
|
+
expect(config.advanced_search.form_solr_parameters['facet.sort']).to eq('index')
|
|
861
|
+
end
|
|
862
|
+
end
|
|
863
|
+
end
|
|
738
864
|
end
|
|
@@ -87,6 +87,12 @@ RSpec.describe Blacklight::Solr::Repository, :api do
|
|
|
87
87
|
expect(subject.search(params: {})).to be_a Blacklight::Solr::Response
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
+
it "can be called with no args" do
|
|
91
|
+
blacklight_config.solr_path = 'xyz'
|
|
92
|
+
allow(subject.connection).to receive(:send_and_receive).with('xyz', anything).and_return(mock_response)
|
|
93
|
+
expect(subject.search).to be_a Blacklight::Solr::Response
|
|
94
|
+
end
|
|
95
|
+
|
|
90
96
|
it "uses the default solr path" do
|
|
91
97
|
allow(subject.connection).to receive(:send_and_receive).with('select', anything).and_return(mock_response)
|
|
92
98
|
expect(subject.search(params: {})).to be_a Blacklight::Solr::Response
|
|
@@ -523,6 +523,58 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, :api do
|
|
|
523
523
|
end
|
|
524
524
|
end
|
|
525
525
|
|
|
526
|
+
describe "#add_facets_for_advanced_search_form" do
|
|
527
|
+
let(:solr_parameters) { Blacklight::Solr::Request.new }
|
|
528
|
+
let(:mock_controller) { instance_double(CatalogController, action_name: 'advanced_search') }
|
|
529
|
+
let(:mock_search_state) { instance_double(Blacklight::SearchState, controller: mock_controller) }
|
|
530
|
+
|
|
531
|
+
before do
|
|
532
|
+
allow(search_builder).to receive(:search_state).and_return(mock_search_state)
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
context "when action is advanced_search and form_solr_parameters are configured" do
|
|
536
|
+
before do
|
|
537
|
+
blacklight_config.advanced_search.enabled = true
|
|
538
|
+
blacklight_config.advanced_search.form_solr_parameters = {
|
|
539
|
+
'facet.sort' => 'count',
|
|
540
|
+
'facet.field' => %w[format subject_ssim],
|
|
541
|
+
'f.format.facet.limit' => -1,
|
|
542
|
+
'f.subject_ssim.facet.limit' => -1
|
|
543
|
+
}
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
it "merges advanced search form parameters into solr parameters" do
|
|
547
|
+
solr_parameters['existing.param'] = 'keep_me'
|
|
548
|
+
subject.add_facets_for_advanced_search_form(solr_parameters)
|
|
549
|
+
|
|
550
|
+
expect(solr_parameters['facet.sort']).to eq 'count'
|
|
551
|
+
expect(solr_parameters['facet.field']).to eq %w[format subject_ssim]
|
|
552
|
+
expect(solr_parameters['f.format.facet.limit']).to eq(-1)
|
|
553
|
+
expect(solr_parameters['f.subject_ssim.facet.limit']).to eq(-1)
|
|
554
|
+
expect(solr_parameters['existing.param']).to eq 'keep_me'
|
|
555
|
+
end
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
context "when action is not advanced_search" do
|
|
559
|
+
before do
|
|
560
|
+
allow(mock_controller).to receive(:action_name).and_return('index')
|
|
561
|
+
blacklight_config.advanced_search.enabled = true
|
|
562
|
+
blacklight_config.advanced_search.form_solr_parameters = {
|
|
563
|
+
'facet.sort' => 'count',
|
|
564
|
+
'facet.field' => ['format']
|
|
565
|
+
}
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
it "does not merge advanced search form parameters" do
|
|
569
|
+
solr_parameters['f.format.facet.limit'] = 21
|
|
570
|
+
|
|
571
|
+
subject.add_facets_for_advanced_search_form(solr_parameters)
|
|
572
|
+
|
|
573
|
+
expect(solr_parameters['f.format.facet.limit']).to eq 21
|
|
574
|
+
end
|
|
575
|
+
end
|
|
576
|
+
end
|
|
577
|
+
|
|
526
578
|
describe "#add_facet_fq_to_solr" do
|
|
527
579
|
it "converts a String fq into an Array" do
|
|
528
580
|
solr_parameters = { fq: 'a string' }
|
|
@@ -677,12 +729,6 @@ RSpec.describe Blacklight::Solr::SearchBuilderBehavior, :api do
|
|
|
677
729
|
end
|
|
678
730
|
|
|
679
731
|
context 'with advanced search clause parameters' do
|
|
680
|
-
before do
|
|
681
|
-
blacklight_config.search_fields.each_value do |v|
|
|
682
|
-
v.clause_params = { edismax: v.solr_parameters.dup }
|
|
683
|
-
end
|
|
684
|
-
end
|
|
685
|
-
|
|
686
732
|
let(:user_params) { { op: 'must', clause: { '0': { field: 'title', query: 'the book' }, '1': { field: 'author', query: 'the person' } } } }
|
|
687
733
|
|
|
688
734
|
it "has proper solr parameters" do
|
|
@@ -29,13 +29,13 @@ RSpec.describe Blacklight::DocumentPresenter do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
describe '#field_value' do
|
|
32
|
-
let(:field_presenter) { instance_double(Blacklight::FieldPresenter, render: 'xyz') }
|
|
32
|
+
let(:field_presenter) { instance_double(Blacklight::FieldPresenter, render: ['xyz']) }
|
|
33
33
|
let(:field_config) { Blacklight::Configuration::DisplayField.new }
|
|
34
34
|
let(:options) { { a: 1 } }
|
|
35
35
|
|
|
36
36
|
it 'calls the field presenter' do
|
|
37
37
|
allow(Blacklight::FieldPresenter).to receive(:new).with(request_context, doc, field_config, options).and_return(field_presenter)
|
|
38
|
-
expect(presenter.field_value(field_config, options)).to eq 'xyz'
|
|
38
|
+
expect(presenter.field_value(field_config, options)).to eq ['xyz']
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it 'can be configured to use an alternate presenter' do
|
|
@@ -44,7 +44,7 @@ RSpec.describe Blacklight::DocumentPresenter do
|
|
|
44
44
|
field_config.presenter = SomePresenter
|
|
45
45
|
allow(SomePresenter).to receive(:new).and_return(instance)
|
|
46
46
|
|
|
47
|
-
expect(presenter.field_value(field_config, options)).to eq 'abc'
|
|
47
|
+
expect(presenter.field_value(field_config, options)).to eq ['abc']
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|