blacklight 4.7.0 → 4.8.0
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/.gitignore +1 -0
- data/.travis.yml +13 -12
- data/Gemfile +37 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/{_blacklight_base.css.scss → _blacklight_base.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_bookmark.css.scss → _bookmark.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_catalog.css.scss → _catalog.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_dropdown.css.scss → _dropdown.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_facets.css.scss → _facets.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_footer.css.scss → _footer.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_group.css.scss → _group.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_header.css.scss → _header.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_layout.css.scss → _layout.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_mixins.css.scss → _mixins.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_modal.css.scss → _modal.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_print.css.scss → _print.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_responsive.css.scss → _responsive.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{_search_history.css.scss → _search_history.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{blacklight.css.scss → blacklight.scss} +0 -0
- data/app/assets/stylesheets/blacklight/{blacklight_defaults.css.scss → blacklight_defaults.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_catalog.css.scss → _catalog.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_facets.css.scss → _facets.scss} +0 -0
- data/app/assets/stylesheets/blacklight/responsive_partials/{_header.css.scss → _header.scss} +0 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +2 -2
- data/blacklight.gemspec +5 -6
- data/lib/blacklight/catalog.rb +1 -1
- data/lib/blacklight/catalog/search_context.rb +6 -6
- data/lib/blacklight/solr/document.rb +29 -21
- data/lib/blacklight/solr_helper.rb +6 -4
- data/lib/generators/blacklight/templates/{blacklight.css.scss → blacklight.scss} +0 -0
- data/spec/controllers/application_controller_spec.rb +3 -3
- data/spec/controllers/bookmarks_controller_spec.rb +11 -11
- data/spec/controllers/catalog_controller_spec.rb +117 -117
- data/spec/controllers/search_history_controller_spec.rb +8 -8
- data/spec/features/alternate_controller_spec.rb +7 -5
- data/spec/features/record_view_spec.rb +4 -1
- data/spec/features/search_filters_spec.rb +37 -24
- data/spec/features/search_pagination_spec.rb +11 -7
- data/spec/features/search_results_spec.rb +22 -14
- data/spec/features/search_sort_spec.rb +3 -1
- data/spec/features/search_spec.rb +6 -0
- data/spec/helpers/blacklight_helper_spec.rb +175 -166
- data/spec/helpers/catalog_helper_spec.rb +59 -59
- data/spec/helpers/facets_helper_spec.rb +118 -118
- data/spec/helpers/hash_as_hidden_fields_spec.rb +14 -8
- data/spec/helpers/html_head_helper_spec.rb +51 -45
- data/spec/helpers/render_constraints_helper_spec.rb +5 -6
- data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
- data/spec/lib/blacklight_configurable_spec.rb +16 -16
- data/spec/lib/blacklight_configuration_spec.rb +132 -132
- data/spec/lib/blacklight_email_spec.rb +4 -4
- data/spec/lib/blacklight_sms_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
- data/spec/lib/blacklight_solr_document_marc_spec.rb +3 -3
- data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_spec.rb +36 -36
- data/spec/lib/blacklight_solr_response_spec.rb +42 -42
- data/spec/lib/blacklight_spec.rb +5 -5
- data/spec/lib/blacklight_user_spec.rb +5 -5
- data/spec/lib/facet_paginator_spec.rb +12 -12
- data/spec/lib/marc_export_spec.rb +746 -746
- data/spec/lib/search_fields_spec.rb +13 -13
- data/spec/lib/solr_helper_spec.rb +255 -250
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/lib/tasks/solr_marc_task_spec.rb +6 -6
- data/spec/lib/utils_spec.rb +11 -11
- data/spec/models/bookmark_spec.rb +7 -6
- data/spec/models/record_mailer_spec.rb +16 -16
- data/spec/models/search_spec.rb +8 -8
- data/spec/models/solr_document_spec.rb +7 -7
- data/spec/requests/alternate_controller_spec.rb +3 -3
- data/spec/routing/catalog_routing_spec.rb +10 -15
- data/spec/spec_helper.rb +6 -4
- data/spec/support/assert_difference.rb +2 -2
- data/spec/support/features.rb +11 -0
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/support/include_text.rb +2 -2
- data/spec/test_app_templates/Gemfile.extra +2 -15
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -6
- data/spec/views/catalog/_constraints.html.erb_spec.rb +7 -7
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +12 -12
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +13 -13
- data/spec/views/catalog/_index_default.erb_spec.rb +20 -20
- data/spec/views/catalog/_show_default.erb_spec.rb +20 -20
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +6 -6
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +28 -28
- data/spec/views/catalog/index.html.erb_spec.rb +6 -6
- metadata +35 -57
- data/gemfiles/rails3.gemfile +0 -25
- data/gemfiles/rails4.gemfile +0 -24
|
@@ -21,12 +21,12 @@ describe Blacklight::SearchFields do
|
|
|
21
21
|
|
|
22
22
|
before(:each) do
|
|
23
23
|
@search_field_obj = MockConfig.new
|
|
24
|
-
@search_field_obj.
|
|
24
|
+
allow(@search_field_obj).to receive(:blacklight_config).and_return(@config)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it "should return search field list with calculated :label when needed" do
|
|
28
28
|
@search_field_obj.search_field_list.each do |hash|
|
|
29
|
-
hash.label.
|
|
29
|
+
expect(hash.label).not_to be_blank
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -42,30 +42,30 @@ describe Blacklight::SearchFields do
|
|
|
42
42
|
argument = select_arguments[index]
|
|
43
43
|
config_hash = @search_field_obj.search_field_list[index]
|
|
44
44
|
|
|
45
|
-
argument.length.
|
|
46
|
-
argument[0].
|
|
47
|
-
argument[1].
|
|
45
|
+
expect(argument.length).to eq(2)
|
|
46
|
+
expect(argument[0]).to eq(config_hash.label)
|
|
47
|
+
expect(argument[1]).to eq(config_hash.key)
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "should not include fields in select if :display_in_simple_search=>false" do
|
|
52
52
|
select_arguments = @search_field_obj.search_field_options_for_select
|
|
53
53
|
|
|
54
|
-
select_arguments.
|
|
54
|
+
expect(select_arguments).not_to include(["No Display", "no_display"])
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
it "should lookup field definitions by key" do
|
|
60
|
-
@search_field_obj.search_field_def_for_key("title").key.
|
|
60
|
+
expect(@search_field_obj.search_field_def_for_key("title").key).to eq("title")
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "should find label by key" do
|
|
64
|
-
@search_field_obj.label_for_search_field("title").
|
|
64
|
+
expect(@search_field_obj.label_for_search_field("title")).to eq("Title")
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "should supply default label for key not found" do
|
|
68
|
-
@search_field_obj.label_for_search_field("non_existent_key").
|
|
68
|
+
expect(@search_field_obj.label_for_search_field("non_existent_key")).to eq("Keyword")
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
describe "for unspecified :key" do
|
|
@@ -73,10 +73,10 @@ describe Blacklight::SearchFields do
|
|
|
73
73
|
@bad_config = MockConfig.new
|
|
74
74
|
end
|
|
75
75
|
it "should raise exception on #search_field_list" do
|
|
76
|
-
|
|
76
|
+
expect { allow(@bad_config).to receive(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
|
|
77
77
|
config.add_search_field :label => 'All Fields', :qt => 'all_fields'
|
|
78
78
|
config.add_search_field 'title', :qt => 'title_search'
|
|
79
|
-
}) }.
|
|
79
|
+
}) }.to raise_error
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
@@ -85,11 +85,11 @@ describe Blacklight::SearchFields do
|
|
|
85
85
|
@bad_config = MockConfig.new
|
|
86
86
|
end
|
|
87
87
|
it "should raise on #search_field_list" do
|
|
88
|
-
|
|
88
|
+
expect { allow(@bad_config).to receive(:blacklight_config).and_return(Blacklight::Configuration.new { |config|
|
|
89
89
|
config.add_search_field 'my_key', :label => 'All Fields'
|
|
90
90
|
config.add_search_field 'my_key', :label => 'title'
|
|
91
91
|
|
|
92
|
-
}) }.
|
|
92
|
+
}) }.to raise_error
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
@@ -26,7 +26,7 @@ describe 'Blacklight::SolrHelper' do
|
|
|
26
26
|
def blacklight_config
|
|
27
27
|
@config ||= CatalogController.blacklight_config
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
def blacklight_config=(config)
|
|
31
31
|
@config = config
|
|
32
32
|
end
|
|
@@ -51,25 +51,25 @@ describe 'Blacklight::SolrHelper' do
|
|
|
51
51
|
@subject_search_params = {:commit=>"search", :search_field=>"subject", :action=>"index", :"controller"=>"catalog", :"rows"=>"10", :"q"=>"wome"}
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
|
|
56
56
|
# SPECS for actual search parameter generation
|
|
57
57
|
describe "solr_search_params" do
|
|
58
58
|
it "allows customization of solr_search_params_logic" do
|
|
59
59
|
# Normally you'd include a new module into (eg) your CatalogController
|
|
60
|
-
# but a sub-class defininig it directly is simpler for test.
|
|
60
|
+
# but a sub-class defininig it directly is simpler for test.
|
|
61
61
|
def add_foo_to_solr_params(solr_params, user_params)
|
|
62
62
|
solr_params[:foo] = "TESTING"
|
|
63
63
|
end
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
|
|
65
|
+
|
|
66
66
|
self.solr_search_params_logic += [:add_foo_to_solr_params]
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
self.solr_search_params[:foo].
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
expect(self.solr_search_params[:foo]).to eq("TESTING")
|
|
70
70
|
end
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
|
|
72
|
+
|
|
73
73
|
describe 'for an entirely empty search' do
|
|
74
74
|
def params
|
|
75
75
|
{}
|
|
@@ -78,40 +78,40 @@ describe 'Blacklight::SolrHelper' do
|
|
|
78
78
|
@produced_params = self.solr_search_params
|
|
79
79
|
end
|
|
80
80
|
it 'should not have a q param' do
|
|
81
|
-
@produced_params[:q].
|
|
82
|
-
@produced_params["spellcheck.q"].
|
|
81
|
+
expect(@produced_params[:q]).to be_nil
|
|
82
|
+
expect(@produced_params["spellcheck.q"]).to be_nil
|
|
83
83
|
end
|
|
84
84
|
it 'should have default rows' do
|
|
85
|
-
@produced_params[:rows].
|
|
85
|
+
expect(@produced_params[:rows]).to eq(10)
|
|
86
86
|
end
|
|
87
87
|
it 'should have default facet fields' do
|
|
88
88
|
# remove local params from the facet.field
|
|
89
|
-
@produced_params[:"facet.field"].map { |x| x.gsub(/\{![^}]+\}/, '') }.
|
|
89
|
+
expect(@produced_params[:"facet.field"].map { |x| x.gsub(/\{![^}]+\}/, '') }).to eq(blacklight_config.facet_fields_to_add_to_solr)
|
|
90
90
|
end
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
it "should have default qt" do
|
|
93
|
-
@produced_params[:qt].
|
|
93
|
+
expect(@produced_params[:qt]).to eq("search")
|
|
94
94
|
end
|
|
95
95
|
it "should have no fq" do
|
|
96
|
-
@produced_params[:phrase_filters].
|
|
97
|
-
@produced_params[:fq].
|
|
96
|
+
expect(@produced_params[:phrase_filters]).to be_blank
|
|
97
|
+
expect(@produced_params[:fq]).to be_blank
|
|
98
98
|
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
|
|
102
|
-
describe "for an empty string search" do
|
|
103
|
-
it "should return empty string q in solr parameters" do
|
|
102
|
+
describe "for an empty string search" do
|
|
103
|
+
it "should return empty string q in solr parameters" do
|
|
104
104
|
solr_params = solr_search_params(:q => "")
|
|
105
|
-
solr_params[:q].
|
|
106
|
-
solr_params["spellcheck.q"].
|
|
105
|
+
expect(solr_params[:q]).to eq("")
|
|
106
|
+
expect(solr_params["spellcheck.q"]).to eq("")
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
describe "for request params also passed in as argument" do
|
|
111
|
-
it "should only have one 'q' key, as symbol" do
|
|
110
|
+
describe "for request params also passed in as argument" do
|
|
111
|
+
it "should only have one 'q' key, as symbol" do
|
|
112
112
|
solr_params = solr_search_params( :q => "some query" )
|
|
113
|
-
solr_params.keys.
|
|
114
|
-
solr_params.keys.
|
|
113
|
+
expect(solr_params.keys).to include(:q)
|
|
114
|
+
expect(solr_params.keys).not_to include("q")
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
117
|
|
|
@@ -121,11 +121,11 @@ describe 'Blacklight::SolrHelper' do
|
|
|
121
121
|
|
|
122
122
|
solr_params = solr_search_params(:f => @single_facet)
|
|
123
123
|
|
|
124
|
-
solr_params[:q].
|
|
125
|
-
solr_params["spellcheck.q"].
|
|
124
|
+
expect(solr_params[:q]).to be_blank
|
|
125
|
+
expect(solr_params["spellcheck.q"]).to be_blank
|
|
126
126
|
|
|
127
127
|
@single_facet.each_value do |value|
|
|
128
|
-
solr_params[:fq].
|
|
128
|
+
expect(solr_params[:fq]).to include("{!raw f=#{@single_facet.keys[0]}}#{value}")
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
end
|
|
@@ -138,7 +138,7 @@ describe 'Blacklight::SolrHelper' do
|
|
|
138
138
|
value_list ||= []
|
|
139
139
|
value_list = [value_list] unless value_list.respond_to? :each
|
|
140
140
|
value_list.each do |value|
|
|
141
|
-
solr_params[:fq].
|
|
141
|
+
expect(solr_params[:fq]).to include("{!raw f=#{facet_field}}#{value}" )
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
|
|
@@ -153,10 +153,10 @@ describe 'Blacklight::SolrHelper' do
|
|
|
153
153
|
value_list ||= []
|
|
154
154
|
value_list = [value_list] unless value_list.respond_to? :each
|
|
155
155
|
value_list.each do |value|
|
|
156
|
-
solr_params[:fq].
|
|
156
|
+
expect(solr_params[:fq]).to include("{!raw f=#{facet_field}}#{value}" )
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
|
-
solr_params[:q].
|
|
159
|
+
expect(solr_params[:q]).to eq(@mult_word_query)
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
|
|
@@ -167,48 +167,60 @@ describe 'Blacklight::SolrHelper' do
|
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
it "should use the raw handler for strings" do
|
|
170
|
-
facet_value_to_fq_string("facet_name", "my value").
|
|
170
|
+
expect(facet_value_to_fq_string("facet_name", "my value")).to eq("{!raw f=facet_name}my value")
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
it "should pass booleans through" do
|
|
174
|
-
facet_value_to_fq_string("facet_name", true).
|
|
174
|
+
expect(facet_value_to_fq_string("facet_name", true)).to eq("facet_name:true")
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
it "should pass boolean-like strings through" do
|
|
178
|
-
facet_value_to_fq_string("facet_name", "true").
|
|
178
|
+
expect(facet_value_to_fq_string("facet_name", "true")).to eq("facet_name:true")
|
|
179
179
|
end
|
|
180
180
|
|
|
181
181
|
it "should pass integers through" do
|
|
182
|
-
facet_value_to_fq_string("facet_name", 1).
|
|
182
|
+
expect(facet_value_to_fq_string("facet_name", 1)).to eq("facet_name:1")
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
it "should pass integer-like strings through" do
|
|
186
|
-
facet_value_to_fq_string("facet_name", "1").
|
|
186
|
+
expect(facet_value_to_fq_string("facet_name", "1")).to eq("facet_name:1")
|
|
187
187
|
end
|
|
188
188
|
|
|
189
189
|
it "should pass floats through" do
|
|
190
|
-
facet_value_to_fq_string("facet_name", 1.11).
|
|
190
|
+
expect(facet_value_to_fq_string("facet_name", 1.11)).to eq("facet_name:1.11")
|
|
191
191
|
end
|
|
192
192
|
|
|
193
193
|
it "should pass floats through" do
|
|
194
|
-
facet_value_to_fq_string("facet_name", "1.11").
|
|
194
|
+
expect(facet_value_to_fq_string("facet_name", "1.11")).to eq("facet_name:1.11")
|
|
195
195
|
end
|
|
196
196
|
|
|
197
197
|
it "should pass date-type fields through" do
|
|
198
|
-
blacklight_config.facet_fields.
|
|
198
|
+
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
|
|
199
|
+
|
|
200
|
+
expect(facet_value_to_fq_string("facet_name", "2012-01-01")).to eq "facet_name:2012\\-01\\-01"
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it "should escape datetime-type fields" do
|
|
204
|
+
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => true, :query => nil, :tag => nil))
|
|
199
205
|
|
|
200
|
-
facet_value_to_fq_string("facet_name", "
|
|
206
|
+
expect(facet_value_to_fq_string("facet_name", "2003-04-09T00:00:00Z")).to eq "facet_name:2003\\-04\\-09T00\\:00\\:00Z"
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
it "should format Date objects correctly" do
|
|
210
|
+
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:date => nil, :query => nil, :tag => nil))
|
|
211
|
+
d = DateTime.parse("2003-04-09T00:00:00")
|
|
212
|
+
expect(facet_value_to_fq_string("facet_name", d)).to eq "facet_name:2003\\-04\\-09T00\\:00\\:00Z"
|
|
201
213
|
end
|
|
202
214
|
|
|
203
215
|
it "should handle range requests" do
|
|
204
|
-
facet_value_to_fq_string("facet_name", 1..5).
|
|
216
|
+
expect(facet_value_to_fq_string("facet_name", 1..5)).to eq("facet_name:[1 TO 5]")
|
|
205
217
|
end
|
|
206
218
|
|
|
207
219
|
it "should add tag local parameters" do
|
|
208
|
-
blacklight_config.facet_fields.
|
|
220
|
+
allow(blacklight_config.facet_fields).to receive(:[]).with('facet_name').and_return(double(:query => nil, :tag => 'asdf', :date => nil))
|
|
209
221
|
|
|
210
|
-
facet_value_to_fq_string("facet_name", true).
|
|
211
|
-
facet_value_to_fq_string("facet_name", "my value").
|
|
222
|
+
expect(facet_value_to_fq_string("facet_name", true)).to eq("{!tag=asdf}facet_name:true")
|
|
223
|
+
expect(facet_value_to_fq_string("facet_name", "my value")).to eq("{!raw f=facet_name tag=asdf}my value")
|
|
212
224
|
end
|
|
213
225
|
end
|
|
214
226
|
|
|
@@ -217,29 +229,29 @@ describe 'Blacklight::SolrHelper' do
|
|
|
217
229
|
@solr_params = solr_search_params( @subject_search_params )
|
|
218
230
|
end
|
|
219
231
|
it "should look up qt from field definition" do
|
|
220
|
-
@solr_params[:qt].
|
|
232
|
+
expect(@solr_params[:qt]).to eq("search")
|
|
221
233
|
end
|
|
222
234
|
it "should not include weird keys not in field definition" do
|
|
223
|
-
@solr_params[:phrase_filters].
|
|
224
|
-
@solr_params[:fq].
|
|
225
|
-
@solr_params[:commit].
|
|
226
|
-
@solr_params[:action].
|
|
227
|
-
@solr_params[:controller].
|
|
235
|
+
expect(@solr_params[:phrase_filters]).to be_nil
|
|
236
|
+
expect(@solr_params[:fq]).to be_nil
|
|
237
|
+
expect(@solr_params[:commit]).to be_nil
|
|
238
|
+
expect(@solr_params[:action]).to be_nil
|
|
239
|
+
expect(@solr_params[:controller]).to be_nil
|
|
228
240
|
end
|
|
229
241
|
it "should include proper 'q', possibly with LocalParams" do
|
|
230
|
-
@solr_params[:q].
|
|
242
|
+
expect(@solr_params[:q]).to match(/(\{[^}]+\})?wome/)
|
|
231
243
|
end
|
|
232
244
|
it "should include proper 'q' when LocalParams are used" do
|
|
233
245
|
if @solr_params[:q] =~ /\{[^}]+\}/
|
|
234
|
-
@solr_params[:q].
|
|
246
|
+
expect(@solr_params[:q]).to match(/\{[^}]+\}wome/)
|
|
235
247
|
end
|
|
236
248
|
end
|
|
237
249
|
it "should include spellcheck.q, without LocalParams" do
|
|
238
|
-
@solr_params["spellcheck.q"].
|
|
250
|
+
expect(@solr_params["spellcheck.q"]).to eq("wome")
|
|
239
251
|
end
|
|
240
252
|
|
|
241
253
|
it "should include spellcheck.dictionary from field def solr_parameters" do
|
|
242
|
-
@solr_params[:"spellcheck.dictionary"].
|
|
254
|
+
expect(@solr_params[:"spellcheck.dictionary"]).to eq("subject")
|
|
243
255
|
end
|
|
244
256
|
it "should add on :solr_local_parameters using Solr LocalParams style" do
|
|
245
257
|
params = solr_search_params( @subject_search_params )
|
|
@@ -248,8 +260,8 @@ describe 'Blacklight::SolrHelper' do
|
|
|
248
260
|
#the LocalParams are really there
|
|
249
261
|
params[:q] =~ /^\{!([^}]+)\}/
|
|
250
262
|
key_value_pairs = $1.split(" ")
|
|
251
|
-
key_value_pairs.
|
|
252
|
-
key_value_pairs.
|
|
263
|
+
expect(key_value_pairs).to include("pf=$subject_pf")
|
|
264
|
+
expect(key_value_pairs).to include("qf=$subject_qf")
|
|
253
265
|
end
|
|
254
266
|
end
|
|
255
267
|
|
|
@@ -258,18 +270,18 @@ describe 'Blacklight::SolrHelper' do
|
|
|
258
270
|
def params
|
|
259
271
|
super.merge(:qt => "overridden")
|
|
260
272
|
end
|
|
261
|
-
|
|
262
|
-
solr_search_params[:qt].
|
|
273
|
+
|
|
274
|
+
expect(solr_search_params[:qt]).to eq("overridden")
|
|
263
275
|
end
|
|
264
276
|
end
|
|
265
277
|
|
|
266
278
|
describe "converts a String fq into an Array" do
|
|
267
279
|
it "should return the correct overriden parameter" do
|
|
268
280
|
solr_parameters = {:fq => 'a string' }
|
|
269
|
-
|
|
281
|
+
|
|
270
282
|
add_facet_fq_to_solr(solr_parameters, {})
|
|
271
283
|
|
|
272
|
-
solr_parameters[:fq].
|
|
284
|
+
expect(solr_parameters[:fq]).to be_a_kind_of Array
|
|
273
285
|
end
|
|
274
286
|
end
|
|
275
287
|
|
|
@@ -289,13 +301,13 @@ describe 'Blacklight::SolrHelper' do
|
|
|
289
301
|
it "should return the correct solr parameters" do
|
|
290
302
|
|
|
291
303
|
solr_parameters = { }
|
|
292
|
-
|
|
304
|
+
|
|
293
305
|
add_facetting_to_solr(solr_parameters, {})
|
|
294
306
|
|
|
295
|
-
expect(solr_parameters[:facet]).to
|
|
307
|
+
expect(solr_parameters[:facet]).to eq true
|
|
296
308
|
|
|
297
|
-
solr_parameters[:'facet.field'].
|
|
298
|
-
solr_parameters[:'f.test_field.facet.sort'].
|
|
309
|
+
expect(solr_parameters[:'facet.field']).to include('test_field')
|
|
310
|
+
expect(solr_parameters[:'f.test_field.facet.sort']).to eq('count')
|
|
299
311
|
end
|
|
300
312
|
|
|
301
313
|
it "should add facet exclusions" do
|
|
@@ -303,33 +315,33 @@ describe 'Blacklight::SolrHelper' do
|
|
|
303
315
|
|
|
304
316
|
add_facetting_to_solr(solr_parameters, {})
|
|
305
317
|
|
|
306
|
-
solr_parameters[:'facet.query'].
|
|
307
|
-
solr_parameters[:'facet.pivot'].
|
|
318
|
+
expect(solr_parameters[:'facet.query']).to include('{!ex=xyz}some:query')
|
|
319
|
+
expect(solr_parameters[:'facet.pivot']).to include('{!ex=xyz}a,b')
|
|
308
320
|
end
|
|
309
321
|
end
|
|
310
322
|
|
|
311
323
|
describe "with a complex parameter environment" do
|
|
312
|
-
def blacklight_config
|
|
324
|
+
def blacklight_config
|
|
313
325
|
config = Blacklight::Configuration.new
|
|
314
326
|
config.add_search_field("test_field",
|
|
315
|
-
:display_label => "Test",
|
|
316
|
-
:key=>"test_field",
|
|
327
|
+
:display_label => "Test",
|
|
328
|
+
:key=>"test_field",
|
|
317
329
|
:solr_parameters => {:qf => "fieldOne^2.3 fieldTwo fieldThree^0.4", :pf => "", :spellcheck => 'false', :rows => "55", :sort => "request_params_sort" }
|
|
318
330
|
)
|
|
319
331
|
return config
|
|
320
332
|
end
|
|
321
|
-
def params
|
|
333
|
+
def params
|
|
322
334
|
{:search_field => "test_field", :q => "test query", "facet.field" => "extra_facet"}
|
|
323
335
|
end
|
|
324
|
-
|
|
336
|
+
|
|
325
337
|
it "should merge parameters from search_field definition" do
|
|
326
338
|
solr_params = solr_search_params
|
|
327
|
-
|
|
328
|
-
solr_params[:qf].
|
|
329
|
-
solr_params[:spellcheck].
|
|
339
|
+
|
|
340
|
+
expect(solr_params[:qf]).to eq("fieldOne^2.3 fieldTwo fieldThree^0.4")
|
|
341
|
+
expect(solr_params[:spellcheck]).to eq('false')
|
|
330
342
|
end
|
|
331
343
|
it "should merge empty string parameters from search_field definition" do
|
|
332
|
-
solr_search_params[:pf].
|
|
344
|
+
expect(solr_search_params[:pf]).to eq("")
|
|
333
345
|
end
|
|
334
346
|
|
|
335
347
|
describe "should respect proper precedence of settings, " do
|
|
@@ -339,53 +351,53 @@ describe 'Blacklight::SolrHelper' do
|
|
|
339
351
|
|
|
340
352
|
|
|
341
353
|
it "should not put :search_field in produced params" do
|
|
342
|
-
@produced_params[:search_field].
|
|
354
|
+
expect(@produced_params[:search_field]).to be_nil
|
|
343
355
|
end
|
|
344
356
|
|
|
345
357
|
it "should fall through to BL general defaults for qt not otherwise specified " do
|
|
346
|
-
@produced_params[:qt].
|
|
358
|
+
expect(@produced_params[:qt]).to eq(blacklight_config[:default_solr_params][:qt])
|
|
347
359
|
end
|
|
348
360
|
|
|
349
361
|
it "should take rows from search field definition where specified" do
|
|
350
|
-
@produced_params[:rows].
|
|
362
|
+
expect(@produced_params[:rows]).to eq("55")
|
|
351
363
|
end
|
|
352
364
|
|
|
353
365
|
it "should take q from request params" do
|
|
354
|
-
@produced_params[:q].
|
|
366
|
+
expect(@produced_params[:q]).to eq("test query")
|
|
355
367
|
end
|
|
356
368
|
|
|
357
369
|
it "should add in extra facet.field from params" do
|
|
358
|
-
@produced_params[:"facet.field"].
|
|
370
|
+
expect(@produced_params[:"facet.field"]).to include("extra_facet")
|
|
359
371
|
end
|
|
360
372
|
|
|
361
373
|
end
|
|
362
374
|
end
|
|
363
375
|
|
|
364
376
|
describe "sorting" do
|
|
365
|
-
|
|
366
|
-
it "should send the default sort parameter to solr" do
|
|
367
|
-
solr_search_params[:sort].
|
|
377
|
+
|
|
378
|
+
it "should send the default sort parameter to solr" do
|
|
379
|
+
expect(solr_search_params[:sort]).to eq('score desc, pub_date_sort desc, title_sort asc')
|
|
368
380
|
end
|
|
369
381
|
|
|
370
382
|
it "should not send a sort parameter to solr if the sort value is blank" do
|
|
371
|
-
def blacklight_config
|
|
383
|
+
def blacklight_config
|
|
372
384
|
config = Blacklight::Configuration.new
|
|
373
385
|
config.add_sort_field('', :label => 'test')
|
|
374
386
|
return config
|
|
375
387
|
end
|
|
376
388
|
|
|
377
389
|
produced_params = solr_search_params
|
|
378
|
-
produced_params.
|
|
390
|
+
expect(produced_params).not_to have_key(:sort)
|
|
379
391
|
end
|
|
380
392
|
|
|
381
393
|
it "should pass through user sort parameters" do
|
|
382
394
|
produced_params = solr_search_params( :sort => 'solr_test_field desc' )
|
|
383
|
-
produced_params[:sort].
|
|
395
|
+
expect(produced_params[:sort]).to eq('solr_test_field desc')
|
|
384
396
|
end
|
|
385
397
|
end
|
|
386
398
|
|
|
387
399
|
describe "for :solr_local_parameters config" do
|
|
388
|
-
def blacklight_config
|
|
400
|
+
def blacklight_config
|
|
389
401
|
config = Blacklight::Configuration.new
|
|
390
402
|
config.add_search_field(
|
|
391
403
|
"custom_author_key",
|
|
@@ -404,45 +416,45 @@ describe 'Blacklight::SolrHelper' do
|
|
|
404
416
|
)
|
|
405
417
|
return config
|
|
406
418
|
end
|
|
407
|
-
|
|
408
|
-
def params
|
|
419
|
+
|
|
420
|
+
def params
|
|
409
421
|
{:search_field => "custom_author_key", :q => "query"}
|
|
410
422
|
end
|
|
411
|
-
|
|
423
|
+
|
|
412
424
|
before do
|
|
413
425
|
@result = solr_search_params
|
|
414
426
|
end
|
|
415
427
|
|
|
416
428
|
it "should pass through ordinary params" do
|
|
417
|
-
@result[:qt].
|
|
418
|
-
@result[:ps].
|
|
419
|
-
@result[:qf].
|
|
429
|
+
expect(@result[:qt]).to eq("author_qt")
|
|
430
|
+
expect(@result[:ps]).to eq("2")
|
|
431
|
+
expect(@result[:qf]).to eq("someField^1000")
|
|
420
432
|
end
|
|
421
433
|
|
|
422
434
|
it "should include include local params with escaping" do
|
|
423
|
-
@result[:q].
|
|
424
|
-
@result[:q].
|
|
425
|
-
@result[:q].
|
|
435
|
+
expect(@result[:q]).to include('qf=$author_qf')
|
|
436
|
+
expect(@result[:q]).to include('pf=\'you\\\'ll have \\" to escape this\'')
|
|
437
|
+
expect(@result[:q]).to include('pf2=$pf2_do_not_escape_or_quote')
|
|
426
438
|
end
|
|
427
439
|
end
|
|
428
|
-
|
|
440
|
+
|
|
429
441
|
describe "mapping facet.field" do
|
|
430
442
|
it "should add single additional facet.field from app" do
|
|
431
443
|
solr_params = solr_search_params( "facet.field" => "additional_facet" )
|
|
432
|
-
solr_params[:"facet.field"].
|
|
433
|
-
solr_params[:"facet.field"].length.
|
|
444
|
+
expect(solr_params[:"facet.field"]).to include("additional_facet")
|
|
445
|
+
expect(solr_params[:"facet.field"].length).to be > 1
|
|
434
446
|
end
|
|
435
447
|
it "should map multiple facet.field to additional facet.field" do
|
|
436
448
|
solr_params = solr_search_params( "facet.field" => ["add_facet1", "add_facet2"] )
|
|
437
|
-
solr_params[:"facet.field"].
|
|
438
|
-
solr_params[:"facet.field"].
|
|
439
|
-
solr_params[:"facet.field"].length.
|
|
449
|
+
expect(solr_params[:"facet.field"]).to include("add_facet1")
|
|
450
|
+
expect(solr_params[:"facet.field"]).to include("add_facet2")
|
|
451
|
+
expect(solr_params[:"facet.field"].length).to be > 2
|
|
440
452
|
end
|
|
441
453
|
it "should map facets[fields][] to additional facet.field" do
|
|
442
454
|
solr_params = solr_search_params( "facets" => ["add_facet1", "add_facet2"] )
|
|
443
|
-
solr_params[:"facet.field"].
|
|
444
|
-
solr_params[:"facet.field"].
|
|
445
|
-
solr_params[:"facet.field"].length.
|
|
455
|
+
expect(solr_params[:"facet.field"]).to include("add_facet1")
|
|
456
|
+
expect(solr_params[:"facet.field"]).to include("add_facet2")
|
|
457
|
+
expect(solr_params[:"facet.field"].length).to be > 2
|
|
446
458
|
end
|
|
447
459
|
end
|
|
448
460
|
|
|
@@ -464,21 +476,21 @@ describe 'Blacklight::SolrHelper' do
|
|
|
464
476
|
end
|
|
465
477
|
end
|
|
466
478
|
it 'sets rows to 0' do
|
|
467
|
-
@generated_solr_facet_params[:rows].
|
|
479
|
+
expect(@generated_solr_facet_params[:rows]).to eq(0)
|
|
468
480
|
end
|
|
469
481
|
it 'sets facets requested to facet_field argument' do
|
|
470
|
-
@generated_solr_facet_params["facet.field".to_sym].
|
|
482
|
+
expect(@generated_solr_facet_params["facet.field".to_sym]).to eq(@facet_field)
|
|
471
483
|
end
|
|
472
484
|
it 'defaults offset to 0' do
|
|
473
|
-
@generated_solr_facet_params[:"f.#{@facet_field}.facet.offset"].
|
|
485
|
+
expect(@generated_solr_facet_params[:"f.#{@facet_field}.facet.offset"]).to eq(0)
|
|
474
486
|
end
|
|
475
487
|
it 'uses offset manually set, and converts it to an integer' do
|
|
476
488
|
solr_params = solr_facet_params(@facet_field, @page_key => 2)
|
|
477
|
-
solr_params[:"f.#{@facet_field}.facet.offset"].
|
|
489
|
+
expect(solr_params[:"f.#{@facet_field}.facet.offset"]).to eq(20)
|
|
478
490
|
end
|
|
479
491
|
it 'defaults limit to 20' do
|
|
480
492
|
solr_params = solr_facet_params(@facet_field)
|
|
481
|
-
solr_params[:"f.#{@facet_field}.facet.limit"].
|
|
493
|
+
expect(solr_params[:"f.#{@facet_field}.facet.limit"]).to eq(21)
|
|
482
494
|
end
|
|
483
495
|
|
|
484
496
|
describe 'if facet_list_limit is defined in controller' do
|
|
@@ -487,29 +499,29 @@ describe 'Blacklight::SolrHelper' do
|
|
|
487
499
|
end
|
|
488
500
|
it 'uses controller method for limit' do
|
|
489
501
|
solr_params = solr_facet_params(@facet_field)
|
|
490
|
-
solr_params[:"f.#{@facet_field}.facet.limit"].
|
|
502
|
+
expect(solr_params[:"f.#{@facet_field}.facet.limit"]).to eq(1001)
|
|
491
503
|
end
|
|
492
504
|
|
|
493
505
|
it 'uses controller method for limit when a ordinary limit is set' do
|
|
494
506
|
solr_params = solr_facet_params(@facet_field)
|
|
495
|
-
solr_params[:"f.#{@facet_field}.facet.limit"].
|
|
507
|
+
expect(solr_params[:"f.#{@facet_field}.facet.limit"]).to eq(1001)
|
|
496
508
|
end
|
|
497
509
|
end
|
|
498
510
|
|
|
499
511
|
it 'uses the default sort' do
|
|
500
512
|
solr_params = solr_facet_params(@facet_field)
|
|
501
|
-
solr_params[:"f.#{@facet_field}.facet.sort"].
|
|
513
|
+
expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to be_blank
|
|
502
514
|
end
|
|
503
515
|
|
|
504
516
|
it "uses the field-specific sort" do
|
|
505
517
|
@facet_field = 'format_ordered'
|
|
506
518
|
solr_params = solr_facet_params(@facet_field)
|
|
507
|
-
solr_params[:"f.#{@facet_field}.facet.sort"].
|
|
519
|
+
expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to eq(:count)
|
|
508
520
|
end
|
|
509
521
|
|
|
510
522
|
it 'uses sort provided in the parameters' do
|
|
511
523
|
solr_params = solr_facet_params(@facet_field, @sort_key => "index")
|
|
512
|
-
solr_params[:"f.#{@facet_field}.facet.sort"].
|
|
524
|
+
expect(solr_params[:"f.#{@facet_field}.facet.sort"]).to eq('index')
|
|
513
525
|
end
|
|
514
526
|
it "comes up with the same params as #solr_search_params to constrain context for facet list" do
|
|
515
527
|
search_params = {:q => 'tibetan history', :f=> {:format=>'Book', :language_facet=>'Tibetan'}}
|
|
@@ -521,39 +533,39 @@ describe 'Blacklight::SolrHelper' do
|
|
|
521
533
|
# don't care about.
|
|
522
534
|
next if [:facets, "facet.field".to_sym, :rows, 'facet.limit', 'facet.offset', 'facet.sort'].include?(key)
|
|
523
535
|
# Everything else should match
|
|
524
|
-
solr_facet_params[key].
|
|
536
|
+
expect(solr_facet_params[key]).to eq(value)
|
|
525
537
|
end
|
|
526
538
|
|
|
527
539
|
end
|
|
528
540
|
end
|
|
529
|
-
describe "for facet limit parameters config ed" do
|
|
541
|
+
describe "for facet limit parameters config ed" do
|
|
530
542
|
def params
|
|
531
543
|
{:search_field => "test_field", :q => "test query"}
|
|
532
544
|
end
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
before do
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
before do
|
|
536
548
|
@generated_params = solr_search_params
|
|
537
549
|
end
|
|
538
|
-
|
|
550
|
+
|
|
539
551
|
it "should include specifically configged facet limits +1" do
|
|
540
|
-
@generated_params[:"f.subject_topic_facet.facet.limit"].
|
|
552
|
+
expect(@generated_params[:"f.subject_topic_facet.facet.limit"]).to eq(21)
|
|
541
553
|
end
|
|
542
554
|
it "should not include a facet limit for a nil key in hash" do
|
|
543
|
-
@generated_params.
|
|
544
|
-
@generated_params.
|
|
555
|
+
expect(@generated_params).not_to have_key(:"f.format.facet.limit")
|
|
556
|
+
expect(@generated_params).not_to have_key(:"facet.limit")
|
|
545
557
|
end
|
|
546
558
|
end
|
|
547
|
-
|
|
559
|
+
|
|
548
560
|
describe "get_facet_pagination", :integration => true do
|
|
549
561
|
before(:each) do
|
|
550
562
|
@facet_paginator = get_facet_pagination(@facet_field)
|
|
551
563
|
end
|
|
552
564
|
it 'should return a facet paginator' do
|
|
553
|
-
@facet_paginator.
|
|
565
|
+
expect(@facet_paginator).to be_a_kind_of(Blacklight::Solr::FacetPaginator)
|
|
554
566
|
end
|
|
555
567
|
it 'with a limit set' do
|
|
556
|
-
@facet_paginator.limit.
|
|
568
|
+
expect(@facet_paginator.limit).not_to be_nil
|
|
557
569
|
end
|
|
558
570
|
end
|
|
559
571
|
|
|
@@ -562,23 +574,23 @@ describe 'Blacklight::SolrHelper' do
|
|
|
562
574
|
|
|
563
575
|
describe 'for a sample query returning results' do
|
|
564
576
|
|
|
565
|
-
before(:all) do
|
|
577
|
+
before(:all) do
|
|
566
578
|
(@solr_response, @document_list) = get_search_results(:q => @all_docs_query)
|
|
567
579
|
end
|
|
568
580
|
|
|
569
581
|
it "should use the configured request handler " do
|
|
570
|
-
blacklight_config.
|
|
571
|
-
blacklight_solr.
|
|
572
|
-
path.
|
|
573
|
-
params[:params][:'facet.field'].
|
|
574
|
-
params[:params][:"facet.query"].
|
|
575
|
-
params[:params].
|
|
576
|
-
|
|
582
|
+
allow(blacklight_config).to receive(:default_solr_params).and_return({:qt => 'custom_request_handler'})
|
|
583
|
+
expect(blacklight_solr).to receive(:send_and_receive) { |path, params|
|
|
584
|
+
expect(path).to eq('select')
|
|
585
|
+
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"])
|
|
586
|
+
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 *]"])
|
|
587
|
+
expect(params[:params]).to include(:rows => 10, :qt=>"custom_request_handler", :q=>"", "spellcheck.q"=>"", :"f.subject_topic_facet.facet.limit"=>21, :sort=>"score desc, pub_date_sort desc, title_sort asc")
|
|
588
|
+
}.and_return({'response'=>{'docs'=>[]}})
|
|
577
589
|
get_search_results(:q => @all_docs_query)
|
|
578
590
|
end
|
|
579
591
|
|
|
580
592
|
it 'should have a @response.docs list of the same size as @document_list' do
|
|
581
|
-
@solr_response.docs.length.
|
|
593
|
+
expect(@solr_response.docs.length).to eq(@document_list.length)
|
|
582
594
|
end
|
|
583
595
|
|
|
584
596
|
it 'should have @response.docs list representing same documents as SolrDocuments in @document_list' do
|
|
@@ -586,10 +598,10 @@ describe 'Blacklight::SolrHelper' do
|
|
|
586
598
|
mash = @solr_response.docs[index]
|
|
587
599
|
solr_document = @document_list[index]
|
|
588
600
|
|
|
589
|
-
Set.new(mash.keys).
|
|
601
|
+
expect(Set.new(mash.keys)).to eq(Set.new(solr_document.keys))
|
|
590
602
|
|
|
591
603
|
mash.each_key do |key|
|
|
592
|
-
mash[key].
|
|
604
|
+
expect(mash[key]).to eq(solr_document[key])
|
|
593
605
|
end
|
|
594
606
|
end
|
|
595
607
|
end
|
|
@@ -632,7 +644,7 @@ describe 'Blacklight::SolrHelper' do
|
|
|
632
644
|
describe '#query_solr' do
|
|
633
645
|
it 'should have results' do
|
|
634
646
|
solr_response = query_solr(:q => @single_word_query)
|
|
635
|
-
solr_response.docs.size.
|
|
647
|
+
expect(solr_response.docs.size).to be > 0
|
|
636
648
|
end
|
|
637
649
|
|
|
638
650
|
end
|
|
@@ -642,24 +654,24 @@ describe 'Blacklight::SolrHelper' do
|
|
|
642
654
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query)
|
|
643
655
|
result_docs = document_list
|
|
644
656
|
document = result_docs.first
|
|
645
|
-
document.get(blacklight_config.index.show_link).
|
|
646
|
-
document.get(blacklight_config.index.record_display_type).
|
|
657
|
+
expect(document.get(blacklight_config.index.show_link)).not_to eq(nil)
|
|
658
|
+
expect(document.get(blacklight_config.index.record_display_type)).not_to eq(nil)
|
|
647
659
|
end
|
|
648
660
|
end
|
|
649
661
|
|
|
650
662
|
|
|
651
663
|
|
|
652
664
|
describe "Single Word Query with no Facets" do
|
|
653
|
-
|
|
665
|
+
|
|
654
666
|
it 'should have results' do
|
|
655
667
|
solr_response = query_solr(:q => @single_word_query)
|
|
656
|
-
solr_response.docs.size.
|
|
668
|
+
expect(solr_response.docs.size).to be > 0
|
|
657
669
|
end
|
|
658
670
|
|
|
659
671
|
it 'should have results' do
|
|
660
672
|
(solr_response, document_list) = get_search_results(:q => @single_word_query)
|
|
661
|
-
solr_response.docs.size.
|
|
662
|
-
solr_response.docs.size.
|
|
673
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
674
|
+
expect(solr_response.docs.size).to be > 0
|
|
663
675
|
end
|
|
664
676
|
end
|
|
665
677
|
|
|
@@ -667,48 +679,48 @@ describe 'Blacklight::SolrHelper' do
|
|
|
667
679
|
it 'should have results' do
|
|
668
680
|
|
|
669
681
|
(solr_response, document_list) = get_search_results(:q => @mult_word_query)
|
|
670
|
-
solr_response.docs.size.
|
|
671
|
-
solr_response.docs.size.
|
|
682
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
683
|
+
expect(solr_response.docs.size).to be > 0
|
|
672
684
|
end
|
|
673
685
|
end
|
|
674
686
|
|
|
675
687
|
describe "One Facet, No Query" do
|
|
676
688
|
it 'should have results' do
|
|
677
689
|
(solr_response, document_list) = get_search_results(:f => @single_facet)
|
|
678
|
-
solr_response.docs.size.
|
|
679
|
-
solr_response.docs.size.
|
|
690
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
691
|
+
expect(solr_response.docs.size).to be > 0
|
|
680
692
|
end
|
|
681
693
|
end
|
|
682
694
|
|
|
683
695
|
describe "Mult Facets, No Query" do
|
|
684
696
|
it 'should have results' do
|
|
685
697
|
(solr_response, document_list) = get_search_results(:f => @multi_facets)
|
|
686
|
-
solr_response.docs.size.
|
|
687
|
-
solr_response.docs.size.
|
|
698
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
699
|
+
expect(solr_response.docs.size).to be > 0
|
|
688
700
|
end
|
|
689
701
|
end
|
|
690
702
|
|
|
691
703
|
describe "Single Word Query with One Facet" do
|
|
692
704
|
it 'should have results' do
|
|
693
705
|
(solr_response, document_list) = get_search_results(:q => @single_word_query, :f => @single_facet)
|
|
694
|
-
solr_response.docs.size.
|
|
695
|
-
solr_response.docs.size.
|
|
706
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
707
|
+
expect(solr_response.docs.size).to be > 0
|
|
696
708
|
end
|
|
697
709
|
end
|
|
698
710
|
|
|
699
711
|
describe "Multiple Words Query with Multiple Facets" do
|
|
700
712
|
it 'should have results' do
|
|
701
713
|
(solr_response, document_list) = get_search_results(:q => @mult_word_query, :f => @multi_facets)
|
|
702
|
-
solr_response.docs.size.
|
|
703
|
-
solr_response.docs.size.
|
|
714
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
715
|
+
expect(solr_response.docs.size).to be > 0
|
|
704
716
|
end
|
|
705
717
|
end
|
|
706
718
|
|
|
707
719
|
describe "for All Docs Query and One Facet" do
|
|
708
720
|
it 'should have results' do
|
|
709
721
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query, :f => @single_facet)
|
|
710
|
-
solr_response.docs.size.
|
|
711
|
-
solr_response.docs.size.
|
|
722
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
723
|
+
expect(solr_response.docs.size).to be > 0
|
|
712
724
|
end
|
|
713
725
|
# TODO: check that number of these results < number of results for all docs query
|
|
714
726
|
# BUT can't: num docs isn't total, it's the num docs in the single SOLR response (e.g. 10)
|
|
@@ -717,24 +729,24 @@ describe 'Blacklight::SolrHelper' do
|
|
|
717
729
|
describe "for Query Without Results and No Facet" do
|
|
718
730
|
it 'should have no results and not raise error' do
|
|
719
731
|
(solr_response, document_list) = get_search_results(:q => @no_docs_query)
|
|
720
|
-
solr_response.docs.size.
|
|
721
|
-
solr_response.docs.size.
|
|
732
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
733
|
+
expect(solr_response.docs.size).to eq(0)
|
|
722
734
|
end
|
|
723
735
|
end
|
|
724
736
|
|
|
725
737
|
describe "for Query Without Results and One Facet" do
|
|
726
738
|
it 'should have no results and not raise error' do
|
|
727
739
|
(solr_response, document_list) = get_search_results(:q => @no_docs_query, :f => @single_facet)
|
|
728
|
-
solr_response.docs.size.
|
|
729
|
-
solr_response.docs.size.
|
|
740
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
741
|
+
expect(solr_response.docs.size).to eq(0)
|
|
730
742
|
end
|
|
731
743
|
end
|
|
732
744
|
|
|
733
745
|
describe "for All Docs Query and Bad Facet" do
|
|
734
746
|
it 'should have no results and not raise error' do
|
|
735
747
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query, :f => @bad_facet)
|
|
736
|
-
solr_response.docs.size.
|
|
737
|
-
solr_response.docs.size.
|
|
748
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
749
|
+
expect(solr_response.docs.size).to eq(0)
|
|
738
750
|
end
|
|
739
751
|
end
|
|
740
752
|
|
|
@@ -753,16 +765,16 @@ describe 'Blacklight::SolrHelper' do
|
|
|
753
765
|
end
|
|
754
766
|
|
|
755
767
|
it 'should have more than one facet' do
|
|
756
|
-
@facets.size.
|
|
768
|
+
expect(@facets.size).to be > 1
|
|
757
769
|
end
|
|
758
|
-
it 'should have all facets specified in initializer' do
|
|
770
|
+
it 'should have all facets specified in initializer' do
|
|
759
771
|
blacklight_config.facet_fields_to_add_to_solr.each do |field|
|
|
760
|
-
@facets.find {|f| f.name == field}.
|
|
772
|
+
expect(@facets.find {|f| f.name == field}).not_to be_nil
|
|
761
773
|
end
|
|
762
774
|
end
|
|
763
775
|
it 'should have at least one value for each facet' do
|
|
764
776
|
@facets.each do |facet|
|
|
765
|
-
facet.items.size.
|
|
777
|
+
expect(facet.items.size).to be > 0
|
|
766
778
|
end
|
|
767
779
|
end
|
|
768
780
|
it 'should have multiple values for at least one facet' do
|
|
@@ -773,7 +785,7 @@ describe 'Blacklight::SolrHelper' do
|
|
|
773
785
|
break
|
|
774
786
|
end
|
|
775
787
|
end
|
|
776
|
-
has_mult_values.
|
|
788
|
+
expect(has_mult_values).to eq(true)
|
|
777
789
|
end
|
|
778
790
|
it 'should have all value counts > 0' do
|
|
779
791
|
@facets.each do |facet|
|
|
@@ -790,58 +802,58 @@ describe 'Blacklight::SolrHelper' do
|
|
|
790
802
|
|
|
791
803
|
it 'should start with first results by default' do
|
|
792
804
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query)
|
|
793
|
-
solr_response.params[:start].to_i.
|
|
805
|
+
expect(solr_response.params[:start].to_i).to eq(0)
|
|
794
806
|
end
|
|
795
807
|
it 'should have number of results (per page) set in initializer, by default' do
|
|
796
808
|
(solr_response, document_list) = get_search_results(:q => @all_docs_query)
|
|
797
|
-
solr_response.docs.size.
|
|
798
|
-
solr_response.docs.size.
|
|
809
|
+
expect(solr_response.docs.size).to eq(document_list.size)
|
|
810
|
+
expect(solr_response.docs.size).to eq(blacklight_config[:default_solr_params][:rows])
|
|
799
811
|
end
|
|
800
812
|
|
|
801
813
|
it 'should get number of results per page requested' do
|
|
802
814
|
num_results = 3 # non-default value
|
|
803
815
|
(solr_response1, document_list1) = get_search_results(:q => @all_docs_query, :per_page => num_results)
|
|
804
|
-
solr_response1.docs.size.
|
|
805
|
-
solr_response1.docs.size.
|
|
816
|
+
expect(solr_response1.docs.size).to eq(document_list1.size)
|
|
817
|
+
expect(solr_response1.docs.size).to eq(num_results)
|
|
806
818
|
end
|
|
807
819
|
|
|
808
820
|
it 'should get number of rows requested' do
|
|
809
821
|
num_results = 4 # non-default value
|
|
810
822
|
(solr_response1, document_list1) = get_search_results(:q => @all_docs_query, :rows => num_results)
|
|
811
|
-
solr_response1.docs.size.
|
|
812
|
-
solr_response1.docs.size.
|
|
823
|
+
expect(solr_response1.docs.size).to eq(document_list1.size)
|
|
824
|
+
expect(solr_response1.docs.size).to eq(num_results)
|
|
813
825
|
end
|
|
814
826
|
|
|
815
827
|
it 'should skip appropriate number of results when requested - default per page' do
|
|
816
828
|
page = 3
|
|
817
829
|
(solr_response2, document_list2) = get_search_results(:q => @all_docs_query, :page => page)
|
|
818
|
-
solr_response2.params[:start].to_i.
|
|
830
|
+
expect(solr_response2.params[:start].to_i).to eq(blacklight_config[:default_solr_params][:rows] * (page-1))
|
|
819
831
|
end
|
|
820
832
|
it 'should skip appropriate number of results when requested - non-default per page' do
|
|
821
833
|
page = 3
|
|
822
834
|
num_results = 3
|
|
823
835
|
(solr_response2a, document_list2a) = get_search_results(:q => @all_docs_query, :per_page => num_results, :page => page)
|
|
824
|
-
solr_response2a.params[:start].to_i.
|
|
836
|
+
expect(solr_response2a.params[:start].to_i).to eq(num_results * (page-1))
|
|
825
837
|
end
|
|
826
838
|
|
|
827
839
|
it 'should have no results when prompted for page after last result' do
|
|
828
840
|
big = 5000
|
|
829
841
|
(solr_response3, document_list3) = get_search_results(:q => @all_docs_query, :rows => big, :page => big)
|
|
830
|
-
solr_response3.docs.size.
|
|
831
|
-
solr_response3.docs.size.
|
|
842
|
+
expect(solr_response3.docs.size).to eq(document_list3.size)
|
|
843
|
+
expect(solr_response3.docs.size).to eq(0)
|
|
832
844
|
end
|
|
833
845
|
|
|
834
846
|
it 'should show first results when prompted for page before first result' do
|
|
835
847
|
# FIXME: should it show first results, or should it throw an error for view to deal w?
|
|
836
848
|
# Solr throws an error for a negative start value
|
|
837
849
|
(solr_response4, document_list4) = get_search_results(:q => @all_docs_query, :page => '-1')
|
|
838
|
-
solr_response4.params[:start].to_i.
|
|
850
|
+
expect(solr_response4.params[:start].to_i).to eq(0)
|
|
839
851
|
end
|
|
840
852
|
it 'should have results available when asked for more than are in response' do
|
|
841
853
|
big = 5000
|
|
842
854
|
(solr_response5, document_list5) = get_search_results(:q => @all_docs_query, :rows => big, :page => 1)
|
|
843
|
-
solr_response5.docs.size.
|
|
844
|
-
solr_response5.docs.size.
|
|
855
|
+
expect(solr_response5.docs.size).to eq(document_list5.size)
|
|
856
|
+
expect(solr_response5.docs.size).to be > 0
|
|
845
857
|
end
|
|
846
858
|
|
|
847
859
|
end # page specs
|
|
@@ -855,42 +867,42 @@ describe 'Blacklight::SolrHelper' do
|
|
|
855
867
|
end
|
|
856
868
|
|
|
857
869
|
it "should raise Blacklight::InvalidSolrID for an unknown id" do
|
|
858
|
-
|
|
870
|
+
expect {
|
|
859
871
|
get_solr_response_for_doc_id(@bad_id)
|
|
860
|
-
}.
|
|
872
|
+
}.to raise_error(Blacklight::Exceptions::InvalidSolrID)
|
|
861
873
|
end
|
|
862
874
|
|
|
863
875
|
it "should use a provided document request handler " do
|
|
864
|
-
blacklight_config.
|
|
865
|
-
blacklight_solr.
|
|
866
|
-
|
|
876
|
+
allow(blacklight_config).to receive_messages(:document_solr_request_handler => 'document')
|
|
877
|
+
expect(blacklight_solr).to receive(:get).with('select', kind_of(Hash)).and_return({'response'=>{'docs'=>[]}})
|
|
878
|
+
expect { get_solr_response_for_doc_id(@doc_id)}.to raise_error Blacklight::Exceptions::InvalidSolrID
|
|
867
879
|
end
|
|
868
880
|
|
|
869
881
|
it "should have a non-nil result for a known id" do
|
|
870
|
-
@document.
|
|
882
|
+
expect(@document).not_to eq(nil)
|
|
871
883
|
end
|
|
872
884
|
it "should have a single document in the response for a known id" do
|
|
873
|
-
@response2.docs.size.
|
|
885
|
+
expect(@response2.docs.size).to eq(1)
|
|
874
886
|
end
|
|
875
887
|
it 'should have the expected value in the id field' do
|
|
876
|
-
@document.id.
|
|
888
|
+
expect(@document.id).to eq(@doc_id)
|
|
877
889
|
end
|
|
878
890
|
it 'should have non-nil values for required fields set in initializer' do
|
|
879
|
-
@document.get(blacklight_config[:show][:html_title]).
|
|
880
|
-
@document.get(blacklight_config[:show][:heading]).
|
|
881
|
-
@document.get(blacklight_config[:show][:display_type]).
|
|
891
|
+
expect(@document.get(blacklight_config[:show][:html_title])).not_to eq(nil)
|
|
892
|
+
expect(@document.get(blacklight_config[:show][:heading])).not_to eq(nil)
|
|
893
|
+
expect(@document.get(blacklight_config[:show][:display_type])).not_to eq(nil)
|
|
882
894
|
end
|
|
883
895
|
end
|
|
884
896
|
|
|
885
897
|
describe "solr_doc_params" do
|
|
886
898
|
it "should default to using the 'document' requestHandler" do
|
|
887
899
|
doc_params = solr_doc_params('asdfg')
|
|
888
|
-
doc_params[:qt].
|
|
900
|
+
expect(doc_params[:qt]).to eq('document')
|
|
889
901
|
end
|
|
890
902
|
|
|
891
903
|
|
|
892
904
|
describe "blacklight config's default_document_solr_parameters" do
|
|
893
|
-
def blacklight_config
|
|
905
|
+
def blacklight_config
|
|
894
906
|
config = Blacklight::Configuration.new
|
|
895
907
|
config.default_document_solr_params = { :qt => 'my_custom_handler', :asdf => '1234' }
|
|
896
908
|
config
|
|
@@ -898,15 +910,15 @@ describe 'Blacklight::SolrHelper' do
|
|
|
898
910
|
|
|
899
911
|
it "should use parameters from the controller's default_document_solr_parameters" do
|
|
900
912
|
doc_params = solr_doc_params('asdfg')
|
|
901
|
-
doc_params[:qt].
|
|
902
|
-
doc_params[:asdf].
|
|
913
|
+
expect(doc_params[:qt]).to eq('my_custom_handler')
|
|
914
|
+
expect(doc_params[:asdf]).to eq('1234')
|
|
903
915
|
end
|
|
904
916
|
end
|
|
905
917
|
|
|
906
918
|
end
|
|
907
919
|
|
|
908
920
|
describe "Get Document by custom unique id" do
|
|
909
|
-
=begin
|
|
921
|
+
=begin
|
|
910
922
|
# Can't test this properly without updating the "document" request handler in solr
|
|
911
923
|
it "should respect the configuration-supplied unique id" do
|
|
912
924
|
SolrDocument.should_receive(:unique_key).and_return("title_display")
|
|
@@ -917,7 +929,7 @@ describe 'Blacklight::SolrHelper' do
|
|
|
917
929
|
=end
|
|
918
930
|
it "should respect the configuration-supplied unique id" do
|
|
919
931
|
doc_params = solr_doc_params('"Strong Medicine speaks"')
|
|
920
|
-
doc_params[:id].
|
|
932
|
+
expect(doc_params[:id]).to eq('"Strong Medicine speaks"')
|
|
921
933
|
end
|
|
922
934
|
end
|
|
923
935
|
|
|
@@ -946,18 +958,18 @@ describe 'Blacklight::SolrHelper' do
|
|
|
946
958
|
=end
|
|
947
959
|
|
|
948
960
|
it 'should have a doc id field' do
|
|
949
|
-
@doc[:id].
|
|
961
|
+
expect(@doc[:id]).not_to eq(nil)
|
|
950
962
|
end
|
|
951
963
|
|
|
952
964
|
it 'should have non-nil values for required fields set in initializer' do
|
|
953
|
-
@doc[blacklight_config.show.html_title].
|
|
954
|
-
@doc[blacklight_config.show.heading].
|
|
955
|
-
@doc[blacklight_config.show.display_type].
|
|
965
|
+
expect(@doc[blacklight_config.show.html_title]).not_to eq(nil)
|
|
966
|
+
expect(@doc[blacklight_config.show.heading]).not_to eq(nil)
|
|
967
|
+
expect(@doc[blacklight_config.show.display_type]).not_to eq(nil)
|
|
956
968
|
end
|
|
957
969
|
|
|
958
970
|
it "should limit search result by facets when supplied" do
|
|
959
971
|
doc2 = get_single_doc_via_search(@doc_row , :q => @all_docs_query, :f => @multi_facets)
|
|
960
|
-
doc2[:id].
|
|
972
|
+
expect(doc2[:id]).not_to eq(nil)
|
|
961
973
|
end
|
|
962
974
|
|
|
963
975
|
end
|
|
@@ -966,15 +978,15 @@ describe 'Blacklight::SolrHelper' do
|
|
|
966
978
|
describe "Searches should return spelling suggestions", :integration => true do
|
|
967
979
|
it 'search results for just-poor-enough-query term should have (multiple) spelling suggestions' do
|
|
968
980
|
(solr_response, document_list) = get_search_results({:q => 'boo'})
|
|
969
|
-
solr_response.spelling.words.
|
|
970
|
-
solr_response.spelling.words.
|
|
981
|
+
expect(solr_response.spelling.words).to include('bon')
|
|
982
|
+
expect(solr_response.spelling.words).to include('bod') #for multiple suggestions
|
|
971
983
|
end
|
|
972
984
|
|
|
973
985
|
it 'search results for just-poor-enough-query term should have multiple spelling suggestions' do
|
|
974
986
|
(solr_response, document_list) = get_search_results({:q => 'politica'})
|
|
975
|
-
solr_response.spelling.words.
|
|
976
|
-
solr_response.spelling.words.
|
|
977
|
-
solr_response.spelling.words.
|
|
987
|
+
expect(solr_response.spelling.words).to include('policy') # less freq
|
|
988
|
+
expect(solr_response.spelling.words).to include('politics') # more freq
|
|
989
|
+
expect(solr_response.spelling.words).to include('political') # more freq
|
|
978
990
|
=begin
|
|
979
991
|
# when we can have multiple suggestions
|
|
980
992
|
solr_response.spelling.words.should_not include('policy') # less freq
|
|
@@ -985,39 +997,33 @@ describe 'Blacklight::SolrHelper' do
|
|
|
985
997
|
|
|
986
998
|
it "title search results for just-poor-enough query term should have spelling suggestions" do
|
|
987
999
|
(solr_response, document_list) = get_search_results({:q => 'yehudiyam', :qt => 'search', :"spellcheck.dictionary" => "title"})
|
|
988
|
-
solr_response.spelling.words.
|
|
1000
|
+
expect(solr_response.spelling.words).to include('yehudiyim')
|
|
989
1001
|
end
|
|
990
1002
|
|
|
991
1003
|
it "author search results for just-poor-enough-query term should have spelling suggestions" do
|
|
992
1004
|
(solr_response, document_list) = get_search_results({:q => 'shirma', :qt => 'search', :"spellcheck.dictionary" => "author"})
|
|
993
|
-
solr_response.spelling.words.
|
|
1005
|
+
expect(solr_response.spelling.words).to include('sharma')
|
|
994
1006
|
end
|
|
995
1007
|
|
|
996
1008
|
it "subject search results for just-poor-enough-query term should have spelling suggestions" do
|
|
997
1009
|
(solr_response, document_list) = get_search_results({:q => 'wome', :qt => 'search', :"spellcheck.dictionary" => "subject"})
|
|
998
|
-
solr_response.spelling.words.
|
|
1010
|
+
expect(solr_response.spelling.words).to include('women')
|
|
999
1011
|
end
|
|
1000
|
-
|
|
1001
|
-
it 'search results for multiple terms query with just-poor-enough-terms should have spelling suggestions for each term' do
|
|
1002
|
-
pending
|
|
1003
|
-
# get_spelling_suggestion("histo politica").should_not be_nil
|
|
1004
|
-
end
|
|
1005
|
-
|
|
1006
1012
|
end
|
|
1007
1013
|
|
|
1008
1014
|
describe "facet_limit_for" do
|
|
1009
1015
|
|
|
1010
1016
|
it "should return specified value for facet_field specified" do
|
|
1011
|
-
facet_limit_for("subject_topic_facet").
|
|
1017
|
+
expect(facet_limit_for("subject_topic_facet")).to eq(blacklight_config.facet_fields["subject_topic_facet"].limit)
|
|
1012
1018
|
end
|
|
1013
1019
|
it "should generate proper solr param" do
|
|
1014
|
-
solr_search_params[:"f.subject_topic_facet.facet.limit"].
|
|
1020
|
+
expect(solr_search_params[:"f.subject_topic_facet.facet.limit"]).to eq(21)
|
|
1015
1021
|
end
|
|
1016
|
-
|
|
1022
|
+
|
|
1017
1023
|
it "facet_limit_hash should return hash with key being facet_field and value being configured limit" do
|
|
1018
1024
|
# facet_limit_hash has been removed from solrhelper in refactor. should it go back?
|
|
1019
1025
|
pending "facet_limit_hash has been removed from solrhelper in refactor. should it go back?"
|
|
1020
|
-
facet_limit_hash.
|
|
1026
|
+
expect(facet_limit_hash).to eq(blacklight_config[:facet][:limits])
|
|
1021
1027
|
end
|
|
1022
1028
|
it "should handle no facet_limits in config" do
|
|
1023
1029
|
def blacklight_config
|
|
@@ -1025,61 +1031,61 @@ describe 'Blacklight::SolrHelper' do
|
|
|
1025
1031
|
config.facet_fields = {}
|
|
1026
1032
|
return config
|
|
1027
1033
|
end
|
|
1028
|
-
|
|
1029
|
-
facet_limit_for("subject_topic_facet").
|
|
1030
|
-
|
|
1031
|
-
solr_search_params.
|
|
1032
|
-
|
|
1034
|
+
|
|
1035
|
+
expect(facet_limit_for("subject_topic_facet")).to be_nil
|
|
1036
|
+
|
|
1037
|
+
expect(solr_search_params).not_to have_key(:"f.subject_topic_facet.facet.limit")
|
|
1038
|
+
|
|
1033
1039
|
end
|
|
1034
|
-
|
|
1040
|
+
|
|
1035
1041
|
describe "for 'true' configured values" do
|
|
1036
1042
|
it "should return nil if no @response available" do
|
|
1037
|
-
facet_limit_for("some_unknown_field").
|
|
1043
|
+
expect(facet_limit_for("some_unknown_field")).to be_nil
|
|
1038
1044
|
end
|
|
1039
|
-
it "should get from @response facet.limit if available" do
|
|
1045
|
+
it "should get from @response facet.limit if available" do
|
|
1040
1046
|
# Okay, this is cheesy, since we included SolrHelper directly
|
|
1041
1047
|
# into our example groups, we need to set an iVar here, so it will
|
|
1042
|
-
# use it.
|
|
1043
|
-
@response = {"responseHeader" => {"params" => {"facet.limit" => 11}}}
|
|
1044
|
-
facet_limit_for("language_facet").
|
|
1048
|
+
# use it.
|
|
1049
|
+
@response = {"responseHeader" => {"params" => {"facet.limit" => 11}}}
|
|
1050
|
+
expect(facet_limit_for("language_facet")).to eq(10)
|
|
1045
1051
|
end
|
|
1046
1052
|
it "should get from specific field in @response if available" do
|
|
1047
1053
|
@response = {"responseHeader" => {"params" => {"facet.limit" => 11,"f.language_facet.facet.limit" => 16}}}
|
|
1048
|
-
facet_limit_for("language_facet").
|
|
1054
|
+
expect(facet_limit_for("language_facet")).to eq(15)
|
|
1049
1055
|
end
|
|
1050
1056
|
end
|
|
1051
1057
|
end
|
|
1052
1058
|
|
|
1053
1059
|
describe "with max per page enforced" do
|
|
1054
|
-
def blacklight_config
|
|
1060
|
+
def blacklight_config
|
|
1055
1061
|
config = Blacklight::Configuration.new
|
|
1056
1062
|
config.max_per_page = 123
|
|
1057
1063
|
return config
|
|
1058
1064
|
end
|
|
1059
1065
|
|
|
1060
1066
|
it "should enforce max_per_page against all parameters" do
|
|
1061
|
-
blacklight_config.max_per_page.
|
|
1062
|
-
solr_search_params(:per_page => 98765)[:rows].
|
|
1063
|
-
end
|
|
1067
|
+
expect(blacklight_config.max_per_page).to eq(123)
|
|
1068
|
+
expect(solr_search_params(:per_page => 98765)[:rows]).to eq(123)
|
|
1069
|
+
end
|
|
1064
1070
|
end
|
|
1065
1071
|
|
|
1066
1072
|
describe "#get_solr_response_for_field_values" do
|
|
1067
1073
|
before do
|
|
1068
1074
|
@mock_response = double()
|
|
1069
|
-
@mock_response.
|
|
1075
|
+
allow(@mock_response).to receive_messages(:docs => [])
|
|
1070
1076
|
end
|
|
1071
1077
|
it "should contruct a solr query based on the field and value pair" do
|
|
1072
|
-
self.
|
|
1078
|
+
expect(self).to receive(:find).with(an_instance_of(String), hash_including(:q => "field_name:(value)")).and_return(@mock_response)
|
|
1073
1079
|
get_solr_response_for_field_values('field_name', 'value')
|
|
1074
1080
|
end
|
|
1075
1081
|
|
|
1076
1082
|
it "should OR multiple values together" do
|
|
1077
|
-
self.
|
|
1083
|
+
expect(self).to receive(:find).with(an_instance_of(String), hash_including(:q => "field_name:(a OR b)")).and_return(@mock_response)
|
|
1078
1084
|
get_solr_response_for_field_values('field_name', ['a', 'b'])
|
|
1079
1085
|
end
|
|
1080
1086
|
|
|
1081
1087
|
it "should escape crazy identifiers" do
|
|
1082
|
-
self.
|
|
1088
|
+
expect(self).to receive(:find).with(an_instance_of(String), hash_including(:q => "field_name:(\"h://\\\"\\\'\")")).and_return(@mock_response)
|
|
1083
1089
|
get_solr_response_for_field_values('field_name', 'h://"\'')
|
|
1084
1090
|
end
|
|
1085
1091
|
end
|
|
@@ -1092,7 +1098,7 @@ describe 'Blacklight::SolrHelper' do
|
|
|
1092
1098
|
# more like this
|
|
1093
1099
|
# nearby on shelf
|
|
1094
1100
|
it "should raise a Blacklight exception if RSolr can't connect to the Solr instance" do
|
|
1095
|
-
blacklight_solr.
|
|
1101
|
+
allow(blacklight_solr).to receive(:get).and_raise(Errno::ECONNREFUSED)
|
|
1096
1102
|
expect { find(:a => 123) }.to raise_exception(/Unable to connect to Solr instance/)
|
|
1097
1103
|
end
|
|
1098
1104
|
|
|
@@ -1104,7 +1110,7 @@ describe 'Blacklight::SolrHelper' do
|
|
|
1104
1110
|
it "should pull the grouped key out of the config" do
|
|
1105
1111
|
blacklight_config.index.group = 'xyz'
|
|
1106
1112
|
expect(self.grouped_key_for_results).to eq('xyz')
|
|
1107
|
-
end
|
|
1113
|
+
end
|
|
1108
1114
|
end
|
|
1109
1115
|
|
|
1110
1116
|
describe "#with_tag_ex" do
|
|
@@ -1158,11 +1164,11 @@ describe 'Blacklight::SolrHelper' do
|
|
|
1158
1164
|
|
|
1159
1165
|
it "defaults to get" do
|
|
1160
1166
|
expect(blacklight_config.http_method).to eq :get
|
|
1161
|
-
blacklight_solr.
|
|
1167
|
+
expect(blacklight_solr).to receive(:send_and_receive) { |path, params|
|
|
1162
1168
|
expect(path).to eq 'select'
|
|
1163
1169
|
expect(params[:method]).to eq :get
|
|
1164
1170
|
expect(params[:params]).to include(:q)
|
|
1165
|
-
|
|
1171
|
+
}.and_return({'response'=>{'docs'=>[]}})
|
|
1166
1172
|
get_search_results(:q => @all_docs_query)
|
|
1167
1173
|
end
|
|
1168
1174
|
end
|
|
@@ -1172,11 +1178,11 @@ describe 'Blacklight::SolrHelper' do
|
|
|
1172
1178
|
|
|
1173
1179
|
it "keep value set to post" do
|
|
1174
1180
|
expect(blacklight_config.http_method).to eq :post
|
|
1175
|
-
blacklight_solr.
|
|
1181
|
+
expect(blacklight_solr).to receive(:send_and_receive) { |path, params|
|
|
1176
1182
|
expect(path).to eq 'select'
|
|
1177
1183
|
expect(params[:method]).to eq :post
|
|
1178
1184
|
expect(params[:data]).to include(:q)
|
|
1179
|
-
|
|
1185
|
+
}.and_return({'response'=>{'docs'=>[]}})
|
|
1180
1186
|
get_search_results(:q => @all_docs_query)
|
|
1181
1187
|
end
|
|
1182
1188
|
|
|
@@ -1188,4 +1194,3 @@ describe 'Blacklight::SolrHelper' do
|
|
|
1188
1194
|
end
|
|
1189
1195
|
|
|
1190
1196
|
end
|
|
1191
|
-
|