blacklight 3.0pre1 → 3.0pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/.gitmodules +0 -6
  2. data/README.rdoc +94 -87
  3. data/blacklight.gemspec +1 -1
  4. data/config/routes.rb +1 -1
  5. data/lib/blacklight.rb +2 -2
  6. data/lib/blacklight/catalog.rb +10 -12
  7. data/lib/blacklight/controller.rb +2 -2
  8. data/lib/blacklight/engine.rb +5 -2
  9. data/lib/blacklight/solr/document.rb +1 -1
  10. data/lib/blacklight/solr/document/marc.rb +1 -16
  11. data/lib/blacklight/solr_helper.rb +43 -14
  12. data/lib/blacklight/version.rb +1 -1
  13. data/lib/generators/blacklight/assets_generator.rb +25 -0
  14. data/lib/generators/blacklight/blacklight_generator.rb +16 -1
  15. data/lib/generators/blacklight/jetty_generator.rb +101 -0
  16. data/lib/generators/blacklight/solr_conf_generator.rb +25 -0
  17. data/lib/generators/blacklight/templates/catalog_controller.rb +0 -1
  18. data/lib/generators/blacklight/templates/config/solr.yml +14 -2
  19. data/lib/generators/blacklight/templates/public/images/{blacklight/bg.png → bg.png} +0 -0
  20. data/lib/generators/blacklight/templates/public/images/{blacklight/border.png → border.png} +0 -0
  21. data/lib/generators/blacklight/templates/public/images/{blacklight/bul_sq_gry.gif → bul_sq_gry.gif} +0 -0
  22. data/lib/generators/blacklight/templates/public/images/{blacklight/checkmark.gif → checkmark.gif} +0 -0
  23. data/lib/generators/blacklight/templates/public/images/{blacklight/logo.png → logo.png} +0 -0
  24. data/lib/generators/blacklight/templates/public/images/{blacklight/magnifying_glass.gif → magnifying_glass.gif} +0 -0
  25. data/lib/generators/blacklight/templates/public/images/{blacklight/remove.gif → remove.gif} +0 -0
  26. data/lib/generators/blacklight/templates/public/images/{blacklight/separator.gif → separator.gif} +0 -0
  27. data/lib/generators/blacklight/templates/public/images/{blacklight/start_over.gif → start_over.gif} +0 -0
  28. data/lib/generators/blacklight/templates/public/javascripts/blacklight.js +5 -0
  29. data/lib/generators/blacklight/templates/public/stylesheets/blacklight.css +9 -3
  30. data/lib/generators/blacklight/templates/solr_conf/schema.xml +339 -0
  31. data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +578 -0
  32. data/lib/railties/all_tests.rake +11 -0
  33. data/lib/railties/blacklight.rake +0 -52
  34. data/lib/railties/blacklight_cucumber.rake +125 -0
  35. data/lib/railties/blacklight_rspec.rake +128 -0
  36. data/lib/railties/{test_solr_server.rb → jetty_solr_server.rb} +22 -45
  37. data/lib/railties/solr_marc.rake +24 -5
  38. data/test_support/.rspec +1 -0
  39. data/test_support/data/test_data.utf8.mrc +1 -0
  40. data/test_support/features/bookmarks.feature +88 -0
  41. data/test_support/features/did_you_mean.feature +129 -0
  42. data/test_support/features/folder.feature +67 -0
  43. data/test_support/features/librarian_view.feature +17 -0
  44. data/test_support/features/record_view.feature +34 -0
  45. data/test_support/features/saved_searches.feature +49 -0
  46. data/test_support/features/search.feature +86 -0
  47. data/test_support/features/search_filters.feature +121 -0
  48. data/test_support/features/search_history.feature +95 -0
  49. data/test_support/features/search_results.feature +61 -0
  50. data/test_support/features/search_sort.feature +29 -0
  51. data/test_support/features/step_definitions/bookmarks_steps.rb +5 -0
  52. data/test_support/features/step_definitions/error_steps.rb +4 -0
  53. data/test_support/features/step_definitions/folder_steps.rb +26 -0
  54. data/test_support/features/step_definitions/general_steps.rb +49 -0
  55. data/test_support/features/step_definitions/record_view_steps.rb +11 -0
  56. data/test_support/features/step_definitions/saved_searches_steps.rb +21 -0
  57. data/test_support/features/step_definitions/search_facets_steps.rb +28 -0
  58. data/test_support/features/step_definitions/search_history_steps.rb +8 -0
  59. data/test_support/features/step_definitions/search_result_steps.rb +113 -0
  60. data/test_support/features/step_definitions/search_steps.rb +102 -0
  61. data/test_support/features/step_definitions/user_steps.rb +4 -0
  62. data/test_support/features/step_definitions/web_steps.rb +211 -0
  63. data/test_support/features/support/env.rb +49 -0
  64. data/test_support/features/support/paths.rb +55 -0
  65. data/test_support/features/support/selectors.rb +39 -0
  66. data/test_support/features/unapi.feature +30 -0
  67. data/test_support/spec/controllers/application_controller_spec.rb +22 -0
  68. data/test_support/spec/controllers/catalog_controller_spec.rb +480 -0
  69. data/test_support/spec/controllers/folder_controller_spec.rb +40 -0
  70. data/test_support/spec/controllers/search_history_controller_spec.rb +45 -0
  71. data/test_support/spec/data/sample_docs.yml +655 -0
  72. data/test_support/spec/data/test_data.utf8.mrc +1 -0
  73. data/test_support/spec/helpers/blacklight_helper_spec.rb +482 -0
  74. data/test_support/spec/helpers/hash_as_hidden_fields_spec.rb +23 -0
  75. data/test_support/spec/helpers/render_constraints_helper_spec.rb +64 -0
  76. data/test_support/spec/helpers/search_history_helper_spec.rb +11 -0
  77. data/test_support/spec/helpers/solr_helper_spec.rb +873 -0
  78. data/test_support/spec/lib/blacklight_email_spec.rb +23 -0
  79. data/test_support/spec/lib/blacklight_sms_spec.rb +23 -0
  80. data/test_support/spec/lib/blacklight_solr_document_dublin_core_spec.rb +41 -0
  81. data/test_support/spec/lib/blacklight_solr_document_marc_spec.rb +88 -0
  82. data/test_support/spec/lib/blacklight_solr_document_spec.rb +173 -0
  83. data/test_support/spec/lib/blacklight_spec.rb +39 -0
  84. data/test_support/spec/lib/configurable_spec.rb +97 -0
  85. data/test_support/spec/lib/facet_paginator_spec.rb +93 -0
  86. data/test_support/spec/lib/marc_export_spec.rb +444 -0
  87. data/test_support/spec/lib/search_fields_spec.rb +105 -0
  88. data/test_support/spec/lib/tasks/blacklight_task_spec.rb +21 -0
  89. data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +59 -0
  90. data/test_support/spec/models/bookmark_spec.rb +37 -0
  91. data/test_support/spec/models/record_mailer_spec.rb +67 -0
  92. data/test_support/spec/models/search_spec.rb +55 -0
  93. data/test_support/spec/models/solr_docment_spec.rb +111 -0
  94. data/test_support/spec/rcov.opts +3 -0
  95. data/test_support/spec/spec.opts +4 -0
  96. data/test_support/spec/spec_helper.rb +38 -0
  97. data/test_support/spec/support/action_controller.rb +42 -0
  98. data/test_support/spec/support/assert_difference.rb +16 -0
  99. data/test_support/spec/support/include_text.rb +20 -0
  100. data/test_support/spec/views/catalog/_constraints_element.html.erb_spec.rb +59 -0
  101. data/test_support/spec/views/catalog/_document_list.html.erb_spec.rb +8 -0
  102. data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +182 -0
  103. data/test_support/spec/views/catalog/_index_partials/_default.erb_spec.rb +70 -0
  104. data/test_support/spec/views/catalog/_show_partials/_default.html.erb_spec.rb +70 -0
  105. data/test_support/spec/views/catalog/index.atom.builder_spec.rb +141 -0
  106. data/test_support/spec/views/catalog/show.html.erb_spec.rb +100 -0
  107. data/test_support/spec/views/catalog/unapi.xml.builder_spec.rb +45 -0
  108. metadata +95 -98
  109. data/lib/blacklight/marc.rb +0 -46
  110. data/lib/blacklight/marc/citation.rb +0 -251
  111. data/lib/railties/cucumber.rake +0 -53
  112. data/lib/railties/rspec.rake +0 -188
  113. data/spec/helpers/catalog_helper_spec.rb +0 -111
  114. data/spec/views/catalog/_sms_form.html.erb_spec.rb +0 -19
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe HashAsHiddenFields do
4
+ include HashAsHiddenFields
5
+ before(:each) do
6
+ @hash = {:q => "query", :search_field => "search_field", :per_page=>10, :page=>5, :extra_arbitrary_key=>"arbitrary_value", :f=> {:field1 => ["a", "b"], :field2=> ["z"]}}
7
+ end
8
+
9
+ it "should convert a hash with nested complex data to Rails-style hidden form fields" do
10
+
11
+ generated = hash_as_hidden_fields(@hash)
12
+
13
+ generated.should have_selector("input[type='hidden'][name='q'][value='query']")
14
+ generated.should have_selector("input[type='hidden'][name='per_page'][value='10']")
15
+ generated.should have_selector("input[type='hidden'][name='page'][value='5']")
16
+ generated.should have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']")
17
+ generated.should have_selector("input[type='hidden'][name='f[field2][]'][value='z']")
18
+ generated.should have_selector("input[type='hidden'][name='f[field1][]'][value='a']")
19
+ generated.should have_selector("input[type='hidden'][name='f[field1][]'][value='b']")
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ # This is NOT currently spec'ing render_constraints_* methods, becuase
4
+ # inflexibility in rspec makes it really hard to do so effectively. It would be
5
+ # nice, the specs that are there for render_search_to_s could be a model.
6
+ #
7
+ # We ARE spec'ing render_search_to_s* versions, which is feasible since they
8
+ # don't call any template partials.
9
+ describe RenderConstraintsHelper do
10
+
11
+ describe "render_search_to_s_*" do
12
+ describe "render_search_to_s_element" do
13
+ it "should render basic element" do
14
+ response = helper.render_search_to_s_element("key", "value")
15
+ response.should have_selector("span.constraint") do |span|
16
+ span.should have_selector("span.filterName", :content => "key:")
17
+ span.should have_selector("span.filterValue", :content => "value")
18
+ end
19
+ response.html_safe?.should == true
20
+ end
21
+ it "should escape them that need escaping" do
22
+ response = helper.render_search_to_s_element("key>", "value>")
23
+ response.should have_selector("span.constraint") do |span|
24
+ span.should have_selector("span.filterName") do |s2|
25
+ # Note: nokogiri's gettext will unescape the inner html
26
+ # which seems to be what rspecs "contains" method calls on
27
+ # text nodes - thus the to_s inserted below.
28
+ s2.to_s.should match(/key>:/)
29
+ end
30
+ span.should have_selector("span.filterValue") do |s3|
31
+ s3.to_s.should match(/value>/)
32
+ end
33
+ end
34
+ response.html_safe?.should == true
35
+ end
36
+ it "should not escape with options set thus" do
37
+ response = helper.render_search_to_s_element("key>", "value>", :escape_key => false, :escape_value => false)
38
+ response.should have_selector("span.constraint") do |span|
39
+ span.should have_selector("span.filterName", :content => "key>:")
40
+ span.should have_selector("span.filterValue", :content => "value>")
41
+ end
42
+ response.html_safe?.should == true
43
+ end
44
+ end
45
+
46
+ describe "render_search_to_s" do
47
+ before do
48
+ @params = {:q => "history", :f => {"some_facet" => ["value1", "value1"], "other_facet" => ["other1"]}}
49
+ end
50
+ it "should call lesser methods" do
51
+ # API hooks expect this to be so
52
+ response = helper.render_search_to_s(@params)
53
+
54
+ response.should include( helper.render_search_to_s_q(@params))
55
+ response.should include( helper.render_search_to_s_filters(@params))
56
+ response.html_safe?.should == true
57
+ end
58
+ end
59
+
60
+
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe SearchHistoryHelper do
4
+
5
+ #Delete this example and add some real ones or delete this file
6
+ it "should be included in the object returned by #helper" do
7
+ included_modules = (class << helper; self; end).send :included_modules
8
+ included_modules.should include(SearchHistoryHelper)
9
+ end
10
+
11
+ end
@@ -0,0 +1,873 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require 'marc'
3
+
4
+ # Because SolrHelper is a controller layer mixin,
5
+ # it depends on the methods provided by AtionController::Base
6
+ # currently, the only method that is used is #params
7
+ class MockSolrHelperContainer
8
+
9
+ include Blacklight::SolrHelper
10
+ attr_accessor :params
11
+ attr_accessor :response
12
+
13
+ # SolrHelper expects a method called #params,
14
+ # within the class that's mixing it in
15
+ def params
16
+ @params ||= {}
17
+ end
18
+
19
+ end
20
+
21
+
22
+ =begin
23
+ # check the methods that do solr requests. Note that we are not testing if
24
+ # solr gives "correct" responses, as that's out of scope (it's a part of
25
+ # testing the solr code itself). We *are* testing if blacklight code sends
26
+ # queries to solr such that it gets appropriate results. When a user does a search,
27
+ # do we get data back from solr (i.e. did we properly configure blacklight code
28
+ # to talk with solr and get results)? when we do a document request, does
29
+ # blacklight code get a single document returned?)
30
+ =end
31
+ describe 'Blacklight::SolrHelper' do
32
+
33
+ before(:all) do
34
+ @solr_helper = MockSolrHelperContainer.new
35
+ @solr_url = Blacklight.solr_config[:url]
36
+ end
37
+
38
+ before(:each) do
39
+ @all_docs_query = ''
40
+ @no_docs_query = 'zzzzzzzzzzzz'
41
+ @single_word_query = 'include'
42
+ @mult_word_query = 'tibetan history'
43
+ # f[format][]=Book&f[language_facet][]=English
44
+ @single_facet = {:format=>'Book'}
45
+ @multi_facets = {:format=>'Book', :language_facet=>'Tibetan'}
46
+ @bad_facet = {:format=>'666'}
47
+ @subject_search_params = {:commit=>"search", :search_field=>"subject", :action=>"index", :"controller"=>"catalog", :"per_page"=>"10", :"q"=>"wome"}
48
+ end
49
+
50
+ # SPECS FOR blacklight.rb contents
51
+ describe "blacklight.rb" do
52
+ describe "solr.yml and/or initializers" do
53
+
54
+ it "should contain a solr_url" do
55
+ Blacklight.solr_config[:url].should_not == nil
56
+ end
57
+
58
+ it "should contain some display fields" do
59
+ Blacklight.config[:show].should_not == nil
60
+ end
61
+
62
+ end
63
+ end
64
+
65
+ # SPECS for actual search parameter generation
66
+ describe "solr_search_params" do
67
+ it "allows customization of solr_search_params_logic" do
68
+ # Normally you'd include a new module into (eg) your CatalogController
69
+ # but a sub-class defininig it directly is simpler for test.
70
+ class CustomizableHelper < MockSolrHelperContainer
71
+ def add_foo_to_solr_params(solr_params, user_params)
72
+ solr_params[:foo] = "TESTING"
73
+ end
74
+ end
75
+
76
+ CustomizableHelper.solr_search_params_logic << :add_foo_to_solr_params
77
+
78
+
79
+ obj = CustomizableHelper.new
80
+ params = obj.solr_search_params
81
+
82
+ params[:foo].should == "TESTING"
83
+ end
84
+
85
+
86
+ describe 'for an entirely empty search' do
87
+ before do
88
+ @produced_params = @solr_helper.solr_search_params
89
+ end
90
+ it 'should not have a q param' do
91
+ @produced_params[:q].should be_nil
92
+ @produced_params["spellcheck.q"].should be_nil
93
+ end
94
+ it 'should have default per_page' do
95
+ @produced_params[:per_page].should == 10
96
+ end
97
+ it 'should have default facet fields' do
98
+ @produced_params[:"facet.field"].should == Blacklight.config[:default_solr_params][:"facet.field"]
99
+ end
100
+ it 'should not use the exact facet array from config defaults' do
101
+ @produced_params[:"facet.field"].should_not be_equal(Blacklight.config[:facet][:field_names])
102
+ end
103
+ it "should have default qt" do
104
+ @produced_params[:qt].should == "search"
105
+ end
106
+ it "should have no fq" do
107
+ @produced_params[:phrase_filters].should be_blank
108
+ @produced_params[:fq].should be_blank
109
+ end
110
+ end
111
+
112
+
113
+ describe "for an empty string search" do
114
+ it "should return empty string q in solr parameters" do
115
+ params = @solr_helper.solr_search_params(:q => "")
116
+ params[:q].should == ""
117
+ params["spellcheck.q"].should == ""
118
+ end
119
+ end
120
+
121
+ describe "for request params also passed in as argument" do
122
+ before do
123
+ @req_params = HashWithIndifferentAccess.new({:q => "some query"})
124
+ params = @req_params
125
+ end
126
+ it "should only have one 'q' key, as symbol" do
127
+ solr_params = @solr_helper.solr_search_params( @req_params )
128
+ solr_params.keys.should include(:q)
129
+ solr_params.keys.should_not include("q")
130
+ end
131
+ end
132
+
133
+
134
+ describe "for one facet, no query" do
135
+ it "should have proper solr parameters" do
136
+
137
+ params = @solr_helper.solr_search_params(:f => @single_facet)
138
+
139
+ params[:q].should be_blank
140
+ params["spellcheck.q"].should be_blank
141
+ params[:"facet.field"].should == Blacklight.config[:default_solr_params][:"facet.field"]
142
+
143
+ @single_facet.each_value do |value|
144
+ params[:fq].should include("{!raw f=#{@single_facet.keys[0]}}#{value}")
145
+ end
146
+ end
147
+ end
148
+
149
+ describe "with Multi Facets, No Query" do
150
+ it 'should have fq set properly' do
151
+ params = @solr_helper.solr_search_params(:f => @multi_facets)
152
+
153
+ @multi_facets.each_pair do |facet_field, value_list|
154
+ value_list.each do |value|
155
+ params[:fq].should include("{!raw f=#{facet_field}}#{value}" )
156
+ end
157
+ end
158
+
159
+ end
160
+ end
161
+
162
+ describe "with Multi Facets, Multi Word Query" do
163
+ it 'should have fq and q set properly' do
164
+ params = @solr_helper.solr_search_params(:q => @mult_word_query, :f => @multi_facets)
165
+
166
+ @multi_facets.each_pair do |facet_field, value_list|
167
+ value_list.each do |value|
168
+ params[:fq].should include("{!raw f=#{facet_field}}#{value}" )
169
+ end
170
+ end
171
+ params[:q].should == @mult_word_query
172
+ end
173
+ end
174
+
175
+ describe "solr parameters for a field search from config (subject)" do
176
+ before do
177
+ @solr_params = @solr_helper.solr_search_params( @subject_search_params )
178
+ end
179
+ it "should look up qt from field definition" do
180
+ @solr_params[:qt].should == "search"
181
+ end
182
+ it "should not include weird keys not in field definition" do
183
+ @solr_params[:phrase_filters].should be_nil
184
+ @solr_params[:fq].should be_nil
185
+ @solr_params[:commit].should be_nil
186
+ @solr_params[:action].should be_nil
187
+ @solr_params[:controller].should be_nil
188
+ end
189
+ it "should include proper 'q', possibly with LocalParams" do
190
+ @solr_params[:q].should match(/(\{[^}]+\})?wome/)
191
+ end
192
+ it "should include proper 'q' when LocalParams are used" do
193
+ if @solr_params[:q] =~ /\{[^}]+\}/
194
+ @solr_params[:q].should match(/\{[^}]+\}wome/)
195
+ end
196
+ end
197
+ it "should include spellcheck.q, without LocalParams" do
198
+ @solr_params["spellcheck.q"].should == "wome"
199
+ end
200
+ it "should include facet.field from default_solr_params" do
201
+ @solr_params[:"facet.field"].should == Blacklight.config[:default_solr_params][:"facet.field"]
202
+ end
203
+ it "should include spellcheck.dictionary from field def solr_parameters" do
204
+ @solr_params[:"spellcheck.dictionary"].should == "subject"
205
+ end
206
+ it "should add on :solr_local_parameters using Solr LocalParams style" do
207
+ params = @solr_helper.solr_search_params( @subject_search_params )
208
+
209
+ #q == "{!pf=$subject_pf $qf=subject_qf} wome", make sure
210
+ #the LocalParams are really there
211
+ params[:q] =~ /^\{!([^}]+)\}/
212
+ key_value_pairs = $1.split(" ")
213
+ key_value_pairs.should include("pf=$subject_pf")
214
+ key_value_pairs.should include("qf=$subject_qf")
215
+ end
216
+ end
217
+
218
+ describe "overriding of qt parameter" do
219
+ it "should return the correct overriden parameter" do
220
+ @solr_helper.params[:qt] = "overriden"
221
+ @solr_helper.solr_search_params[:qt].should == "overriden"
222
+ @solr_helper.params[:qt] = nil
223
+ end
224
+ end
225
+
226
+ describe "with a complex parameter environment" do
227
+ before do
228
+ # Add a custom search field def in so we can test it
229
+ Blacklight.config[:search_fields] << {:display_label => "Test", :key=>"test_field", :solr_parameters => {:qf => "fieldOne^2.3 fieldTwo fieldThree^0.4", :pf => "", :spellcheck => 'false', :per_page => "55", :sort => "request_params_sort"}}
230
+ #re-memoize
231
+ Blacklight.search_field_list(:reload)
232
+
233
+ # Add some params
234
+ @solr_helper_with_params = MockSolrHelperContainer.new
235
+ @solr_helper_with_params.params = {:search_field => "test_field", :q => "test query", "facet.field" => "extra_facet"}
236
+ end
237
+ after do
238
+ # restore search field list to how it was.
239
+ Blacklight.config[:search_fields].delete_if {|hash| hash[:key] == "test_field"}
240
+ #re-memoize
241
+ Blacklight.search_field_list(:reload)
242
+ end
243
+
244
+ it "should merge parameters from search_field definition" do
245
+ params = @solr_helper_with_params.solr_search_params
246
+
247
+ params[:qf].should == "fieldOne^2.3 fieldTwo fieldThree^0.4"
248
+ params[:spellcheck].should == 'false'
249
+ end
250
+ it "should merge empty string parameters from search_field definition" do
251
+ params = @solr_helper_with_params.solr_search_params
252
+ params[:pf].should == ""
253
+ end
254
+
255
+ describe "should respect proper precedence of settings, " do
256
+ before do
257
+ @produced_params = @solr_helper_with_params.solr_search_params().merge(:sort => "extra_params_sort")
258
+ 1+1
259
+ end
260
+
261
+
262
+ it "should not put :search_field in produced params" do
263
+ @produced_params[:search_field].should be_nil
264
+ end
265
+
266
+ it "should fall through to BL general defaults for qt not otherwise specified " do
267
+ @produced_params[:qt].should == Blacklight.config[:default_solr_params][:qt]
268
+ end
269
+
270
+ it "should take per_page from search field definition where specified" do
271
+ @produced_params[:per_page].should == "55"
272
+ end
273
+
274
+ it "should take q from request params" do
275
+ @produced_params[:q].should == "test query"
276
+ end
277
+
278
+ it "should add in extra facet.field from params" do
279
+ @produced_params[:"facet.field"].should include("extra_facet")
280
+ end
281
+
282
+ it "should Overwrite request params sort with extra_params sort" do
283
+ @produced_params[:sort].should == "extra_params_sort"
284
+ end
285
+
286
+ end
287
+ end
288
+
289
+ describe "for :solr_local_parameters config" do
290
+ before do
291
+ # Hack to test with our own custom config specified here
292
+ @orig_blacklight = Blacklight
293
+ Object.instance_eval{ remove_const :Blacklight }
294
+ Blacklight = @orig_blacklight.clone
295
+ Blacklight.unmemoize_all
296
+ Blacklight.instance_variable_set("@config", {}.deep_merge(@orig_blacklight.config))
297
+
298
+ Blacklight.config[:search_fields] = [
299
+ { :display_label => "Author",
300
+ :qt => "author_qt",
301
+ :key => "author_key",
302
+ :solr_local_parameters => {
303
+ :qf => "$author_qf",
304
+ :pf => "you'll have \" to escape this"
305
+ },
306
+ :solr_parameters => {
307
+ :qf => "someField^1000",
308
+ :ps => "2"
309
+ }
310
+ }
311
+ ]
312
+
313
+ @solr_helper = MockSolrHelperContainer.new
314
+ @solr_helper.params = {:search_field => "author_key", :q => "query"}
315
+ @result = @solr_helper.solr_search_params
316
+ end
317
+
318
+ it "should pass through ordinary params" do
319
+ @result[:qt].should == "author_qt"
320
+ @result[:ps].should == "2"
321
+ @result[:qf].should == "someField^1000"
322
+ end
323
+
324
+ it "should include include local params with escaping" do
325
+ @result[:q].should include('qf=$author_qf')
326
+ @result[:q].should include('pf=\'you\\\'ll have \\" to escape this\'')
327
+ end
328
+
329
+ after do
330
+ Object.instance_eval{ remove_const :Blacklight }
331
+ Blacklight = @orig_blacklight
332
+ end
333
+ end
334
+
335
+ describe "mapping facet.field" do
336
+ it "should add single additional facet.field from app" do
337
+ solr_params = @solr_helper.solr_search_params( "facet.field" => "additional_facet" )
338
+ solr_params[:"facet.field"].should include("additional_facet")
339
+ solr_params[:"facet.field"].length.should > 1
340
+ end
341
+ it "should map multiple facet.field to additional facet.field" do
342
+ solr_params = @solr_helper.solr_search_params( "facet.field" => ["add_facet1", "add_facet2"] )
343
+ solr_params[:"facet.field"].should include("add_facet1")
344
+ solr_params[:"facet.field"].should include("add_facet2")
345
+ solr_params[:"facet.field"].length.should > 2
346
+ end
347
+ it "should map facets[fields][] to additional facet.field" do
348
+ solr_params = @solr_helper.solr_search_params( "facets" => ["add_facet1", "add_facet2"] )
349
+ solr_params[:"facet.field"].should include("add_facet1")
350
+ solr_params[:"facet.field"].should include("add_facet2")
351
+ solr_params[:"facet.field"].length.should > 2
352
+ end
353
+ end
354
+
355
+ end
356
+
357
+ describe "solr_facet_params" do
358
+ before do
359
+ @facet_field = 'format'
360
+ @generated_solr_facet_params = @solr_helper.solr_facet_params(@facet_field)
361
+
362
+ @sort_key = Blacklight::Solr::FacetPaginator.request_keys[:sort]
363
+ @offset_key = Blacklight::Solr::FacetPaginator.request_keys[:offset]
364
+ end
365
+ it 'sets rows to 0' do
366
+ @generated_solr_facet_params[:rows].should == 0
367
+ end
368
+ it 'sets facets requested to facet_field argument' do
369
+ @generated_solr_facet_params["facet.field".to_sym].should == @facet_field
370
+ end
371
+ it 'defaults offset to 0' do
372
+ @generated_solr_facet_params['facet.offset'].should == 0
373
+ end
374
+ it 'uses offset manually set, and converts it to an integer' do
375
+ solr_params = @solr_helper.solr_facet_params(@facet_field, @offset_key => "100")
376
+ solr_params['facet.offset'].should == 100
377
+ end
378
+ it 'defaults limit to 20' do
379
+ solr_params = @solr_helper.solr_facet_params(@facet_field)
380
+ solr_params[:"f.#{@facet_field}.facet.limit"].should == 21
381
+ end
382
+ describe 'if facet_list_limit is defined in controller' do
383
+ before(:each) do
384
+ @solr_helper.stub!("facet_list_limit").and_return("1000")
385
+ end
386
+ it 'uses controller method for limit' do
387
+ solr_params = @solr_helper.solr_facet_params(@facet_field)
388
+ solr_params[:"f.#{@facet_field}.facet.limit"].should == 1001
389
+ end
390
+ end
391
+ it 'uses sort set manually' do
392
+ solr_params = @solr_helper.solr_facet_params(@facet_field, @sort_key => "index")
393
+ solr_params['facet.sort'].should == 'index'
394
+ end
395
+ it "comes up with the same params as #solr_search_params to constrain context for facet list" do
396
+ search_params = {:q => 'tibetan history', :f=> {:format=>'Book', :language_facet=>'Tibetan'}}
397
+ solr_search_params = @solr_helper.solr_search_params( search_params )
398
+ solr_facet_params = @solr_helper.solr_facet_params('format', search_params)
399
+
400
+ solr_search_params.each_pair do |key, value|
401
+ # The specific params used for fetching the facet list we
402
+ # don't care about.
403
+ next if [:facets, "facet.field".to_sym, :rows, 'facet.limit', 'facet.offset', 'facet.sort'].include?(key)
404
+ # Everything else should match
405
+ solr_facet_params[key].should == value
406
+ end
407
+
408
+ end
409
+ end
410
+ describe "for facet limit parameters config ed" do
411
+ before(:each) do
412
+ @solr_helper_facet = MockSolrHelperContainer.new
413
+ @solr_helper_facet.params = {:search_field => "test_field", :q => "test query"}
414
+ @solr_helper_facet.stub!("facet_limit_hash").and_return({:some_facet => nil, :subject_facet => 10})
415
+ @generated_params = @solr_helper_facet.solr_search_params
416
+ end
417
+
418
+ it "should include specifically configged facet limits +1" do
419
+ @generated_params[:"f.subject_facet.facet.limit"].should == 11
420
+ end
421
+ it "should not include a facet limit for a nil key in hash" do
422
+ @generated_params.should_not have_key(:"f.some_facet.facet.limit")
423
+ @generated_params.should_not have_key(:"facet.limit")
424
+ end
425
+ end
426
+ describe "get_facet_pagination" do
427
+ before(:each) do
428
+ @facet_paginator = @solr_helper.get_facet_pagination(@facet_field)
429
+ end
430
+ it 'should return a facet paginator' do
431
+ @facet_paginator.should be_a_kind_of(Blacklight::Solr::FacetPaginator)
432
+ end
433
+ it 'with a limit set' do
434
+ @facet_paginator.limit.should_not be_nil
435
+ end
436
+ end
437
+
438
+ # SPECS FOR SEARCH RESULTS FOR QUERY
439
+ describe 'Search Results' do
440
+
441
+ describe 'for a sample query returning results' do
442
+
443
+ before(:all) do
444
+ (@solr_response, @document_list) = @solr_helper.get_search_results(:q => @all_docs_query)
445
+ end
446
+
447
+ it 'should have a @response.docs list of the same size as @document_list' do
448
+ @solr_response.docs.length.should == @document_list.length
449
+ end
450
+
451
+ it 'should have @response.docs list representing same documents as SolrDocuments in @document_list' do
452
+ @solr_response.docs.each_index do |index|
453
+ mash = @solr_response.docs[index]
454
+ solr_document = @document_list[index]
455
+
456
+ Set.new(mash.keys).should == Set.new(solr_document.keys)
457
+
458
+ mash.each_key do |key|
459
+ mash[key].should == solr_document[key]
460
+ end
461
+ end
462
+ end
463
+ end
464
+
465
+ describe 'for All Docs Query, No Facets' do
466
+ it 'should have non-nil values for required doc fields set in initializer' do
467
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @all_docs_query)
468
+ result_docs = document_list
469
+ document = result_docs.first
470
+ document.get(Blacklight.config[:index][:show_link]).should_not == nil
471
+ document.get(Blacklight.config[:index][:record_display_type]).should_not == nil
472
+ end
473
+ end
474
+
475
+
476
+
477
+ describe "Single Word Query with no Facets" do
478
+ it 'should have results' do
479
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @single_word_query)
480
+ solr_response.docs.size.should == document_list.size
481
+ solr_response.docs.size.should > 0
482
+ end
483
+ end
484
+
485
+ describe "Multiple Words Query with No Facets" do
486
+ it 'should have results' do
487
+
488
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @mult_word_query)
489
+ solr_response.docs.size.should == document_list.size
490
+ solr_response.docs.size.should > 0
491
+ end
492
+ end
493
+
494
+ describe "One Facet, No Query" do
495
+ it 'should have results' do
496
+ (solr_response, document_list) = @solr_helper.get_search_results(:f => @single_facet)
497
+ solr_response.docs.size.should == document_list.size
498
+ solr_response.docs.size.should > 0
499
+ end
500
+ end
501
+
502
+ describe "Mult Facets, No Query" do
503
+ it 'should have results' do
504
+ (solr_response, document_list) = @solr_helper.get_search_results(:f => @multi_facets)
505
+ solr_response.docs.size.should == document_list.size
506
+ solr_response.docs.size.should > 0
507
+ end
508
+ end
509
+
510
+ describe "Single Word Query with One Facet" do
511
+ it 'should have results' do
512
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @single_word_query, :f => @single_facet)
513
+ solr_response.docs.size.should == document_list.size
514
+ solr_response.docs.size.should > 0
515
+ end
516
+ end
517
+
518
+ describe "Multiple Words Query with Multiple Facets" do
519
+ it 'should have results' do
520
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @mult_word_query, :f => @multi_facets)
521
+ solr_response.docs.size.should == document_list.size
522
+ solr_response.docs.size.should > 0
523
+ end
524
+ end
525
+
526
+ describe "for All Docs Query and One Facet" do
527
+ it 'should have results' do
528
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @all_docs_query, :f => @single_facet)
529
+ solr_response.docs.size.should == document_list.size
530
+ solr_response.docs.size.should > 0
531
+ end
532
+ # TODO: check that number of these results < number of results for all docs query
533
+ # BUT can't: num docs isn't total, it's the num docs in the single SOLR response (e.g. 10)
534
+ end
535
+
536
+ describe "for Query Without Results and No Facet" do
537
+ it 'should have no results and not raise error' do
538
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @no_docs_query)
539
+ solr_response.docs.size.should == document_list.size
540
+ solr_response.docs.size.should == 0
541
+ end
542
+ end
543
+
544
+ describe "for Query Without Results and One Facet" do
545
+ it 'should have no results and not raise error' do
546
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @no_docs_query, :f => @single_facet)
547
+ solr_response.docs.size.should == document_list.size
548
+ solr_response.docs.size.should == 0
549
+ end
550
+ end
551
+
552
+ describe "for All Docs Query and Bad Facet" do
553
+ it 'should have no results and not raise error' do
554
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @all_docs_query, :f => @bad_facet)
555
+ solr_response.docs.size.should == document_list.size
556
+ solr_response.docs.size.should == 0
557
+ end
558
+ end
559
+
560
+ describe "for default display fields" do
561
+ it "should have a list of field names for index_view_fields" do
562
+ Blacklight.config[:index_fields].should_not be_nil
563
+ Blacklight.config[:index_fields][:field_names].should be_instance_of(Array)
564
+ Blacklight.config[:index_fields][:field_names].length.should > 0
565
+ Blacklight.config[:index_fields][:field_names][0].should_not == nil
566
+ end
567
+ end
568
+
569
+
570
+ end # Search Results
571
+
572
+
573
+ # SPECS FOR SEARCH RESULTS FOR FACETS
574
+ describe 'Facets in Search Results for All Docs Query' do
575
+
576
+ before(:all) do
577
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @all_docs_query)
578
+ @facets = solr_response.facets
579
+ end
580
+
581
+ it 'should have more than one facet' do
582
+ @facets.size.should > 1
583
+ end
584
+ it 'should have all facets specified in initializer' do
585
+ Blacklight.config[:default_solr_params][:"facet.field"].each do |field|
586
+ @facets.find {|f| f.name == field}.should_not be_nil
587
+ end
588
+ end
589
+ it 'should have at least one value for each facet' do
590
+ @facets.each do |facet|
591
+ facet.items.size.should > 0
592
+ end
593
+ end
594
+ it 'should have multiple values for at least one facet' do
595
+ has_mult_values = false
596
+ @facets.each do |facet|
597
+ if facet.items.size > 1
598
+ has_mult_values = true
599
+ break
600
+ end
601
+ end
602
+ has_mult_values.should == true
603
+ end
604
+ it 'should have all value counts > 0' do
605
+ @facets.each do |facet|
606
+ facet.items.each do |facet_vals|
607
+ facet_vals.hits > 0
608
+ end
609
+ end
610
+ end
611
+ end # facet specs
612
+
613
+
614
+ # SPECS FOR SEARCH RESULTS FOR PAGING
615
+ describe 'Paging' do
616
+
617
+ it 'should start with first results by default' do
618
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @all_docs_query)
619
+ solr_response.params[:start].to_i.should == 0
620
+ end
621
+ it 'should have number of results (per page) set in initializer, by default' do
622
+ (solr_response, document_list) = @solr_helper.get_search_results(:q => @all_docs_query)
623
+ solr_response.docs.size.should == document_list.size
624
+ solr_response.docs.size.should == Blacklight.config[:default_solr_params][:per_page]
625
+ end
626
+
627
+ it 'should get number of results per page requested' do
628
+ num_results = 3 # non-default value
629
+ (solr_response1, document_list1) = @solr_helper.get_search_results(:q => @all_docs_query, :per_page => num_results)
630
+ solr_response1.docs.size.should == document_list1.size
631
+ solr_response1.docs.size.should == num_results
632
+ end
633
+
634
+ it 'should skip appropriate number of results when requested - default per page' do
635
+ page = 3
636
+ (solr_response2, document_list2) = @solr_helper.get_search_results(:q => @all_docs_query, :page => page)
637
+ solr_response2.params[:start].to_i.should == Blacklight.config[:default_solr_params][:per_page] * (page-1)
638
+ end
639
+ it 'should skip appropriate number of results when requested - non-default per page' do
640
+ page = 3
641
+ num_results = 3
642
+ (solr_response2a, document_list2a) = @solr_helper.get_search_results(:q => @all_docs_query, :per_page => num_results, :page => page)
643
+ solr_response2a.params[:start].to_i.should == num_results * (page-1)
644
+ end
645
+
646
+ it 'should have no results when prompted for page after last result' do
647
+ big = 5000
648
+ (solr_response3, document_list3) = @solr_helper.get_search_results(:q => @all_docs_query, :per_page => big, :page => big)
649
+ solr_response3.docs.size.should == document_list3.size
650
+ solr_response3.docs.size.should == 0
651
+ end
652
+
653
+ it 'should show first results when prompted for page before first result' do
654
+ # FIXME: should it show first results, or should it throw an error for view to deal w?
655
+ # Solr throws an error for a negative start value
656
+ (solr_response4, document_list4) = @solr_helper.get_search_results(:q => @all_docs_query, :page => '-1')
657
+ solr_response4.params[:start].to_i.should == 0
658
+ end
659
+ it 'should have results available when asked for more than are in response' do
660
+ big = 5000
661
+ (solr_response5, document_list5) = @solr_helper.get_search_results(:q => @all_docs_query, :per_page => big, :page => 1)
662
+ solr_response5.docs.size.should == document_list5.size
663
+ solr_response5.docs.size.should > 0
664
+ end
665
+
666
+ end # page specs
667
+
668
+ # SPECS FOR SINGLE DOCUMENT REQUESTS
669
+ describe 'Get Document By Id' do
670
+ before(:all) do
671
+ @doc_id = '2007020969'
672
+ @bad_id = "redrum"
673
+ @response2, @document = @solr_helper.get_solr_response_for_doc_id(@doc_id)
674
+ end
675
+
676
+ it "should raise Blacklight::InvalidSolrID for an unknown id" do
677
+ lambda {
678
+ @solr_helper.get_solr_response_for_doc_id(@bad_id)
679
+ }.should raise_error(Blacklight::Exceptions::InvalidSolrID)
680
+ end
681
+
682
+ it "should have a non-nil result for a known id" do
683
+ @document.should_not == nil
684
+ end
685
+ it "should have a single document in the response for a known id" do
686
+ @response2.docs.size.should == 1
687
+ end
688
+ it 'should have the expected value in the id field' do
689
+ @document.get(:id).should == @doc_id
690
+ end
691
+ it 'should have non-nil values for required fields set in initializer' do
692
+ @document.get(Blacklight.config[:show][:html_title]).should_not == nil
693
+ @document.get(Blacklight.config[:show][:heading]).should_not == nil
694
+ @document.get(Blacklight.config[:show][:display_type]).should_not == nil
695
+ end
696
+ it "should have a list of field names for show_view_fields" do
697
+ Blacklight.config[:show_fields].should_not be_nil
698
+ Blacklight.config[:show_fields][:field_names].should be_instance_of(Array)
699
+ Blacklight.config[:show_fields][:field_names].length.should > 0
700
+ Blacklight.config[:show_fields][:field_names][0].should_not == nil
701
+ end
702
+
703
+
704
+
705
+ end
706
+
707
+ # NOTE: some of these repeated fields could be in a shared behavior, but the
708
+ # flow of control is such that the variables can't be instance variables
709
+ # (or at least not for me - Naomi)
710
+
711
+ # SPECS FOR SINGLE DOCUMENT VIA SEARCH
712
+ describe "Get Document Via Search" do
713
+ before(:all) do
714
+ @doc_row = 3
715
+ @doc = @solr_helper.get_single_doc_via_search(@doc_row, :q => @all_docs_query)
716
+ end
717
+ =begin
718
+ # can't test these here, because the method only returns the document
719
+ it "should get a single document" do
720
+ response.docs.size.should == 1
721
+ end
722
+
723
+ doc2 = get_single_doc_via_search(@all_docs_query, nil, @doc_row, @multi_facets)
724
+ it "should limit search result by facets when supplied" do
725
+ response2.docs.numFound.should_be < response.docs.numFound
726
+ end
727
+
728
+ it "should not have facets in the response" do
729
+ response.facets.size.should == 0
730
+ end
731
+ =end
732
+
733
+ it 'should have a doc id field' do
734
+ @doc.get(:id).should_not == nil
735
+ end
736
+
737
+ it 'should have non-nil values for required fields set in initializer' do
738
+ @doc.get(Blacklight.config[:show][:html_title]).should_not == nil
739
+ @doc.get(Blacklight.config[:show][:heading]).should_not == nil
740
+ @doc.get(Blacklight.config[:show][:display_type]).should_not == nil
741
+ end
742
+
743
+ it "should limit search result by facets when supplied" do
744
+ doc2 = @solr_helper.get_single_doc_via_search(@doc_row , :q => @all_docs_query, :f => @multi_facets)
745
+ doc2.get(:id).should_not == nil
746
+ end
747
+
748
+ end
749
+
750
+ # SPECS FOR SPELLING SUGGESTIONS VIA SEARCH
751
+ describe "Searches should return spelling suggestions" do
752
+ it 'search results for just-poor-enough-query term should have (multiple) spelling suggestions' do
753
+ (solr_response, document_list) = @solr_helper.get_search_results({:q => 'boo'})
754
+ solr_response.spelling.words.should include('bon')
755
+ solr_response.spelling.words.should include('bod') #for multiple suggestions
756
+ end
757
+
758
+ it 'search results for just-poor-enough-query term should have multiple spelling suggestions' do
759
+ (solr_response, document_list) = @solr_helper.get_search_results({:q => 'politica'})
760
+ solr_response.spelling.words.should include('policy') # less freq
761
+ solr_response.spelling.words.should include('politics') # more freq
762
+ solr_response.spelling.words.should include('political') # more freq
763
+ =begin
764
+ # when we can have multiple suggestions
765
+ solr_response.spelling.words.should_not include('policy') # less freq
766
+ solr_response.spelling.words.should include('politics') # more freq
767
+ solr_response.spelling.words.should include('political') # more freq
768
+ =end
769
+ end
770
+
771
+ it "title search results for just-poor-enough query term should have spelling suggestions" do
772
+ (solr_response, document_list) = @solr_helper.get_search_results({:q => 'yehudiyam', :qt => 'search', :"spellcheck.dictionary" => "title"})
773
+ solr_response.spelling.words.should include('yehudiyim')
774
+ end
775
+
776
+ it "author search results for just-poor-enough-query term should have spelling suggestions" do
777
+ (solr_response, document_list) = @solr_helper.get_search_results({:q => 'shirma', :qt => 'search', :"spellcheck.dictionary" => "author"})
778
+ solr_response.spelling.words.should include('sharma')
779
+ end
780
+
781
+ it "subject search results for just-poor-enough-query term should have spelling suggestions" do
782
+ (solr_response, document_list) = @solr_helper.get_search_results({:q => 'wome', :qt => 'search', :"spellcheck.dictionary" => "subject"})
783
+ solr_response.spelling.words.should include('women')
784
+ end
785
+
786
+ it 'search results for multiple terms query with just-poor-enough-terms should have spelling suggestions for each term' do
787
+ pending
788
+ # get_spelling_suggestion("histo politica").should_not be_nil
789
+ end
790
+
791
+ end
792
+
793
+ describe "facet_limit_for" do
794
+
795
+ it "should return specified value for facet_field specified" do
796
+ @solr_helper.facet_limit_for("subject_topic_facet").should == Blacklight.config[:facet][:limits]["subject_topic_facet"]
797
+ end
798
+ it "@solr_helper.facet_limit_hash should return hash with key being facet_field and value being configured limit" do
799
+ @solr_helper.facet_limit_hash.should == Blacklight.config[:facet][:limits]
800
+ end
801
+ it "should handle no facet_limits in config" do
802
+ Blacklight.config[:facet][:field_names].include?("subject_topic_facet").should be_true
803
+ Blacklight.config[:facet][:limits].has_key?("subject_topic_facet").should be_true
804
+ @solr_helper.facet_limit_for("subject_topic_facet").should == 20
805
+ fl = Blacklight.config[:facet][:limits]
806
+ Blacklight.config[:facet][:limits] = nil
807
+ @solr_helper.facet_limit_for("subject_topic_facet").should be_nil
808
+ Blacklight.config[:facet][:limits] = fl
809
+ end
810
+ it "solr_search_params should handle no facet_limits in config" do
811
+ Blacklight.config[:facet][:field_names].include?("subject_topic_facet").should be_true
812
+ Blacklight.config[:facet][:limits].has_key?("subject_topic_facet").should be_true
813
+ @solr_helper.solr_search_params[:"f.subject_topic_facet.facet.limit"].should == 21
814
+ fl = Blacklight.config[:facet][:limits]
815
+ Blacklight.config[:facet][:limits] = nil
816
+ @solr_helper.solr_search_params.has_key?(:"f.subject_topic_facet.facet.limit").should be_false
817
+ Blacklight.config[:facet][:limits] = fl
818
+ end
819
+ describe "for 'true' configured values" do
820
+ it "should return nil if no @response available" do
821
+ @solr_helper.facet_limit_for("some_field").should be_nil
822
+ end
823
+ it "should get from @response facet.limit if available" do
824
+ @solr_helper.response = {"responseHeader" => {"params" => {"facet.limit" => 11}}}
825
+ @solr_helper.facet_limit_for("language_facet").should == 10
826
+ end
827
+ it "should get from specific field in @response if available" do
828
+ @solr_helper.response = {"responseHeader" => {"params" => {"facet.limit" => 11,"f.language_facet.facet.limit" => 16}}}
829
+ @solr_helper.facet_limit_for("language_facet").should == 15
830
+ end
831
+ end
832
+ end
833
+
834
+ describe "with max per page enforced" do
835
+ before do
836
+ # Add some params
837
+ @solr_helper_with_params = MockSolrHelperContainer.new
838
+ @solr_helper_with_params.params = {:search_field => "test_field", :per_page => 12345, :q => "test query", "facet.field" => "extra_facet"}
839
+ end
840
+ after do
841
+ end
842
+
843
+ describe "should enforce MaxPerPage against user supplied parameters" do
844
+ before do
845
+ @produced_params = @solr_helper_with_params.solr_search_params
846
+ 1+1
847
+ end
848
+ it "should take per_page from search field definition where specified" do
849
+ @produced_params[:per_page].should == "100"
850
+ end
851
+ end
852
+
853
+ describe "should enforce MaxPerPage against extra controller parameters" do
854
+ before do
855
+ @produced_params = @solr_helper_with_params.solr_search_params(:per_page => 98765)
856
+ 1+1
857
+ end
858
+ it "should take per_page from search field definition where specified" do
859
+ @produced_params[:per_page].should == "100"
860
+ end
861
+ end
862
+ end
863
+
864
+ # TODO: more complex queries! phrases, offset into search results, non-latin, boosting(?)
865
+ # search within query building (?)
866
+ # search + facets (search done first; facet selected first, both selected)
867
+
868
+ # TODO: maybe eventually check other types of solr requests
869
+ # more like this
870
+ # nearby on shelf
871
+
872
+ end
873
+