blacklight 5.19.2 → 6.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/.hound.yml +2 -0
- data/.jshintrc +67 -0
- data/.rubocop_hound.yml +4 -0
- data/.travis.yml +11 -8
- data/Gemfile +11 -21
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +1 -0
- data/app/assets/javascripts/blacklight/core.js +5 -19
- data/app/assets/javascripts/blacklight/facet_load.js +23 -0
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +18 -0
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +5 -1
- data/app/assets/stylesheets/blacklight/_bookmark.scss +14 -6
- data/app/assets/stylesheets/blacklight/_constraints.scss +52 -0
- data/app/assets/stylesheets/blacklight/_controls.scss +61 -0
- data/app/assets/stylesheets/blacklight/_facets.scss +31 -4
- data/app/assets/stylesheets/blacklight/_header.scss +17 -3
- data/app/assets/stylesheets/blacklight/_pagination.scss +21 -0
- data/app/assets/stylesheets/blacklight/_search_results.scss +28 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -3
- data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +3 -45
- data/app/controllers/concerns/blacklight/controller.rb +29 -18
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +4 -3
- data/app/controllers/concerns/blacklight/facet.rb +1 -0
- data/app/controllers/concerns/blacklight/request_builders.rb +4 -107
- data/app/controllers/concerns/blacklight/search_fields.rb +1 -1
- data/app/controllers/concerns/blacklight/search_helper.rb +8 -160
- data/app/controllers/saved_searches_controller.rb +1 -1
- data/app/controllers/search_history_controller.rb +18 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +17 -85
- data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -48
- data/app/helpers/blacklight/component_helper_behavior.rb +9 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +3 -43
- data/app/helpers/blacklight/facets_helper_behavior.rb +10 -6
- data/app/helpers/blacklight/layout_helper_behavior.rb +0 -8
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -10
- data/app/helpers/blacklight/render_partials_helper.rb +1 -3
- data/app/helpers/blacklight/url_helper_behavior.rb +15 -187
- data/{lib → app/models}/blacklight/abstract_repository.rb +0 -15
- data/{lib → app/models}/blacklight/configuration.rb +22 -59
- data/app/models/blacklight/configuration/context.rb +47 -0
- data/{lib → app/models}/blacklight/configuration/facet_field.rb +1 -0
- data/{lib → app/models}/blacklight/configuration/field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/fields.rb +2 -6
- data/{lib → app/models}/blacklight/configuration/search_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/solr_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/sort_field.rb +0 -0
- data/{lib → app/models}/blacklight/configuration/tool_config.rb +0 -0
- data/app/models/blacklight/configuration/view_config.rb +9 -0
- data/app/models/blacklight/facet_paginator.rb +14 -28
- data/{lib → app/models}/blacklight/search_builder.rb +16 -24
- data/app/models/blacklight/solr/facet_paginator.rb +6 -2
- data/{lib → app/models}/blacklight/solr/repository.rb +0 -21
- data/{lib → app/models}/blacklight/solr/request.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response.rb +9 -8
- data/{lib → app/models}/blacklight/solr/response/facets.rb +37 -29
- data/{lib → app/models}/blacklight/solr/response/group.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/group_response.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/more_like_this.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/pagination_methods.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/response.rb +0 -0
- data/{lib → app/models}/blacklight/solr/response/spelling.rb +2 -1
- data/{lib → app/models}/blacklight/solr/search_builder.rb +0 -0
- data/app/models/concerns/blacklight/document.rb +11 -27
- data/app/models/concerns/blacklight/document/active_model_shim.rb +8 -0
- data/app/models/concerns/blacklight/solr/document.rb +8 -3
- data/{lib → app/models/concerns}/blacklight/solr/search_builder_behavior.rb +21 -33
- data/app/models/concerns/blacklight/user.rb +0 -9
- data/app/models/record_mailer.rb +0 -1
- data/app/presenters/blacklight/document_presenter.rb +23 -13
- data/app/views/blacklight/nav/_saved_searches.html.erb +1 -1
- data/app/views/blacklight/nav/_search_history.html.erb +1 -1
- data/app/views/bookmarks/_tools.html.erb +1 -2
- data/app/views/bookmarks/index.html.erb +2 -2
- data/app/views/catalog/_document_default.atom.builder +4 -2
- data/app/views/catalog/_facet_index_navigation.html.erb +9 -0
- data/app/views/catalog/_facet_layout.html.erb +2 -3
- data/app/views/catalog/_facet_pagination.html.erb +19 -21
- data/app/views/catalog/_facets.html.erb +2 -3
- data/app/views/catalog/_home_text.html.erb +2 -3
- data/app/views/catalog/_index_header_default.html.erb +2 -2
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +21 -18
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/app/views/catalog/_zero_results.html.erb +2 -2
- data/app/views/catalog/facet.html.erb +3 -0
- data/app/views/catalog/index.atom.builder +1 -1
- data/app/views/layouts/blacklight.html.erb +2 -2
- data/app/views/saved_searches/index.html.erb +6 -7
- data/app/views/search_history/index.html.erb +5 -5
- data/app/views/shared/_header_navbar.html.erb +2 -2
- data/blacklight.gemspec +5 -5
- data/config/locales/blacklight.de.yml +1 -4
- data/config/locales/blacklight.en.yml +2 -7
- data/config/locales/blacklight.es.yml +1 -4
- data/config/locales/blacklight.fr.yml +1 -4
- data/config/locales/blacklight.it.yml +1 -4
- data/config/locales/blacklight.pt-BR.yml +1 -4
- data/config/routes.rb +9 -0
- data/db/migrate/20140202020201_create_searches.rb +1 -1
- data/db/migrate/20140202020202_create_bookmarks.rb +1 -1
- data/lib/blacklight.rb +5 -82
- data/lib/blacklight/engine.rb +0 -5
- data/lib/blacklight/parameters.rb +13 -0
- data/lib/blacklight/path.rb +143 -0
- data/lib/blacklight/routes.rb +3 -134
- data/lib/blacklight/routes/exportable.rb +25 -0
- data/lib/blacklight/routes/searchable.rb +20 -0
- data/lib/blacklight/solr.rb +1 -9
- data/lib/blacklight/utils.rb +2 -44
- data/lib/generators/blacklight/controller_generator.rb +7 -4
- data/lib/generators/blacklight/install_generator.rb +16 -9
- data/lib/generators/blacklight/models_generator.rb +18 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +85 -91
- data/lib/generators/blacklight/test_support_generator.rb +22 -15
- data/solr/conf/_rest_managed.json +3 -0
- data/solr/conf/admin-extra.html +31 -0
- data/solr/conf/elevate.xml +36 -0
- data/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/solr/conf/protwords.txt +21 -0
- data/solr/conf/schema.xml +621 -0
- data/solr/conf/scripts.conf +24 -0
- data/solr/conf/solrconfig.xml +391 -0
- data/solr/conf/spellings.txt +2 -0
- data/solr/conf/stopwords.txt +58 -0
- data/solr/conf/stopwords_en.txt +58 -0
- data/solr/conf/synonyms.txt +31 -0
- data/solr/conf/xslt/example.xsl +132 -0
- data/solr/conf/xslt/example_atom.xsl +67 -0
- data/solr/conf/xslt/example_rss.xsl +66 -0
- data/solr/conf/xslt/luke.xsl +337 -0
- data/solr/sample_solr_documents.yml +1 -0
- data/spec/controllers/blacklight/base_spec.rb +17 -0
- data/spec/controllers/blacklight/search_helper_spec.rb +25 -297
- data/spec/controllers/catalog_controller_spec.rb +7 -6
- data/spec/controllers/saved_searches_controller_spec.rb +1 -0
- data/spec/controllers/search_history_controller_spec.rb +1 -0
- data/spec/features/alternate_controller_spec.rb +10 -10
- data/spec/features/bookmarks_spec.rb +8 -22
- data/spec/features/facets_spec.rb +27 -7
- data/spec/features/record_view_spec.rb +4 -13
- data/spec/features/search_formats_spec.rb +1 -26
- data/spec/features/sitelinks_search_box.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +8 -38
- data/spec/helpers/catalog_helper_spec.rb +0 -8
- data/spec/helpers/configuration_helper_spec.rb +0 -25
- data/spec/helpers/facets_helper_spec.rb +12 -11
- data/spec/helpers/hash_as_hidden_fields_spec.rb +7 -7
- data/spec/helpers/layout_helper_spec.rb +0 -7
- data/spec/helpers/render_constraints_helper_spec.rb +4 -2
- data/spec/helpers/url_helper_spec.rb +13 -254
- data/spec/lib/blacklight/parameters_spec.rb +22 -0
- data/spec/lib/blacklight/path_spec.rb +254 -0
- data/spec/lib/blacklight_spec.rb +6 -2
- data/spec/models/blacklight/configuration/context_spec.rb +33 -0
- data/spec/models/blacklight/document/active_model_shim_spec.rb +33 -0
- data/spec/models/blacklight/document_spec.rb +29 -1
- data/spec/models/blacklight/facet_paginator_spec.rb +14 -13
- data/spec/models/blacklight/search_builder_spec.rb +17 -23
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +11 -1
- data/spec/models/blacklight/solr/response/facets_spec.rb +19 -25
- data/spec/models/blacklight/solr/response/group_response_spec.rb +5 -5
- data/spec/models/blacklight/solr/response_spec.rb +0 -11
- data/spec/models/blacklight/solr/search_builder_spec.rb +49 -57
- data/spec/presenters/document_presenter_spec.rb +15 -42
- data/spec/routing/catalog_routing_spec.rb +7 -11
- data/spec/spec_helper.rb +4 -42
- data/spec/support/controller_level_helpers.rb +17 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -2
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +40 -0
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -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/tasks/blacklight.rake +25 -30
- metadata +93 -71
- data/app/assets/stylesheets/blacklight/_catalog.scss +0 -229
- data/app/controllers/concerns/blacklight/search_history.rb +0 -31
- data/app/views/catalog/_refworks_form.html.erb +0 -6
- data/lib/blacklight/configuration/view_config.rb +0 -71
- data/lib/blacklight/rails/routes.rb +0 -29
- data/lib/blacklight/solr_helper.rb +0 -9
- data/lib/generators/blacklight/templates/config/initializers/blacklight_initializer.rb +0 -9
- data/spec/helpers/component_helper_spec.rb +0 -19
- data/spec/lib/blacklight/routes_spec.rb +0 -25
- data/spec/lib/blacklight/solr_helper_spec.rb +0 -12
- data/spec/routing/routes_spec.rb +0 -20
- data/spec/views/catalog/_document_action.html.erb_spec.rb +0 -21
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Blacklight::Base do
|
4
|
+
let(:controller) { (Class.new(ApplicationController) { include Blacklight::Base }).new }
|
5
|
+
subject { controller}
|
6
|
+
|
7
|
+
describe "#blacklight_path" do
|
8
|
+
let(:params) { double }
|
9
|
+
before { allow(controller).to receive_messages(params: params) }
|
10
|
+
subject { controller.send(:blacklight_path) }
|
11
|
+
|
12
|
+
it "creates a path object" do
|
13
|
+
expect(subject).to be_kind_of Blacklight::Path
|
14
|
+
expect(subject.params).to be params
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -11,8 +11,6 @@ require 'spec_helper'
|
|
11
11
|
#
|
12
12
|
describe Blacklight::SearchHelper do
|
13
13
|
|
14
|
-
let(:default_method_chain) { CatalogController.search_params_logic }
|
15
|
-
|
16
14
|
# SearchHelper is a controller layer mixin, which depends
|
17
15
|
# on being mixed into a class which has #params (from Rails)
|
18
16
|
# and #blacklight_config
|
@@ -51,34 +49,6 @@ describe Blacklight::SearchHelper do
|
|
51
49
|
@subject_search_params = {:commit=>"search", :search_field=>"subject", :action=>"index", :"controller"=>"catalog", :"rows"=>"10", :"q"=>"wome"}
|
52
50
|
end
|
53
51
|
|
54
|
-
describe "solr_search_params" do
|
55
|
-
it "allows customization of the filter pipeline" do
|
56
|
-
# Normally you'd include a new module into (eg) your CatalogController
|
57
|
-
# but a sub-class defininig it directly is simpler for test.
|
58
|
-
allow(subject).to receive(:add_foo_to_solr_params) do |solr_params, user_params|
|
59
|
-
solr_params[:wt] = "TESTING"
|
60
|
-
end
|
61
|
-
|
62
|
-
allow(Deprecation).to receive(:warn)
|
63
|
-
expect(subject.solr_search_params({}, [:add_foo_to_solr_params])[:wt]).to eq "TESTING"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "get_facet_pagination", :integration => true do
|
68
|
-
before do
|
69
|
-
@facet_field = 'format'
|
70
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
71
|
-
@facet_paginator = subject.get_facet_pagination(@facet_field)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
it 'should return a facet paginator' do
|
75
|
-
expect(@facet_paginator).to be_a_kind_of(Blacklight::Solr::FacetPaginator)
|
76
|
-
end
|
77
|
-
it 'with a limit set' do
|
78
|
-
expect(@facet_paginator.limit).not_to be_nil
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
52
|
# SPECS FOR SEARCH RESULTS FOR QUERY
|
83
53
|
describe 'Search Results', :integration => true do
|
84
54
|
|
@@ -86,7 +56,7 @@ describe Blacklight::SearchHelper do
|
|
86
56
|
describe 'for a sample query returning results' do
|
87
57
|
|
88
58
|
before do
|
89
|
-
(@solr_response, @document_list) = subject.search_results(
|
59
|
+
(@solr_response, @document_list) = subject.search_results(q: @all_docs_query)
|
90
60
|
end
|
91
61
|
|
92
62
|
it "should use the configured request handler " do
|
@@ -97,7 +67,7 @@ describe Blacklight::SearchHelper do
|
|
97
67
|
expect(params[:params]["facet.query"]).to eq ["pub_date:[#{5.years.ago.year} TO *]", "pub_date:[#{10.years.ago.year} TO *]", "pub_date:[#{25.years.ago.year} TO *]"]
|
98
68
|
expect(params[:params]).to include('rows' => 10, 'qt'=>"custom_request_handler", 'q'=>"", "f.subject_topic_facet.facet.limit"=>21, 'sort'=>"score desc, pub_date_sort desc, title_sort asc")
|
99
69
|
end.and_return({'response'=>{'docs'=>[]}})
|
100
|
-
subject.search_results(
|
70
|
+
subject.search_results(q: @all_docs_query)
|
101
71
|
end
|
102
72
|
|
103
73
|
it 'should have a @response.docs list of the same size as @document_list' do
|
@@ -118,44 +88,12 @@ describe Blacklight::SearchHelper do
|
|
118
88
|
end
|
119
89
|
end
|
120
90
|
|
121
|
-
describe "with SearchBuilder replacement block" do
|
122
|
-
it "should pass configured SearchBuilder and use returned SearchBuilder" do
|
123
|
-
replacement_search_builder = subject.search_builder([:new_chain])
|
124
|
-
|
125
|
-
# Sorry, have to use mocks to make sure method really passes the
|
126
|
-
# block return value to the repository search, couldn't figure
|
127
|
-
# out a better way to test.
|
128
|
-
expect(subject.repository).to receive(:search) do |arg_search_builder|
|
129
|
-
expect(arg_search_builder).to equal(replacement_search_builder)
|
130
|
-
end.and_return(
|
131
|
-
blacklight_config.response_model.new({'response'=>{'docs'=>[]}}, {}, document_model: blacklight_config.document_model, blacklight_config: blacklight_config)
|
132
|
-
)
|
133
|
-
|
134
|
-
subject.search_results({q: @no_docs_query}, [:one, :two]) do |arg_search_builder|
|
135
|
-
expect(arg_search_builder.processor_chain).to eq([:one, :two])
|
136
|
-
|
137
|
-
replacement_search_builder
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe "#get_search_results " do
|
143
|
-
it "should be deprecated and return results" do
|
144
|
-
expect(Deprecation).to receive(:warn)
|
145
|
-
(solr_response, document_list) = subject.get_search_results(q: @all_docs_query)
|
146
|
-
result_docs = document_list
|
147
|
-
document = result_docs.first
|
148
|
-
expect(document.fetch(blacklight_config.index.title_field)).not_to be_nil
|
149
|
-
expect(document.fetch(blacklight_config.index.display_type_field)).not_to be_nil
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
91
|
describe "for a query returning a grouped response" do
|
154
92
|
let(:blacklight_config) { copy_of_catalog_config }
|
155
93
|
before do
|
156
94
|
blacklight_config.default_solr_params[:group] = true
|
157
95
|
blacklight_config.default_solr_params[:'group.field'] = 'pub_date_sort'
|
158
|
-
(@solr_response, @document_list) = subject.search_results(
|
96
|
+
(@solr_response, @document_list) = subject.search_results(q: @all_docs_query)
|
159
97
|
end
|
160
98
|
|
161
99
|
it "should have an empty document list" do
|
@@ -175,7 +113,7 @@ describe Blacklight::SearchHelper do
|
|
175
113
|
allow(subject).to receive_messages grouped_key_for_results: 'title_sort'
|
176
114
|
blacklight_config.default_solr_params[:group] = true
|
177
115
|
blacklight_config.default_solr_params[:'group.field'] = ['pub_date_sort', 'title_sort']
|
178
|
-
(@solr_response, @document_list) = subject.search_results(
|
116
|
+
(@solr_response, @document_list) = subject.search_results(q: @all_docs_query)
|
179
117
|
end
|
180
118
|
|
181
119
|
it "should have an empty document list" do
|
@@ -188,85 +126,10 @@ describe Blacklight::SearchHelper do
|
|
188
126
|
end
|
189
127
|
end
|
190
128
|
|
191
|
-
describe '#query_solr' do
|
192
|
-
it 'should have results' do
|
193
|
-
expect(Deprecation).to receive(:warn)
|
194
|
-
solr_response = subject.query_solr(q: @single_word_query)
|
195
|
-
expect(solr_response.docs).to have_at_least(1).result
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
describe 'for All Docs Query, No Facets' do
|
201
|
-
it 'should have non-nil values for required doc fields set in initializer' do
|
202
|
-
(solr_response, document_list) = subject.search_results({ q: @all_docs_query }, default_method_chain)
|
203
|
-
result_docs = document_list
|
204
|
-
document = result_docs.first
|
205
|
-
expect(document.fetch(blacklight_config.index.title_field)).not_to be_nil
|
206
|
-
expect(document.fetch(blacklight_config.index.display_type_field)).not_to be_nil
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
describe "Single Word Query with no Facets" do
|
213
|
-
it 'should have results' do
|
214
|
-
expect(Deprecation).to receive(:warn)
|
215
|
-
solr_response = subject.query_solr( q: @single_word_query)
|
216
|
-
expect(solr_response.docs).to have_at_least(1).result
|
217
|
-
end
|
218
|
-
|
219
|
-
it 'should have results' do
|
220
|
-
(solr_response, document_list) = subject.search_results({ q: @single_word_query }, default_method_chain)
|
221
|
-
expect(solr_response.docs).to have(document_list.size).results
|
222
|
-
expect(solr_response.docs).to have_at_least(1).result
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe "Multiple Words Query with No Facets" do
|
227
|
-
it 'should have results' do
|
228
|
-
|
229
|
-
(solr_response, document_list) = subject.search_results({ q: @mult_word_query }, default_method_chain)
|
230
|
-
expect(solr_response.docs).to have(document_list.size).results
|
231
|
-
expect(solr_response.docs).to have_at_least(1).result
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
describe "One Facet, No Query" do
|
236
|
-
it 'should have results' do
|
237
|
-
(solr_response, document_list) = subject.search_results({ f: @single_facet }, default_method_chain)
|
238
|
-
expect(solr_response.docs).to have(document_list.size).results
|
239
|
-
expect(solr_response.docs).to have_at_least(1).result
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
describe "Mult Facets, No Query" do
|
244
|
-
it 'should have results' do
|
245
|
-
(solr_response, document_list) = subject.search_results({ f: @multi_facets }, default_method_chain)
|
246
|
-
expect(solr_response.docs).to have(document_list.size).results
|
247
|
-
expect(solr_response.docs).to have_at_least(1).result
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
describe "Single Word Query with One Facet" do
|
252
|
-
it 'should have results' do
|
253
|
-
(solr_response, document_list) = subject.search_results({ q: @single_word_query, f: @single_facet }, default_method_chain)
|
254
|
-
expect(solr_response.docs).to have(document_list.size).results
|
255
|
-
expect(solr_response.docs).to have_at_least(1).result
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
describe "Multiple Words Query with Multiple Facets" do
|
260
|
-
it 'should have results' do
|
261
|
-
(solr_response, document_list) = subject.search_results({ q: @mult_word_query, f: @multi_facets }, default_method_chain)
|
262
|
-
expect(solr_response.docs).to have(document_list.size).results
|
263
|
-
expect(solr_response.docs).to have_at_least(1).result
|
264
|
-
end
|
265
|
-
end
|
266
129
|
|
267
130
|
describe "for All Docs Query and One Facet" do
|
268
131
|
it 'should have results' do
|
269
|
-
(solr_response, document_list) = subject.search_results(
|
132
|
+
(solr_response, document_list) = subject.search_results(q: @all_docs_query, f: @single_facet)
|
270
133
|
expect(solr_response.docs).to have(document_list.size).results
|
271
134
|
expect(solr_response.docs).to have_at_least(1).result
|
272
135
|
end
|
@@ -276,7 +139,7 @@ describe Blacklight::SearchHelper do
|
|
276
139
|
|
277
140
|
describe "for Query Without Results and No Facet" do
|
278
141
|
it 'should have no results and not raise error' do
|
279
|
-
(solr_response, document_list) = subject.search_results(
|
142
|
+
(solr_response, document_list) = subject.search_results(q: @no_docs_query)
|
280
143
|
expect(document_list).to have(0).results
|
281
144
|
expect(solr_response.docs).to have(0).results
|
282
145
|
end
|
@@ -284,7 +147,7 @@ describe Blacklight::SearchHelper do
|
|
284
147
|
|
285
148
|
describe "for Query Without Results and One Facet" do
|
286
149
|
it 'should have no results and not raise error' do
|
287
|
-
(solr_response, document_list) = subject.search_results(
|
150
|
+
(solr_response, document_list) = subject.search_results(q: @no_docs_query, f: @single_facet)
|
288
151
|
expect(document_list).to have(0).results
|
289
152
|
expect(solr_response.docs).to have(0).results
|
290
153
|
end
|
@@ -292,7 +155,7 @@ describe Blacklight::SearchHelper do
|
|
292
155
|
|
293
156
|
describe "for All Docs Query and Bad Facet" do
|
294
157
|
it 'should have no results and not raise error' do
|
295
|
-
(solr_response, document_list) = subject.search_results(
|
158
|
+
(solr_response, document_list) = subject.search_results(q: @all_docs_query, f: @bad_facet)
|
296
159
|
expect(document_list).to have(0).results
|
297
160
|
expect(solr_response.docs).to have(0).results
|
298
161
|
end
|
@@ -306,7 +169,7 @@ describe Blacklight::SearchHelper do
|
|
306
169
|
let(:blacklight_config) { copy_of_catalog_config }
|
307
170
|
|
308
171
|
before do
|
309
|
-
(solr_response, document_list) = subject.search_results(
|
172
|
+
(solr_response, document_list) = subject.search_results(q: @all_docs_query)
|
310
173
|
@facets = solr_response.aggregations
|
311
174
|
end
|
312
175
|
|
@@ -348,44 +211,44 @@ describe Blacklight::SearchHelper do
|
|
348
211
|
let(:blacklight_config) { copy_of_catalog_config }
|
349
212
|
|
350
213
|
it 'should start with first results by default' do
|
351
|
-
(solr_response, document_list) = subject.search_results(
|
214
|
+
(solr_response, document_list) = subject.search_results(q: @all_docs_query)
|
352
215
|
expect(solr_response.params[:start].to_i).to eq 0
|
353
216
|
end
|
354
217
|
it 'should have number of results (per page) set in initializer, by default' do
|
355
|
-
(solr_response, document_list) = subject.search_results(
|
218
|
+
(solr_response, document_list) = subject.search_results(q: @all_docs_query)
|
356
219
|
expect(solr_response.docs).to have(blacklight_config[:default_solr_params][:rows]).items
|
357
220
|
expect(document_list).to have(blacklight_config[:default_solr_params][:rows]).items
|
358
221
|
end
|
359
222
|
|
360
223
|
it 'should get number of results per page requested' do
|
361
224
|
num_results = 3 # non-default value
|
362
|
-
(solr_response1, document_list1) = subject.search_results(
|
225
|
+
(solr_response1, document_list1) = subject.search_results(q: @all_docs_query, per_page: num_results)
|
363
226
|
expect(document_list1).to have(num_results).docs
|
364
227
|
expect(solr_response1.docs).to have(num_results).docs
|
365
228
|
end
|
366
229
|
|
367
230
|
it 'should get number of rows requested' do
|
368
231
|
num_results = 4 # non-default value
|
369
|
-
(solr_response1, document_list1) = subject.search_results(
|
232
|
+
(solr_response1, document_list1) = subject.search_results(q: @all_docs_query, rows: num_results)
|
370
233
|
expect(document_list1).to have(num_results).docs
|
371
234
|
expect(solr_response1.docs).to have(num_results).docs
|
372
235
|
end
|
373
236
|
|
374
237
|
it 'should skip appropriate number of results when requested - default per page' do
|
375
238
|
page = 3
|
376
|
-
(solr_response2, document_list2) = subject.search_results(
|
239
|
+
(solr_response2, document_list2) = subject.search_results(q: @all_docs_query, page: page)
|
377
240
|
expect(solr_response2.params[:start].to_i).to eq blacklight_config[:default_solr_params][:rows] * (page-1)
|
378
241
|
end
|
379
242
|
it 'should skip appropriate number of results when requested - non-default per page' do
|
380
243
|
page = 3
|
381
244
|
num_results = 3
|
382
|
-
(solr_response2a, document_list2a) = subject.search_results(
|
245
|
+
(solr_response2a, document_list2a) = subject.search_results(q: @all_docs_query, per_page: num_results, page: page)
|
383
246
|
expect(solr_response2a.params[:start].to_i).to eq num_results * (page-1)
|
384
247
|
end
|
385
248
|
|
386
249
|
it 'should have no results when prompted for page after last result' do
|
387
250
|
big = 5000
|
388
|
-
(solr_response3, document_list3) = subject.search_results(
|
251
|
+
(solr_response3, document_list3) = subject.search_results(q: @all_docs_query, rows: big, page: big)
|
389
252
|
expect(document_list3).to have(0).docs
|
390
253
|
expect(solr_response3.docs).to have(0).docs
|
391
254
|
end
|
@@ -393,12 +256,12 @@ describe Blacklight::SearchHelper do
|
|
393
256
|
it 'should show first results when prompted for page before first result' do
|
394
257
|
# FIXME: should it show first results, or should it throw an error for view to deal w?
|
395
258
|
# Solr throws an error for a negative start value
|
396
|
-
(solr_response4, document_list4) = subject.search_results(
|
259
|
+
(solr_response4, document_list4) = subject.search_results(q: @all_docs_query, page: '-1')
|
397
260
|
expect(solr_response4.params[:start].to_i).to eq 0
|
398
261
|
end
|
399
262
|
it 'should have results available when asked for more than are in response' do
|
400
263
|
big = 5000
|
401
|
-
(solr_response5, document_list5) = subject.search_results(
|
264
|
+
(solr_response5, document_list5) = subject.search_results(q: @all_docs_query, rows: big, page: 1)
|
402
265
|
expect(solr_response5.docs).to have(document_list5.length).docs
|
403
266
|
expect(solr_response5.docs).to have_at_least(1).doc
|
404
267
|
end
|
@@ -407,16 +270,6 @@ describe Blacklight::SearchHelper do
|
|
407
270
|
|
408
271
|
# SPECS FOR SINGLE DOCUMENT REQUESTS
|
409
272
|
describe 'Get Document By Id', :integration => true do
|
410
|
-
|
411
|
-
describe "#get_solr_response_for_doc_id" do
|
412
|
-
let(:doc_id) { '2007020969' }
|
413
|
-
it "should be deprecated" do
|
414
|
-
expect(Deprecation).to receive(:warn).at_least(1).times
|
415
|
-
expect(subject.repository).to receive(:find).with(@doc_id, {}).and_call_original
|
416
|
-
subject.get_solr_response_for_doc_id(@doc_id)
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
273
|
before do
|
421
274
|
@doc_id = '2007020969'
|
422
275
|
@bad_id = "redrum"
|
@@ -455,113 +308,16 @@ describe Blacklight::SearchHelper do
|
|
455
308
|
end
|
456
309
|
end
|
457
310
|
|
458
|
-
describe "solr_doc_params" do
|
459
|
-
it "should default to using the 'document' requestHandler" do
|
460
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
461
|
-
doc_params = subject.solr_doc_params('asdfg')
|
462
|
-
expect(doc_params[:qt]).to eq 'document'
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
|
-
it "should default to using the id parameter when sending solr queries" do
|
467
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
468
|
-
doc_params = subject.solr_doc_params('asdfg')
|
469
|
-
expect(doc_params[:id]).to eq 'asdfg'
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
it "should use the document_unique_id_param configuration" do
|
474
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
475
|
-
allow(blacklight_config).to receive_messages(document_unique_id_param: :ids)
|
476
|
-
doc_params = subject.solr_doc_params('asdfg')
|
477
|
-
expect(doc_params[:ids]).to eq 'asdfg'
|
478
|
-
end
|
479
|
-
end
|
480
|
-
|
481
|
-
describe "blacklight config's default_document_solr_parameters" do
|
482
|
-
it "should use parameters from the controller's default_document_solr_parameters" do
|
483
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
484
|
-
blacklight_config.default_document_solr_params = { :qt => 'my_custom_handler', :asdf => '1234' }
|
485
|
-
doc_params = subject.solr_doc_params('asdfg')
|
486
|
-
expect(doc_params[:qt]).to eq 'my_custom_handler'
|
487
|
-
expect(doc_params[:asdf]).to eq '1234'
|
488
|
-
end
|
489
|
-
end
|
490
|
-
end
|
491
|
-
|
492
|
-
end
|
493
|
-
|
494
|
-
describe "Get Document by custom unique id" do
|
495
|
-
=begin
|
496
|
-
# Can't test this properly without updating the "document" request handler in solr
|
497
|
-
it "should respect the configuration-supplied unique id" do
|
498
|
-
allow(SolrDocument).to receive(:unique_key).and_return("title_display")
|
499
|
-
@response, @document = @solr_helper.fetch('"Strong Medicine speaks"')
|
500
|
-
@document.id).to eq '"Strong Medicine speaks"'
|
501
|
-
@document.get(:id)).to eq 2007020969
|
502
|
-
end
|
503
|
-
=end
|
504
|
-
it "should respect the configuration-supplied unique id" do
|
505
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
506
|
-
doc_params = subject.solr_doc_params('"Strong Medicine speaks"')
|
507
|
-
expect(doc_params[:id]).to eq '"Strong Medicine speaks"'
|
508
|
-
end
|
509
|
-
end
|
510
|
-
end
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
# SPECS FOR SINGLE DOCUMENT VIA SEARCH
|
515
|
-
describe "Get Document Via Search", :integration => true do
|
516
|
-
before do
|
517
|
-
@doc_row = 3
|
518
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
519
|
-
@doc = subject.get_single_doc_via_search(@doc_row, :q => @all_docs_query)
|
520
|
-
end
|
521
|
-
end
|
522
|
-
=begin
|
523
|
-
# can't test these here, because the method only returns the document
|
524
|
-
it "should get a single document" do
|
525
|
-
response.docs.size).to eq 1
|
526
|
-
end
|
527
|
-
|
528
|
-
doc2 = get_single_doc_via_search(@all_docs_query, nil, @doc_row, @multi_facets)
|
529
|
-
it "should limit search result by facets when supplied" do
|
530
|
-
response2expect(.docs.numFound).to_be < response.docs.numFound
|
531
|
-
end
|
532
|
-
|
533
|
-
it "should not have facets in the response" do
|
534
|
-
response.facets.size).to eq 0
|
535
|
-
end
|
536
|
-
=end
|
537
|
-
|
538
|
-
it 'should have a doc id field' do
|
539
|
-
expect(@doc[:id]).not_to be_nil
|
540
|
-
end
|
541
|
-
|
542
|
-
it 'should have non-nil values for required fields set in initializer' do
|
543
|
-
expect(@doc[blacklight_config.view_config(:show).display_type_field]).not_to be_nil
|
544
|
-
end
|
545
|
-
|
546
|
-
it "should limit search result by facets when supplied" do
|
547
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
548
|
-
doc2 = subject.get_single_doc_via_search(@doc_row , :q => @all_docs_query, :f => @multi_facets)
|
549
|
-
expect(doc2[:id]).not_to be_nil
|
550
|
-
end
|
551
|
-
end
|
552
|
-
|
553
|
-
end
|
554
|
-
|
555
311
|
# SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
|
556
312
|
describe "Searches should return spelling suggestions", :integration => true do
|
557
313
|
it 'search results for just-poor-enough-query term should have (multiple) spelling suggestions' do
|
558
|
-
(solr_response, document_list) = subject.search_results(
|
314
|
+
(solr_response, document_list) = subject.search_results(q: 'boo')
|
559
315
|
expect(solr_response.spelling.words).to include('bon')
|
560
316
|
expect(solr_response.spelling.words).to include('bod') #for multiple suggestions
|
561
317
|
end
|
562
318
|
|
563
319
|
it 'search results for just-poor-enough-query term should have multiple spelling suggestions' do
|
564
|
-
(solr_response, document_list) = subject.search_results(
|
320
|
+
(solr_response, document_list) = subject.search_results(q: 'politica')
|
565
321
|
expect(solr_response.spelling.words).to include('policy') # less freq
|
566
322
|
expect(solr_response.spelling.words).to include('politics') # more freq
|
567
323
|
expect(solr_response.spelling.words).to include('political') # more freq
|
@@ -574,17 +330,17 @@ describe Blacklight::SearchHelper do
|
|
574
330
|
end
|
575
331
|
|
576
332
|
it "title search results for just-poor-enough query term should have spelling suggestions" do
|
577
|
-
(solr_response, document_list) = subject.search_results(
|
333
|
+
(solr_response, document_list) = subject.search_results(q: 'yehudiyam', qt: 'search', :"spellcheck.dictionary" => "title")
|
578
334
|
expect(solr_response.spelling.words).to include('yehudiyim')
|
579
335
|
end
|
580
336
|
|
581
337
|
it "author search results for just-poor-enough-query term should have spelling suggestions" do
|
582
|
-
(solr_response, document_list) = subject.search_results(
|
338
|
+
(solr_response, document_list) = subject.search_results(q: 'shirma', qt: 'search', :"spellcheck.dictionary" => "author")
|
583
339
|
expect(solr_response.spelling.words).to include('sharma')
|
584
340
|
end
|
585
341
|
|
586
342
|
it "subject search results for just-poor-enough-query term should have spelling suggestions" do
|
587
|
-
(solr_response, document_list) = subject.search_results(
|
343
|
+
(solr_response, document_list) = subject.search_results(q: 'wome', qt: 'search', :"spellcheck.dictionary" => "subject")
|
588
344
|
expect(solr_response.spelling.words).to include('women')
|
589
345
|
end
|
590
346
|
|
@@ -641,33 +397,6 @@ describe Blacklight::SearchHelper do
|
|
641
397
|
end
|
642
398
|
end
|
643
399
|
|
644
|
-
describe "#get_solr_response_for_field_values" do
|
645
|
-
before do
|
646
|
-
@mock_response = double()
|
647
|
-
allow(@mock_response).to receive_messages(documents: [])
|
648
|
-
end
|
649
|
-
it "should contruct a solr query based on the field and value pair" do
|
650
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
651
|
-
allow(subject.repository).to receive(:send_and_receive).with('select', hash_including("q" => "{!lucene}field_name:(value)")).and_return(@mock_response)
|
652
|
-
subject.get_solr_response_for_field_values('field_name', 'value')
|
653
|
-
end
|
654
|
-
end
|
655
|
-
|
656
|
-
it "should OR multiple values together" do
|
657
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
658
|
-
allow(subject.repository).to receive(:send_and_receive).with('select', hash_including("q" => "{!lucene}field_name:(a OR b)")).and_return(@mock_response)
|
659
|
-
subject.get_solr_response_for_field_values('field_name', ['a', 'b'])
|
660
|
-
end
|
661
|
-
end
|
662
|
-
|
663
|
-
it "should escape crazy identifiers" do
|
664
|
-
Deprecation.silence(Blacklight::SearchHelper) do
|
665
|
-
allow(subject.repository).to receive(:send_and_receive).with('select', hash_including("q" => "{!lucene}field_name:(\"h://\\\"\\\'\")")).and_return(@mock_response)
|
666
|
-
subject.get_solr_response_for_field_values('field_name', 'h://"\'')
|
667
|
-
end
|
668
|
-
end
|
669
|
-
end
|
670
|
-
|
671
400
|
# TODO: more complex queries! phrases, offset into search results, non-latin, boosting(?)
|
672
401
|
# search within query building (?)
|
673
402
|
# search + facets (search done first; facet selected first, both selected)
|
@@ -677,8 +406,7 @@ describe Blacklight::SearchHelper do
|
|
677
406
|
# nearby on shelf
|
678
407
|
it "should raise a Blacklight exception if RSolr can't connect to the Solr instance" do
|
679
408
|
allow(blacklight_solr).to receive(:send_and_receive).and_raise(Errno::ECONNREFUSED)
|
680
|
-
expect
|
681
|
-
expect { subject.query_solr }.to raise_exception(/Unable to connect to Solr instance/)
|
409
|
+
expect { subject.repository.search }.to raise_exception(/Unable to connect to Solr instance/)
|
682
410
|
end
|
683
411
|
|
684
412
|
describe "grouped_key_for_results" do
|
@@ -691,7 +419,7 @@ describe Blacklight::SearchHelper do
|
|
691
419
|
describe "#get_previous_and_next_documents_for_search" do
|
692
420
|
let(:pre_query) { SearchHelperTestClass.new blacklight_config, blacklight_solr }
|
693
421
|
before do
|
694
|
-
@full_response, @all_docs = pre_query.search_results(
|
422
|
+
@full_response, @all_docs = pre_query.search_results(q: '', per_page: '100')
|
695
423
|
end
|
696
424
|
|
697
425
|
it "should return the previous and next documents for a search" do
|