blacklight 5.5.1 → 5.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +8 -16
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -1
- data/app/helpers/blacklight/url_helper_behavior.rb +5 -1
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/blacklight.gemspec +2 -1
- data/gemfiles/rails3.gemfile +1 -1
- data/gemfiles/rails4.1.gemfile +1 -1
- data/gemfiles/rails4.gemfile +1 -1
- data/lib/blacklight/catalog.rb +0 -1
- data/lib/blacklight/solr/facet_paginator.rb +22 -10
- data/lib/generators/blacklight/install_generator.rb +1 -1
- data/spec/controllers/bookmarks_controller_spec.rb +6 -6
- data/spec/controllers/catalog_controller_spec.rb +48 -48
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/record_view_spec.rb +1 -1
- data/spec/features/search_filters_spec.rb +4 -4
- data/spec/features/search_results_spec.rb +12 -12
- data/spec/helpers/blacklight_helper_spec.rb +83 -83
- data/spec/helpers/catalog_helper_spec.rb +37 -37
- data/spec/helpers/configuration_helper_spec.rb +39 -39
- data/spec/helpers/facets_helper_spec.rb +37 -37
- data/spec/helpers/render_constraints_helper_spec.rb +6 -1
- data/spec/helpers/search_history_constraints_helper_spec.rb +9 -9
- data/spec/helpers/url_helper_spec.rb +49 -39
- data/spec/lib/blacklight/configurable_spec.rb +5 -5
- data/spec/lib/blacklight/configuration_spec.rb +8 -8
- data/spec/lib/blacklight/facet_paginator_spec.rb +25 -0
- data/spec/lib/blacklight/routes_spec.rb +4 -4
- data/spec/lib/blacklight/search_fields_spec.rb +3 -3
- data/spec/lib/blacklight/solr/document_spec.rb +2 -2
- data/spec/lib/blacklight/solr_helper_spec.rb +37 -37
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +1 -1
- data/spec/lib/blacklight/solr_response_spec.rb +31 -31
- data/spec/lib/document_presenter_spec.rb +41 -41
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/models/record_mailer_spec.rb +1 -1
- data/spec/models/search_spec.rb +1 -1
- data/spec/routing/catalog_routing_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/support/include_text.rb +2 -3
- data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_facets.html.erb_spec.rb +6 -6
- data/spec/views/catalog/_index_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +5 -5
- data/spec/views/catalog/_show_default.erb_spec.rb +10 -10
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +5 -5
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +4 -4
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +5 -2
- data/spec/views/catalog/facet.html.erb_spec.rb +5 -5
- data/spec/views/catalog/index.atom.builder_spec.rb +2 -2
- data/spec/views/catalog/index.html.erb_spec.rb +5 -5
- data/spec/views/catalog/show.html.erb_spec.rb +8 -8
- data/tasks/blacklight.rake +1 -2
- metadata +18 -4
@@ -7,8 +7,8 @@ describe Blacklight::Routes do
|
|
7
7
|
describe "without constraints" do
|
8
8
|
let(:options) { Hash.new }
|
9
9
|
it "should define the resources" do
|
10
|
-
router.
|
11
|
-
router.
|
10
|
+
allow(router).to receive(:resources).with(:solr_document, {:path=>:records, :controller=>:records, :only=>[:show]})
|
11
|
+
allow(router).to receive(:resources).with(:records, :only=>[:show])
|
12
12
|
subject.solr_document(:records)
|
13
13
|
end
|
14
14
|
end
|
@@ -16,8 +16,8 @@ describe Blacklight::Routes do
|
|
16
16
|
describe "with constraints" do
|
17
17
|
let(:options) { { :constraints => {id: /[a-z]+/, format: false } } }
|
18
18
|
it "should define the resources" do
|
19
|
-
router.
|
20
|
-
router.
|
19
|
+
allow(router).to receive(:resources).with(:solr_document, {:path=>:records, :controller=>:records, :only=>[:show], :constraints=>{:id=>/[a-z]+/, :format=>false} })
|
20
|
+
allow(router).to receive(:resources).with(:records, :only=>[:show], :constraints=>{:id=>/[a-z]+/, :format=>false})
|
21
21
|
subject.solr_document(:records)
|
22
22
|
end
|
23
23
|
end
|
@@ -20,7 +20,7 @@ describe Blacklight::SearchFields do
|
|
20
20
|
|
21
21
|
before(:each) do
|
22
22
|
@search_field_obj = MockConfig.new
|
23
|
-
@search_field_obj.
|
23
|
+
allow(@search_field_obj).to receive(:blacklight_config).and_return(@config)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should return search field list with calculated :label when needed" do
|
@@ -50,7 +50,7 @@ describe Blacklight::SearchFields do
|
|
50
50
|
@bad_config = MockConfig.new
|
51
51
|
end
|
52
52
|
it "should raise exception on #search_field_list" do
|
53
|
-
expect { @bad_config.
|
53
|
+
expect { allow(@bad_config).to receive(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
|
54
54
|
config.add_search_field :label => 'All Fields', :qt => 'all_fields'
|
55
55
|
config.add_search_field 'title', :qt => 'title_search'
|
56
56
|
}) }.to raise_error
|
@@ -62,7 +62,7 @@ describe Blacklight::SearchFields do
|
|
62
62
|
@bad_config = MockConfig.new
|
63
63
|
end
|
64
64
|
it "should raise on #search_field_list" do
|
65
|
-
expect { @bad_config.
|
65
|
+
expect { allow(@bad_config).to receive(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
|
66
66
|
config.add_search_field 'my_key', :label => 'All Fields'
|
67
67
|
config.add_search_field 'my_key', :label => 'title'
|
68
68
|
|
@@ -160,7 +160,7 @@ describe "Blacklight::Solr::Document" do
|
|
160
160
|
# registration in an after, sorry.
|
161
161
|
end
|
162
162
|
it "registers format" do
|
163
|
-
expect(defined?("Mime::MOCK2")).to
|
163
|
+
expect(defined?("Mime::MOCK2")).to be_truthy
|
164
164
|
end
|
165
165
|
it "registers as alias only" do
|
166
166
|
expect(Mime::Type.lookup("application/mock2")).not_to equal Mime::Type.lookup_by_extension("mock2")
|
@@ -176,7 +176,7 @@ describe "Blacklight::Solr::Document" do
|
|
176
176
|
it "should know if a document is exportable" do
|
177
177
|
doc = MockDocument.new
|
178
178
|
doc.will_export_as(:marc, "application/marc")
|
179
|
-
expect(doc.exports_as?(:marc)).to
|
179
|
+
expect(doc.exports_as?(:marc)).to be true
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -55,25 +55,25 @@ describe Blacklight::SolrHelper do
|
|
55
55
|
describe "#find" do
|
56
56
|
it "should use the configured solr path" do
|
57
57
|
blacklight_config.solr_path = 'xyz'
|
58
|
-
blacklight_solr.
|
58
|
+
allow(blacklight_solr).to receive(:send_and_receive).with('xyz', anything).and_return("{}".to_json)
|
59
59
|
expect(subject.find({})).to be_a_kind_of Blacklight::SolrResponse
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should override the configured solr path" do
|
63
63
|
blacklight_config.solr_path = 'xyz'
|
64
|
-
blacklight_solr.
|
64
|
+
allow(blacklight_solr).to receive(:send_and_receive).with('abc', anything).and_return("{}".to_json)
|
65
65
|
expect(subject.find('abc', {})).to be_a_kind_of Blacklight::SolrResponse
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should use a default :qt param" do
|
69
69
|
blacklight_config.qt = 'xyz'
|
70
|
-
blacklight_solr.
|
70
|
+
allow(blacklight_solr).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'xyz'})).and_return("{}".to_json)
|
71
71
|
expect(subject.find({})).to be_a_kind_of Blacklight::SolrResponse
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should use the provided :qt param" do
|
75
75
|
blacklight_config.qt = 'xyz'
|
76
|
-
blacklight_solr.
|
76
|
+
allow(blacklight_solr).to receive(:send_and_receive).with('select', hash_including(params: { qt: 'abc'})).and_return("{}".to_json)
|
77
77
|
expect(subject.find({qt: 'abc'})).to be_a_kind_of Blacklight::SolrResponse
|
78
78
|
end
|
79
79
|
|
@@ -82,7 +82,7 @@ describe Blacklight::SolrHelper do
|
|
82
82
|
|
83
83
|
it "defaults to get" do
|
84
84
|
expect(blacklight_config.http_method).to eq :get
|
85
|
-
blacklight_solr.
|
85
|
+
allow(blacklight_solr).to receive(:send_and_receive) do |path, params|
|
86
86
|
expect(path).to eq 'select'
|
87
87
|
expect(params[:method]).to eq :get
|
88
88
|
expect(params[:params]).to include(:q)
|
@@ -96,7 +96,7 @@ describe Blacklight::SolrHelper do
|
|
96
96
|
|
97
97
|
it "keep value set to post" do
|
98
98
|
expect(blacklight_config.http_method).to eq :post
|
99
|
-
blacklight_solr.
|
99
|
+
allow(blacklight_solr).to receive(:send_and_receive) do |path, params|
|
100
100
|
expect(path).to eq 'select'
|
101
101
|
expect(params[:method]).to eq :post
|
102
102
|
expect(params[:data]).to include(:q)
|
@@ -121,7 +121,7 @@ describe Blacklight::SolrHelper do
|
|
121
121
|
it "allows customization of solr_search_params_logic" do
|
122
122
|
# Normally you'd include a new module into (eg) your CatalogController
|
123
123
|
# but a sub-class defininig it directly is simpler for test.
|
124
|
-
subject.
|
124
|
+
allow(subject).to receive(:add_foo_to_solr_params) do |solr_params, user_params|
|
125
125
|
solr_params[:wt] = "TESTING"
|
126
126
|
end
|
127
127
|
|
@@ -260,19 +260,19 @@ describe Blacklight::SolrHelper do
|
|
260
260
|
end
|
261
261
|
|
262
262
|
it "should pass date-type fields through" do
|
263
|
-
blacklight_config.facet_fields.
|
263
|
+
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
|
264
264
|
|
265
265
|
expect(subject.send(:facet_value_to_fq_string, "facet_name", "2012-01-01")).to eq "facet_name:2012\\-01\\-01"
|
266
266
|
end
|
267
267
|
|
268
268
|
it "should escape datetime-type fields" do
|
269
|
-
blacklight_config.facet_fields.
|
269
|
+
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
|
270
270
|
|
271
271
|
expect(subject.send(:facet_value_to_fq_string, "facet_name", "2003-04-09T00:00:00Z")).to eq "facet_name:2003\\-04\\-09T00\\:00\\:00Z"
|
272
272
|
end
|
273
273
|
|
274
274
|
it "should format Date objects correctly" do
|
275
|
-
blacklight_config.facet_fields.
|
275
|
+
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => nil, :query => nil, :tag => nil))
|
276
276
|
d = DateTime.parse("2003-04-09T00:00:00")
|
277
277
|
expect(subject.send(:facet_value_to_fq_string, "facet_name", d)).to eq "facet_name:2003\\-04\\-09T00\\:00\\:00Z"
|
278
278
|
end
|
@@ -282,7 +282,7 @@ describe Blacklight::SolrHelper do
|
|
282
282
|
end
|
283
283
|
|
284
284
|
it "should add tag local parameters" do
|
285
|
-
blacklight_config.facet_fields.
|
285
|
+
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:query => nil, :tag => 'asdf', :date => nil))
|
286
286
|
|
287
287
|
expect(subject.send(:facet_value_to_fq_string, "facet_name", true)).to eq "{!tag=asdf}facet_name:true"
|
288
288
|
expect(subject.send(:facet_value_to_fq_string, "facet_name", "my value")).to eq "{!raw f=facet_name tag=asdf}my value"
|
@@ -334,7 +334,7 @@ describe Blacklight::SolrHelper do
|
|
334
334
|
|
335
335
|
describe "overriding of qt parameter" do
|
336
336
|
it "should return the correct overriden parameter" do
|
337
|
-
subject.
|
337
|
+
allow(subject).to receive_messages(params: { qt: 'overridden' })
|
338
338
|
|
339
339
|
expect(subject.solr_search_params[:qt]).to eq "overridden"
|
340
340
|
end
|
@@ -397,7 +397,7 @@ describe Blacklight::SolrHelper do
|
|
397
397
|
end
|
398
398
|
|
399
399
|
it "should add sort parameters" do
|
400
|
-
expect(solr_parameters[:facet]).to
|
400
|
+
expect(solr_parameters[:facet]).to be true
|
401
401
|
|
402
402
|
expect(solr_parameters[:'facet.field']).to include('test_field')
|
403
403
|
expect(solr_parameters[:'f.test_field.facet.sort']).to eq 'count'
|
@@ -494,7 +494,7 @@ describe Blacklight::SolrHelper do
|
|
494
494
|
end
|
495
495
|
|
496
496
|
before do
|
497
|
-
subject.
|
497
|
+
allow(subject).to receive_messages params: {:search_field => "test_field", :q => "test query", "facet.field" => "extra_facet"}
|
498
498
|
end
|
499
499
|
|
500
500
|
it "should merge parameters from search_field definition" do
|
@@ -579,7 +579,7 @@ describe Blacklight::SolrHelper do
|
|
579
579
|
end
|
580
580
|
|
581
581
|
before do
|
582
|
-
subject.
|
582
|
+
allow(subject).to receive_messages params: {:search_field => "custom_author_key", :q => "query"}
|
583
583
|
end
|
584
584
|
|
585
585
|
before do
|
@@ -666,7 +666,7 @@ describe Blacklight::SolrHelper do
|
|
666
666
|
|
667
667
|
describe 'if facet_list_limit is defined in controller' do
|
668
668
|
before do
|
669
|
-
subject.
|
669
|
+
allow(subject).to receive_messages facet_list_limit: 1000
|
670
670
|
end
|
671
671
|
it 'uses controller method for limit' do
|
672
672
|
solr_params = subject.solr_facet_params(@facet_field)
|
@@ -710,7 +710,7 @@ describe Blacklight::SolrHelper do
|
|
710
710
|
end
|
711
711
|
describe "for facet limit parameters config ed" do
|
712
712
|
before do
|
713
|
-
subject.
|
713
|
+
allow(subject).to receive_messages params: {:search_field => "test_field", :q => "test query"}
|
714
714
|
@generated_params = subject.solr_search_params
|
715
715
|
end
|
716
716
|
|
@@ -750,8 +750,8 @@ describe Blacklight::SolrHelper do
|
|
750
750
|
end
|
751
751
|
|
752
752
|
it "should use the configured request handler " do
|
753
|
-
blacklight_config.
|
754
|
-
blacklight_solr.
|
753
|
+
allow(blacklight_config).to receive(:default_solr_params).and_return({:qt => 'custom_request_handler'})
|
754
|
+
allow(blacklight_solr).to receive(:send_and_receive) do |path, params|
|
755
755
|
expect(path).to eq 'select'
|
756
756
|
expect(params[:params]['facet.field']).to eq ["format", "{!ex=pub_date_single}pub_date", "subject_topic_facet", "language_facet", "lc_1letter_facet", "subject_geo_facet", "subject_era_facet"]
|
757
757
|
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 *]"]
|
@@ -797,7 +797,7 @@ describe Blacklight::SolrHelper do
|
|
797
797
|
let(:blacklight_config) { copy_of_catalog_config }
|
798
798
|
|
799
799
|
before do
|
800
|
-
subject.
|
800
|
+
allow(subject).to receive_messages grouped_key_for_results: 'title_sort'
|
801
801
|
(@solr_response, @document_list) = subject.get_search_results({:q => @all_docs_query}, :group => true, :'group.field' => ['pub_date_sort', 'title_sort'])
|
802
802
|
end
|
803
803
|
|
@@ -1048,14 +1048,14 @@ describe Blacklight::SolrHelper do
|
|
1048
1048
|
end
|
1049
1049
|
|
1050
1050
|
it "should use a provided document request handler " do
|
1051
|
-
blacklight_config.
|
1052
|
-
blacklight_solr.
|
1051
|
+
allow(blacklight_config).to receive_messages(:document_solr_request_handler => 'document')
|
1052
|
+
allow(blacklight_solr).to receive(:send_and_receive).with('select', kind_of(Hash)).and_return({'response'=>{'docs'=>[]}})
|
1053
1053
|
expect { subject.get_solr_response_for_doc_id(@doc_id)}.to raise_error Blacklight::Exceptions::InvalidSolrID
|
1054
1054
|
end
|
1055
1055
|
|
1056
1056
|
it "should use a provided document solr path " do
|
1057
|
-
blacklight_config.
|
1058
|
-
blacklight_solr.
|
1057
|
+
allow(blacklight_config).to receive_messages(:document_solr_path => 'get')
|
1058
|
+
allow(blacklight_solr).to receive(:send_and_receive).with('get', kind_of(Hash)).and_return({'response'=>{'docs'=>[]}})
|
1059
1059
|
expect { subject.get_solr_response_for_doc_id(@doc_id)}.to raise_error Blacklight::Exceptions::InvalidSolrID
|
1060
1060
|
end
|
1061
1061
|
|
@@ -1085,7 +1085,7 @@ describe Blacklight::SolrHelper do
|
|
1085
1085
|
end
|
1086
1086
|
|
1087
1087
|
it "should use the document_unique_id_param configuration" do
|
1088
|
-
blacklight_config.
|
1088
|
+
allow(blacklight_config).to receive_messages(document_unique_id_param: :ids)
|
1089
1089
|
doc_params = subject.solr_doc_params('asdfg')
|
1090
1090
|
expect(doc_params[:ids]).to eq 'asdfg'
|
1091
1091
|
end
|
@@ -1105,7 +1105,7 @@ describe Blacklight::SolrHelper do
|
|
1105
1105
|
=begin
|
1106
1106
|
# Can't test this properly without updating the "document" request handler in solr
|
1107
1107
|
it "should respect the configuration-supplied unique id" do
|
1108
|
-
SolrDocument.
|
1108
|
+
allow(SolrDocument).to receive(:unique_key).and_return("title_display")
|
1109
1109
|
@response, @document = @solr_helper.get_solr_response_for_doc_id('"Strong Medicine speaks"')
|
1110
1110
|
@document.id).to eq '"Strong Medicine speaks"'
|
1111
1111
|
@document.get(:id)).to eq 2007020969
|
@@ -1135,7 +1135,7 @@ describe Blacklight::SolrHelper do
|
|
1135
1135
|
|
1136
1136
|
doc2 = get_single_doc_via_search(@all_docs_query, nil, @doc_row, @multi_facets)
|
1137
1137
|
it "should limit search result by facets when supplied" do
|
1138
|
-
|
1138
|
+
response2expect(.docs.numFound).to_be < response.docs.numFound
|
1139
1139
|
end
|
1140
1140
|
|
1141
1141
|
it "should not have facets in the response" do
|
@@ -1175,7 +1175,7 @@ describe Blacklight::SolrHelper do
|
|
1175
1175
|
expect(solr_response.spelling.words).to include('political') # more freq
|
1176
1176
|
=begin
|
1177
1177
|
# when we can have multiple suggestions
|
1178
|
-
solr_response.spelling.words.
|
1178
|
+
expect(solr_response.spelling.words).to_not include('policy') # less freq
|
1179
1179
|
solr_response.spelling.words).to include('politics') # more freq
|
1180
1180
|
solr_response.spelling.words).to include('political') # more freq
|
1181
1181
|
=end
|
@@ -1197,7 +1197,7 @@ describe Blacklight::SolrHelper do
|
|
1197
1197
|
end
|
1198
1198
|
|
1199
1199
|
it 'search results for multiple terms query with just-poor-enough-terms should have spelling suggestions for each term' do
|
1200
|
-
|
1200
|
+
skip
|
1201
1201
|
# get_spelling_suggestion("histo politica").should_not be_nil
|
1202
1202
|
end
|
1203
1203
|
|
@@ -1215,7 +1215,7 @@ describe Blacklight::SolrHelper do
|
|
1215
1215
|
|
1216
1216
|
it "facet_limit_hash should return hash with key being facet_field and value being configured limit" do
|
1217
1217
|
# facet_limit_hash has been removed from solrhelper in refactor. should it go back?
|
1218
|
-
|
1218
|
+
skip "facet_limit_hash has been removed from solrhelper in refactor. should it go back?"
|
1219
1219
|
expect(subject.facet_limit_hash).to eq blacklight_config[:facet][:limits]
|
1220
1220
|
end
|
1221
1221
|
it "should handle no facet_limits in config" do
|
@@ -1238,14 +1238,14 @@ describe Blacklight::SolrHelper do
|
|
1238
1238
|
end
|
1239
1239
|
it "should get from @response facet.limit if available" do
|
1240
1240
|
@response = double()
|
1241
|
-
@response.
|
1241
|
+
allow(@response).to receive(:facet_by_field_name).with("language_facet").and_return(double(limit: nil))
|
1242
1242
|
subject.instance_variable_set(:@response, @response)
|
1243
1243
|
blacklight_config.facet_fields['language_facet'].limit = 10
|
1244
1244
|
expect(subject.facet_limit_for("language_facet")).to eq 10
|
1245
1245
|
end
|
1246
1246
|
it "should get the limit from the facet field in @response" do
|
1247
1247
|
@response = double()
|
1248
|
-
@response.
|
1248
|
+
allow(@response).to receive(:facet_by_field_name).with("language_facet").and_return(double(limit: 16))
|
1249
1249
|
subject.instance_variable_set(:@response, @response)
|
1250
1250
|
expect(subject.facet_limit_for("language_facet")).to eq 15
|
1251
1251
|
end
|
@@ -1268,20 +1268,20 @@ describe Blacklight::SolrHelper do
|
|
1268
1268
|
describe "#get_solr_response_for_field_values" do
|
1269
1269
|
before do
|
1270
1270
|
@mock_response = double()
|
1271
|
-
@mock_response.
|
1271
|
+
allow(@mock_response).to receive_messages(documents: [])
|
1272
1272
|
end
|
1273
1273
|
it "should contruct a solr query based on the field and value pair" do
|
1274
|
-
subject.
|
1274
|
+
allow(subject).to receive(:find).with(hash_including(:q => "field_name:(value)")).and_return(@mock_response)
|
1275
1275
|
subject.get_solr_response_for_field_values('field_name', 'value')
|
1276
1276
|
end
|
1277
1277
|
|
1278
1278
|
it "should OR multiple values together" do
|
1279
|
-
subject.
|
1279
|
+
allow(subject).to receive(:find).with(hash_including(:q => "field_name:(a OR b)")).and_return(@mock_response)
|
1280
1280
|
subject.get_solr_response_for_field_values('field_name', ['a', 'b'])
|
1281
1281
|
end
|
1282
1282
|
|
1283
1283
|
it "should escape crazy identifiers" do
|
1284
|
-
subject.
|
1284
|
+
allow(subject).to receive(:find).with(hash_including(:q => "field_name:(\"h://\\\"\\\'\")")).and_return(@mock_response)
|
1285
1285
|
subject.get_solr_response_for_field_values('field_name', 'h://"\'')
|
1286
1286
|
end
|
1287
1287
|
end
|
@@ -1294,7 +1294,7 @@ describe Blacklight::SolrHelper do
|
|
1294
1294
|
# more like this
|
1295
1295
|
# nearby on shelf
|
1296
1296
|
it "should raise a Blacklight exception if RSolr can't connect to the Solr instance" do
|
1297
|
-
blacklight_solr.
|
1297
|
+
allow(blacklight_solr).to receive(:send_and_receive).and_raise(Errno::ECONNREFUSED)
|
1298
1298
|
expect { subject.find(:a => 123) }.to raise_exception(/Unable to connect to Solr instance/)
|
1299
1299
|
end
|
1300
1300
|
|
@@ -12,7 +12,7 @@ describe Blacklight::SolrResponse::GroupResponse do
|
|
12
12
|
|
13
13
|
describe "groups" do
|
14
14
|
it "should return an array of Groups" do
|
15
|
-
response.grouped.
|
15
|
+
expect(response.grouped).to be_a Array
|
16
16
|
|
17
17
|
expect(group.groups).to have(2).items
|
18
18
|
group.groups.each do |group|
|
@@ -28,16 +28,16 @@ describe Blacklight::SolrResponse do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should provide facet helpers' do
|
31
|
-
r.facets.size.
|
31
|
+
expect(r.facets.size).to eq 2
|
32
32
|
|
33
33
|
field_names = r.facets.collect{|facet|facet.name}
|
34
|
-
field_names.include?('cat').
|
35
|
-
field_names.include?('manu').
|
34
|
+
expect(field_names.include?('cat')).to be true
|
35
|
+
expect(field_names.include?('manu')).to be true
|
36
36
|
|
37
37
|
first_facet = r.facets.select { |x| x.name == 'cat'}.first
|
38
|
-
first_facet.name.
|
38
|
+
expect(first_facet.name).to eq 'cat'
|
39
39
|
|
40
|
-
first_facet.items.size.
|
40
|
+
expect(first_facet.items.size).to eq 10
|
41
41
|
|
42
42
|
expected = "electronics - 14, memory - 3, card - 2, connector - 2, drive - 2, graphics - 2, hard - 2, monitor - 2, search - 2, software - 2"
|
43
43
|
received = first_facet.items.collect do |item|
|
@@ -73,7 +73,7 @@ describe Blacklight::SolrResponse do
|
|
73
73
|
it "should provide a model name helper" do
|
74
74
|
first_doc_model_name = double(:human => 'xyz')
|
75
75
|
|
76
|
-
r.docs.first.
|
76
|
+
allow(r.docs.first).to receive(:model_name).and_return first_doc_model_name
|
77
77
|
|
78
78
|
expect(r.model_name).to eq first_doc_model_name
|
79
79
|
end
|
@@ -81,33 +81,33 @@ describe Blacklight::SolrResponse do
|
|
81
81
|
describe "FacetItem" do
|
82
82
|
it "should work with a field,value tuple" do
|
83
83
|
item = Blacklight::SolrResponse::Facets::FacetItem.new('value', 15)
|
84
|
-
item.value.
|
85
|
-
item.hits.
|
84
|
+
expect(item.value).to eq 'value'
|
85
|
+
expect(item.hits).to eq 15
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should work with a field,value + hash triple" do
|
89
89
|
item = Blacklight::SolrResponse::Facets::FacetItem.new('value', 15, :a => 1, :value => 'ignored')
|
90
|
-
item.value.
|
91
|
-
item.hits.
|
92
|
-
item.a.
|
90
|
+
expect(item.value).to eq 'value'
|
91
|
+
expect(item.hits).to eq 15
|
92
|
+
expect(item.a).to eq 1
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should work like an openstruct" do
|
96
96
|
item = Blacklight::SolrResponse::Facets::FacetItem.new(:value => 'value', :hits => 15)
|
97
97
|
|
98
|
-
item.hits.
|
99
|
-
item.value.
|
100
|
-
item.
|
98
|
+
expect(item.hits).to eq 15
|
99
|
+
expect(item.value).to eq 'value'
|
100
|
+
expect(item).to be_a_kind_of(OpenStruct)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should provide a label accessor" do
|
104
104
|
item = Blacklight::SolrResponse::Facets::FacetItem.new('value', :hits => 15)
|
105
|
-
item.label.
|
105
|
+
expect(item.label).to eq 'value'
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should use a provided label" do
|
109
109
|
item = Blacklight::SolrResponse::Facets::FacetItem.new('value', 15, :label => 'custom label')
|
110
|
-
item.label.
|
110
|
+
expect(item.label).to eq 'custom label'
|
111
111
|
|
112
112
|
end
|
113
113
|
|
@@ -116,78 +116,78 @@ describe Blacklight::SolrResponse do
|
|
116
116
|
it 'should return the correct value when calling facet_by_field_name' do
|
117
117
|
r = create_response
|
118
118
|
facet = r.facet_by_field_name('cat')
|
119
|
-
facet.name.
|
119
|
+
expect(facet.name).to eq 'cat'
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'should provide the responseHeader params' do
|
123
123
|
raw_response = eval(mock_query_response)
|
124
124
|
raw_response['responseHeader']['params']['test'] = :test
|
125
125
|
r = Blacklight::SolrResponse.new(raw_response, raw_response['params'])
|
126
|
-
r.params['test'].
|
126
|
+
expect(r.params['test']).to eq :test
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'should provide the solr-returned params and "rows" should be 11' do
|
130
130
|
raw_response = eval(mock_query_response)
|
131
131
|
r = Blacklight::SolrResponse.new(raw_response, {})
|
132
|
-
r.params[:rows].to_s.
|
132
|
+
expect(r.params[:rows].to_s).to eq '11'
|
133
133
|
end
|
134
134
|
|
135
135
|
it 'should provide the ruby request params if responseHeader["params"] does not exist' do
|
136
136
|
raw_response = eval(mock_query_response)
|
137
137
|
raw_response.delete 'responseHeader'
|
138
138
|
r = Blacklight::SolrResponse.new(raw_response, :rows => 999)
|
139
|
-
r.params[:rows].to_s.
|
139
|
+
expect(r.params[:rows].to_s).to eq '999'
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'should provide spelling suggestions for regular spellcheck results' do
|
143
143
|
raw_response = eval(mock_response_with_spellcheck)
|
144
144
|
r = Blacklight::SolrResponse.new(raw_response, {})
|
145
|
-
r.spelling.words.
|
146
|
-
r.spelling.words.
|
145
|
+
expect(r.spelling.words).to include("dell")
|
146
|
+
expect(r.spelling.words).to include("ultrasharp")
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'should provide spelling suggestions for extended spellcheck results' do
|
150
150
|
raw_response = eval(mock_response_with_spellcheck_extended)
|
151
151
|
r = Blacklight::SolrResponse.new(raw_response, {})
|
152
|
-
r.spelling.words.
|
153
|
-
r.spelling.words.
|
152
|
+
expect(r.spelling.words).to include("dell")
|
153
|
+
expect(r.spelling.words).to include("ultrasharp")
|
154
154
|
end
|
155
155
|
|
156
156
|
it 'should provide no spelling suggestions when extended results and suggestion frequency is the same as original query frequency' do
|
157
157
|
raw_response = eval(mock_response_with_spellcheck_same_frequency)
|
158
158
|
r = Blacklight::SolrResponse.new(raw_response, {})
|
159
|
-
r.spelling.words.
|
159
|
+
expect(r.spelling.words).to eq []
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'should provide spelling suggestions for a regular spellcheck results with a collation' do
|
163
163
|
raw_response = eval(mock_response_with_spellcheck_collation)
|
164
164
|
r = Blacklight::SolrResponse.new(raw_response, {})
|
165
|
-
r.spelling.words.
|
166
|
-
r.spelling.words.
|
165
|
+
expect(r.spelling.words).to include("dell")
|
166
|
+
expect(r.spelling.words).to include("ultrasharp")
|
167
167
|
end
|
168
168
|
|
169
169
|
it 'should provide spelling suggestion collation' do
|
170
170
|
raw_response = eval(mock_response_with_spellcheck_collation)
|
171
171
|
r = Blacklight::SolrResponse.new(raw_response, {})
|
172
|
-
r.spelling.collation.
|
172
|
+
expect(r.spelling.collation).to eq 'dell ultrasharp'
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should provide MoreLikeThis suggestions" do
|
176
176
|
raw_response = eval(mock_response_with_more_like_this)
|
177
177
|
r = Blacklight::SolrResponse.new(raw_response, {})
|
178
|
-
r.more_like(double(:id => '79930185')).
|
178
|
+
expect(r.more_like(double(:id => '79930185'))).to have(2).items
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should be empty when the response has no results" do
|
182
182
|
r = Blacklight::SolrResponse.new({}, {})
|
183
|
-
r.
|
183
|
+
allow(r).to receive_messages(:total => 0)
|
184
184
|
expect(r).to be_empty
|
185
185
|
end
|
186
186
|
|
187
187
|
describe "#export_formats" do
|
188
188
|
it "should collect the unique export formats for the current response" do
|
189
189
|
r = Blacklight::SolrResponse.new({}, {})
|
190
|
-
r.
|
190
|
+
allow(r).to receive_messages(documents: [double(:export_formats => { a: 1, b: 2}), double(:export_formats => { b: 1, c: 2})])
|
191
191
|
expect(r.export_formats).to include :a, :b
|
192
192
|
end
|
193
193
|
end
|