active-fedora 9.8.0 → 9.9.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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/History.txt +29 -0
  4. data/README.md +1 -1
  5. data/active-fedora.gemspec +2 -2
  6. data/config/fedora.yml +2 -2
  7. data/config/solr.yml +3 -3
  8. data/lib/active_fedora/associations/builder/belongs_to.rb +2 -5
  9. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +2 -5
  10. data/lib/active_fedora/config.rb +1 -1
  11. data/lib/active_fedora/fedora.rb +7 -1
  12. data/lib/active_fedora/file.rb +46 -32
  13. data/lib/active_fedora/file_configurator.rb +2 -1
  14. data/lib/active_fedora/rake_support.rb +33 -0
  15. data/lib/active_fedora/relation/finder_methods.rb +2 -1
  16. data/lib/active_fedora/solr_service.rb +6 -2
  17. data/lib/active_fedora/version.rb +1 -1
  18. data/lib/active_fedora.rb +1 -1
  19. data/lib/generators/active_fedora/config/fedora/templates/fedora.yml +2 -2
  20. data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -1
  21. data/lib/generators/active_fedora/config/solr/templates/solr/config/_rest_managed.json +3 -0
  22. data/lib/generators/active_fedora/config/solr/templates/solr/config/admin-extra.html +31 -0
  23. data/lib/generators/active_fedora/config/solr/templates/{solr_conf/solr.xml → solr/config/elevate.xml} +36 -35
  24. data/lib/generators/active_fedora/config/solr/templates/solr/config/mapping-ISOLatin1Accent.txt +246 -0
  25. data/lib/generators/active_fedora/config/solr/templates/solr/config/protwords.txt +21 -0
  26. data/lib/generators/active_fedora/config/solr/templates/{solr_conf/conf → solr/config}/schema.xml +217 -123
  27. data/lib/generators/active_fedora/config/solr/templates/solr/config/scripts.conf +24 -0
  28. data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +297 -0
  29. data/lib/generators/active_fedora/config/solr/templates/solr/config/spellings.txt +2 -0
  30. data/lib/generators/active_fedora/config/solr/templates/solr/config/stopwords.txt +58 -0
  31. data/lib/generators/active_fedora/config/solr/templates/solr/config/stopwords_en.txt +58 -0
  32. data/lib/generators/active_fedora/config/solr/templates/solr/config/synonyms.txt +31 -0
  33. data/lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example.xsl +132 -0
  34. data/lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example_atom.xsl +67 -0
  35. data/lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example_rss.xsl +66 -0
  36. data/lib/generators/active_fedora/config/solr/templates/solr/config/xslt/luke.xsl +337 -0
  37. data/lib/generators/active_fedora/config/solr/templates/solr.yml +2 -2
  38. data/lib/tasks/active_fedora_dev.rake +12 -13
  39. data/solr/config/solrconfig.xml +60 -182
  40. data/spec/fixtures/rails_root/config/fedora.yml +8 -0
  41. data/spec/integration/date_time_properties_spec.rb +15 -4
  42. data/spec/unit/config_spec.rb +8 -3
  43. data/spec/unit/fedora_spec.rb +20 -0
  44. data/spec/unit/file_configurator_spec.rb +9 -0
  45. data/spec/unit/file_spec.rb +105 -0
  46. data/spec/unit/finder_methods_spec.rb +34 -0
  47. data/spec/unit/solr_service_spec.rb +25 -0
  48. metadata +24 -10
  49. data/config/jetty.yml +0 -6
  50. data/lib/generators/active_fedora/config/solr/templates/solr_conf/conf/solrconfig.xml +0 -218
@@ -32,6 +32,8 @@
32
32
 
33
33
  <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib" />
34
34
  <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" />
35
+ <lib dir="${solr.install.dir:../../../..}/contrib/extraction/lib" regex=".*\.jar" />
36
+ <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-cell-\d.*\.jar" />
35
37
 
36
38
  <directoryFactory name="DirectoryFactory"
37
39
  class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}">
@@ -45,7 +47,7 @@
45
47
  <dataDir>${solr.blacklight-core.data.dir:}</dataDir>
46
48
 
47
49
  <requestDispatcher handleSelect="true" >
48
- <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />
50
+ <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048000" />
49
51
  </requestDispatcher>
50
52
 
51
53
  <requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
@@ -69,162 +71,55 @@
69
71
  will be overridden by parameters in the request
70
72
  -->
71
73
  <lst name="defaults">
72
- <str name="defType">dismax</str>
74
+ <str name="defType">edismax</str>
73
75
  <str name="echoParams">explicit</str>
74
- <int name="rows">10</int>
75
-
76
76
  <str name="q.alt">*:*</str>
77
77
  <str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
78
-
78
+ <int name="qs">1</int>
79
+ <int name="ps">2</int>
80
+ <float name="tie">0.01</float>
79
81
  <!-- this qf and pf are used by default, if not otherwise specified by
80
82
  client. The default blacklight_config will use these for the
81
- "keywords" search. See the author_qf/author_pf, title_qf, etc
83
+ "keywords" search. See the author_qf/author_pf, title_qf, etc
82
84
  below, which the default blacklight_config will specify for
83
85
  those searches. You may also be interested in:
84
86
  http://wiki.apache.org/solr/LocalParams
85
87
  -->
88
+ <str name="qf">
89
+ id
90
+ active_fedora_model_ssi
91
+ title_tesim
92
+ author_tesim
93
+ subject_tesim
94
+ </str>
95
+ <str name="pf">
96
+ all_text_timv^10
97
+ </str>
86
98
 
87
- <str name="qf">
88
- title_unstem_search^100000
89
- subtitle_unstem_search^50000
90
- title_t^25000
91
- subtitle_t^10000
92
- title_addl_unstem_search^5000
93
- title_addl_t^2500
94
- title_added_entry_unstem_search^1500
95
- title_added_entry_t^1250
96
- subject_topic_unstem_search^1000
97
- subject_unstem_search^750
98
- subject_topic_facet^625
99
- subject_t^500
100
- author_unstem_search^250
101
- author_addl_unstem_search^250
102
- author_t^100
103
- author_addl_t^50
104
- subject_addl_unstem_search^250
105
- subject_addl_t^50
106
- title_series_unstem_search^25
107
- title_series_t^10
108
- isbn_t
109
- text
110
- </str>
111
- <str name="pf">
112
- title_unstem_search^1000000
113
- subtitle_unstem_search^500000
114
- title_t^250000
115
- subtitle_t^100000
116
- title_addl_unstem_search^50000
117
- title_addl_t^25000
118
- title_added_entry_unstem_search^15000
119
- title_added_entry_t^12500
120
- subject_topic_unstem_search^10000
121
- subject_unstem_search^7500
122
- subject_topic_facet^6250
123
- subject_t^5000
124
- author_unstem_search^2500
125
- author_addl_unstem_search^2500
126
- author_t^1000
127
- author_addl_t^500
128
- subject_addl_unstem_search^2500
129
- subject_addl_t^500
130
- title_series_unstem_search^250
131
- title_series_t^100
132
- text^10
133
- </str>
134
99
  <str name="author_qf">
135
- author_unstem_search^200
136
- author_addl_unstem_search^50
137
- author_t^20
138
- author_addl_t
100
+ author_tesim
139
101
  </str>
140
102
  <str name="author_pf">
141
- author_unstem_search^2000
142
- author_addl_unstem_search^500
143
- author_t^200
144
- author_addl_t^10
145
103
  </str>
146
104
  <str name="title_qf">
147
- title_unstem_search^50000
148
- subtitle_unstem_search^25000
149
- title_addl_unstem_search^10000
150
- title_t^5000
151
- subtitle_t^2500
152
- title_addl_t^100
153
- title_added_entry_unstem_search^50
154
- title_added_entry_t^10
155
- title_series_unstem_search^5
156
- title_series_t
105
+ title_tesim
157
106
  </str>
158
107
  <str name="title_pf">
159
- title_unstem_search^500000
160
- subtitle_unstem_search^250000
161
- title_addl_unstem_search^100000
162
- title_t^50000
163
- subtitle_t^25000
164
- title_addl_t^1000
165
- title_added_entry_unstem_search^500
166
- title_added_entry_t^100
167
- title_series_t^50
168
- title_series_unstem_search^10
169
108
  </str>
170
109
  <str name="subject_qf">
171
- subject_topic_unstem_search^200
172
- subject_unstem_search^125
173
- subject_topic_facet^100
174
- subject_t^50
175
- subject_addl_unstem_search^10
176
- subject_addl_t
110
+ subject_tesim
177
111
  </str>
178
112
  <str name="subject_pf">
179
- subject_topic_unstem_search^2000
180
- subject_unstem_search^1250
181
- subject_t^1000
182
- subject_topic_facet^500
183
- subject_addl_unstem_search^100
184
- subject_addl_t^10
185
113
  </str>
186
-
187
- <int name="ps">3</int>
188
- <float name="tie">0.01</float>
189
114
 
190
- <!-- NOT using marc_display because it is large and will slow things down for search results -->
191
115
  <str name="fl">
192
- id,
193
- score,
194
- author_display,
195
- author_vern_display,
196
- format,
197
- isbn_t,
198
- language_facet,
199
- lc_callnum_display,
200
- material_type_display,
201
- published_display,
202
- published_vern_display,
203
- pub_date,
204
- title_display,
205
- title_vern_display,
206
- subject_topic_facet,
207
- subject_geo_facet,
208
- subject_era_facet,
209
- subtitle_display,
210
- subtitle_vern_display,
211
- url_fulltext_display,
212
- url_suppl_display,
116
+ *,
117
+ score
213
118
  </str>
214
119
 
215
120
  <str name="facet">true</str>
216
121
  <str name="facet.mincount">1</str>
217
- <str name="facet.limit">10</str>
218
- <str name="facet.field">format</str>
219
- <str name="facet.field">lc_1letter_facet</str>
220
- <str name="facet.field">lc_alpha_facet</str>
221
- <str name="facet.field">lc_b4cutter_facet</str>
222
- <str name="facet.field">language_facet</str>
223
- <str name="facet.field">pub_date</str>
224
- <str name="facet.field">subject_era_facet</str>
225
- <str name="facet.field">subject_geo_facet</str>
226
- <str name="facet.field">subject_topic_facet</str>
227
-
122
+
228
123
  <str name="spellcheck">true</str>
229
124
  <str name="spellcheck.dictionary">default</str>
230
125
  <str name="spellcheck.onlyMorePopular">true</str>
@@ -233,62 +128,32 @@
233
128
  <str name="spellcheck.count">5</str>
234
129
 
235
130
  </lst>
236
- <!-- In addition to defaults, "appends" params can be specified
237
- to identify values which should be appended to the list of
238
- multi-val params from the query (or the existing "defaults").
239
- -->
240
- <!-- In this example, the param "fq=instock:true" would be appended to
241
- any query time fq params the user may specify, as a mechanism for
242
- partitioning the index, independent of any user selected filtering
243
- that may also be desired (perhaps as a result of faceted searching).
244
-
245
- NOTE: there is *absolutely* nothing a client can do to prevent these
246
- "appends" values from being used, so don't use this mechanism
247
- unless you are sure you always want it.
248
- -->
249
- <!--
250
- <lst name="appends">
251
- <str name="fq">inStock:true</str>
252
- </lst>
253
- -->
254
- <!-- "invariants" are a way of letting the Solr maintainer lock down
255
- the options available to Solr clients. Any params values
256
- specified here are used regardless of what values may be specified
257
- in either the query, the "defaults", or the "appends" params.
258
-
259
- In this example, the facet.field and facet.query params would
260
- be fixed, limiting the facets clients can use. Faceting is
261
- not turned on by default - but if the client does specify
262
- facet=true in the request, these are the only facets they
263
- will be able to see counts for; regardless of what other
264
- facet.field or facet.query params they may specify.
265
-
266
- NOTE: there is *absolutely* nothing a client can do to prevent these
267
- "invariants" values from being used, so don't use this mechanism
268
- unless you are sure you always want it.
269
- -->
270
- <!--
271
- <lst name="invariants">
272
- <str name="facet.field">cat</str>
273
- <str name="facet.field">manu_exact</str>
274
- <str name="facet.query">price:[* TO 500]</str>
275
- <str name="facet.query">price:[500 TO *]</str>
276
- </lst>
277
- -->
278
- <!-- If the default list of SearchComponents is not desired, that
279
- list can either be overridden completely, or components can be
280
- prepended or appended to the default list. (see below)
281
- -->
282
- <!--
283
- <arr name="components">
284
- <str>nameOfCustomComponent1</str>
285
- <str>nameOfCustomComponent2</str>
286
- </arr>
287
- -->
288
131
  <arr name="last-components">
289
132
  <str>spellcheck</str>
290
133
  </arr>
291
-
134
+ </requestHandler>
135
+
136
+ <requestHandler name="permissions" class="solr.SearchHandler" >
137
+ <lst name="defaults">
138
+ <str name="facet">off</str>
139
+ <str name="echoParams">all</str>
140
+ <str name="rows">1</str>
141
+ <str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
142
+ <str name="fl">
143
+ id,
144
+ access_ssim,
145
+ discover_access_group_ssim,discover_access_person_ssim,
146
+ read_access_group_ssim,read_access_person_ssim,
147
+ edit_access_group_ssim,edit_access_person_ssim,
148
+ depositor_ti,
149
+ embargo_release_date_dtsi
150
+ inheritable_access_ssim,
151
+ inheritable_discover_access_group_ssim,inheritable_discover_access_person_ssim,
152
+ inheritable_read_access_group_ssim,inheritable_read_access_person_ssim,
153
+ inheritable_edit_access_group_ssim,inheritable_edit_access_person_ssim,
154
+ inheritable_embargo_release_date_dtsi
155
+ </str>
156
+ </lst>
292
157
  </requestHandler>
293
158
 
294
159
  <requestHandler name="standard" class="solr.SearchHandler">
@@ -415,5 +280,18 @@
415
280
  </arr>
416
281
  </requestHandler>
417
282
 
283
+ <requestHandler name="/update/extract" class="org.apache.solr.handler.extraction.ExtractingRequestHandler">
284
+ <lst name="defaults">
285
+ <str name="fmap.Last-Modified">last_modified</str>
286
+ <str name="uprefix">ignored_</str>
287
+ </lst>
288
+ <!--Optional. Specify a path to a tika configuration file. See the Tika docs for details.-->
289
+ <!-- <str name="tika.config">/my/path/to/tika.config</str> -->
290
+ <!-- Optional. Specify one or more date formats to parse. See DateUtil.DEFAULT_DATE_FORMATS
291
+ for default date formats -->
292
+ <!-- <lst name="date.formats"> -->
293
+ <!-- <str>yyyy&#45;MM&#45;dd</str> -->
294
+ <!-- </lst> -->
295
+ </requestHandler>
418
296
  </config>
419
297
 
@@ -2,3 +2,11 @@ test:
2
2
  user: fedoraAdmin
3
3
  password: fedoraAdmin
4
4
  url: http://testhost.com:8983/fedora
5
+ test_ssl:
6
+ user: fedoraAdmin
7
+ password: fedoraAdmin
8
+ url: https://testhost.com:8443/fedora
9
+ ssl:
10
+ verify: false
11
+ ca_path: /path/to/certs
12
+
@@ -22,17 +22,28 @@ describe ActiveFedora::Base do
22
22
 
23
23
  let(:date) { DateTime.parse("2015-10-22T10:20:03.653+01:00") }
24
24
  let(:date2) { DateTime.parse("2015-10-22T15:34:20.323-11:00") }
25
- subject { Foo.create(date: [date], single_date: date2, empty_date: '', integer: 1).reload }
26
25
 
27
26
  describe "saving and loading in Fedora" do
27
+ let(:object) { Foo.create!(date: [date], single_date: date2, empty_date: '', integer: 1).reload }
28
28
  it "loads the correct time" do
29
- expect(subject.date.first).to eql date
30
- expect(subject.single_date).to eql date2
29
+ expect(object.date.first).to eql date
30
+ expect(object.single_date).to eql date2
31
+ end
32
+ end
33
+
34
+ describe 'serializing' do
35
+ let(:object) { Foo.new(date: [date]) }
36
+ let(:triple) { object.resource.query(predicate: ::RDF::Vocab::DC.date).to_a.first }
37
+ subject { triple.to_s }
38
+ it 'time zone must have semicolin to be a cannonical XMLSchema#dateTime' do
39
+ expect(subject).to match(/\+01:00/)
31
40
  end
32
41
  end
33
42
 
34
43
  describe "saving and loading in Solr" do
35
- let(:subject_solr) { subject.class.load_instance_from_solr(subject.id) }
44
+ let(:object) { Foo.create!(date: [date], single_date: date2, empty_date: '', integer: 1) }
45
+
46
+ let(:subject_solr) { object.class.load_instance_from_solr(object.id) }
36
47
  it "uses DateTime objects" do
37
48
  expect(subject_solr.date.first).to be_a DateTime
38
49
  expect(subject_solr.single_date).to be_a DateTime
@@ -2,12 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Config do
4
4
  context "with a single fedora instance" do
5
- let(:yaml) { Psych.load(File.read('spec/fixtures/rails_root/config/fedora.yml'))['test'] }
6
- let(:conf) { described_class.new(yaml) }
5
+ let(:yaml) { Psych.load(File.read('spec/fixtures/rails_root/config/fedora.yml')) }
6
+ let(:section) { 'test' }
7
+ let(:conf) { described_class.new(yaml[section]) }
7
8
 
8
9
  describe "#credentials" do
9
10
  subject { conf.credentials }
10
- it { should eq(url: 'http://testhost.com:8983/fedora', user: 'fedoraAdmin', password: 'fedoraAdmin') }
11
+ it { is_expected.to eq(url: 'http://testhost.com:8983/fedora', user: 'fedoraAdmin', password: 'fedoraAdmin') }
12
+ describe "with SSL options" do
13
+ let(:section) { 'test_ssl' }
14
+ its([:ssl]) { is_expected.to eq(verify: false, ca_path: '/path/to/certs') }
15
+ end
11
16
  end
12
17
  end
13
18
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveFedora::Fedora do
4
+ subject { described_class.new(config) }
5
+ describe "#authorized_connection" do
6
+ describe "with SSL options" do
7
+ let(:config) {
8
+ { url: "https://example.com",
9
+ user: "fedoraAdmin",
10
+ password: "fedoraAdmin",
11
+ ssl: { ca_path: '/path/to/certs' }
12
+ }
13
+ }
14
+ specify {
15
+ expect(Faraday).to receive(:new).with("https://example.com", ssl: { ca_path: '/path/to/certs' }).twice.and_call_original
16
+ subject.authorized_connection
17
+ }
18
+ end
19
+ end
20
+ end
@@ -230,6 +230,15 @@ describe ActiveFedora::FileConfigurator do
230
230
  expect(subject.load_solr_config).to eq(url: "http://mysolr:8081")
231
231
  expect(subject.solr_config).to eq(url: "http://mysolr:8081")
232
232
  end
233
+
234
+ it "includes update_path and select_path in solr_config" do
235
+ allow(subject).to receive(:load_solrizer_config)
236
+ expect(subject).to receive(:config_path).with(:solr).and_return("/path/to/solr.yml")
237
+ expect(subject).to receive(:load_fedora_config)
238
+ expect(IO).to receive(:read).with("/path/to/solr.yml").and_return("test:\n url: http://mysolr:8080\n update_path: update_test\n select_path: select_test\n")
239
+ expect(subject.solr_config[:update_path]).to eq('update_test')
240
+ expect(subject.solr_config[:select_path]).to eq('select_test')
241
+ end
233
242
  end
234
243
 
235
244
  describe "load_configs" do
@@ -292,4 +292,109 @@ describe ActiveFedora::File do
292
292
  it { is_expected.to be_a(DateTime) }
293
293
  end
294
294
  end
295
+
296
+ describe "callbacks" do
297
+ before do
298
+ class MyFile < ActiveFedora::File
299
+ after_initialize :a_init
300
+ before_create :b_create
301
+ after_create :a_create
302
+ before_update :b_update
303
+ after_update :a_update
304
+ before_save :b_save
305
+ after_save :a_save
306
+ before_destroy :b_destroy
307
+ after_destroy :a_destroy
308
+
309
+ def a_init; end
310
+
311
+ def b_create; end
312
+
313
+ def a_create; end
314
+
315
+ def b_save; end
316
+
317
+ def a_save; end
318
+
319
+ def b_destroy; end
320
+
321
+ def a_destroy; end
322
+
323
+ def b_update; end
324
+
325
+ def a_update; end
326
+ end
327
+ end
328
+
329
+ after do
330
+ Object.send(:remove_const, :MyFile)
331
+ end
332
+
333
+ subject { MyFile.new }
334
+
335
+ describe "initialize" do
336
+ specify {
337
+ expect_any_instance_of(MyFile).to receive(:a_init)
338
+ MyFile.new
339
+ }
340
+ end
341
+
342
+ describe "create" do
343
+ describe "when content is not nil" do
344
+ specify {
345
+ expect(subject).to receive(:b_create).once
346
+ expect(subject).to receive(:a_create).once
347
+ expect(subject).to receive(:b_save).once
348
+ expect(subject).to receive(:a_save).once
349
+ subject.content = "foo"
350
+ subject.save
351
+ }
352
+ end
353
+ describe "when content is nil" do
354
+ specify {
355
+ expect(subject).to receive(:b_create).once
356
+ expect(subject).not_to receive(:a_create)
357
+ expect(subject).to receive(:b_save).once
358
+ expect(subject).not_to receive(:a_save)
359
+ subject.save
360
+ }
361
+ end
362
+ end
363
+
364
+ describe "update" do
365
+ describe "when content has changed" do
366
+ specify {
367
+ subject.content = "foo"
368
+ subject.save
369
+ expect(subject).to receive(:b_save).once
370
+ expect(subject).to receive(:a_save).once
371
+ expect(subject).to receive(:b_update).once
372
+ expect(subject).to receive(:a_update).once
373
+ subject.content = "bar"
374
+ subject.save
375
+ }
376
+ end
377
+ describe "when content has not changed" do
378
+ specify {
379
+ subject.content = "foo"
380
+ subject.save
381
+ expect(subject).to receive(:b_save).once
382
+ expect(subject).not_to receive(:a_save)
383
+ expect(subject).to receive(:b_update).once
384
+ expect(subject).not_to receive(:a_update)
385
+ subject.save
386
+ }
387
+ end
388
+ end
389
+
390
+ describe "destroy" do
391
+ specify {
392
+ subject.content = "foo"
393
+ subject.save
394
+ expect(subject).to receive(:b_destroy).once
395
+ expect(subject).to receive(:a_destroy).once
396
+ subject.destroy
397
+ }
398
+ end
399
+ end
295
400
  end
@@ -6,6 +6,14 @@ describe ActiveFedora::FinderMethods do
6
6
  def self.delegated_attributes
7
7
  {}
8
8
  end
9
+
10
+ def self.solr_query_handler
11
+ 'standard'
12
+ end
13
+
14
+ def self.default_sort_params
15
+ ["system_create_dtsi asc"]
16
+ end
9
17
  end
10
18
  end
11
19
 
@@ -47,4 +55,30 @@ describe ActiveFedora::FinderMethods do
47
55
  "_query_:\"{!raw f=library_id}four\"" }
48
56
  end
49
57
  end
58
+
59
+ describe "#find_in_batches" do
60
+ let(:docs) { double('docs', has_next?: false) }
61
+ let(:select_handler) { 'select' }
62
+ let(:connection) { double('conn') }
63
+ before do
64
+ expect(finder).to receive(:create_query).with('age_t' => '21').and_return('dummy query')
65
+ allow(ActiveFedora::SolrService.instance).to receive(:conn).and_return(connection)
66
+ allow(ActiveFedora::SolrService).to receive(:select_path).and_return(select_handler)
67
+ expect(connection).to receive(:paginate) \
68
+ .with(1, 1000, select_handler, params: hash_including(other_opt: 'test')) \
69
+ .and_return('response' => { 'docs' => docs })
70
+ end
71
+ it "yields the docs" do
72
+ expect { |b|
73
+ finder.find_in_batches({ 'age_t' => '21' }, { other_opt: 'test' }, &b)
74
+ }.to yield_with_args(docs)
75
+ end
76
+
77
+ context "with custom select handler" do
78
+ let(:select_handler) { 'select_test' }
79
+ it "uses the custom select handler" do
80
+ finder.find_in_batches({ 'age_t' => '21' }, other_opt: 'test') do end
81
+ end
82
+ end
83
+ end
50
84
  end
@@ -33,6 +33,13 @@ describe ActiveFedora::SolrService do
33
33
  expect(described_class).to receive(:register)
34
34
  expect(proc { described_class.instance }).to raise_error(ActiveFedora::SolrNotInitialized)
35
35
  end
36
+ it "passes on solr_config when initializing the service" do
37
+ allow(RSolr).to receive(:connect)
38
+ expect(Thread.current[:solr_service]).to be_nil
39
+ allow(ActiveFedora).to receive(:solr_config).and_return(url: 'http://fubar', update_path: 'update_test')
40
+ expect(described_class).to receive(:register).with('http://fubar', hash_including(update_path: 'update_test')).and_call_original
41
+ described_class.instance
42
+ end
36
43
 
37
44
  describe '#construct_query_for_pids' do
38
45
  it "generates a useable solr query from an array of Fedora ids" do
@@ -49,6 +56,14 @@ describe ActiveFedora::SolrService do
49
56
  allow(described_class).to receive(:instance).and_return(double("instance", conn: mock_conn))
50
57
  expect(described_class.query('querytext', raw: true)).to eq stub_result
51
58
  end
59
+ it "uses select_path" do
60
+ mock_conn = double("Connection")
61
+ stub_result = double("Result")
62
+ expect(mock_conn).to receive(:get).with('select_test', params: { q: 'querytext', qt: 'standard' }).and_return(stub_result)
63
+ expect(described_class).to receive(:select_path).and_return('select_test')
64
+ allow(described_class).to receive(:instance).and_return(double("instance", conn: mock_conn))
65
+ expect(described_class.query('querytext', raw: true)).to eq stub_result
66
+ end
52
67
  end
53
68
  describe ".count" do
54
69
  it "returns a count of matching records" do
@@ -66,6 +81,16 @@ describe ActiveFedora::SolrService do
66
81
  expect(described_class.count('querytext', fq: 'filter', rows: 10)).to eq 7
67
82
  end
68
83
  end
84
+ describe ".select_path" do
85
+ it "gets :select_path from solr_config" do
86
+ expect(ActiveFedora).to receive(:solr_config).and_return(select_path: 'select_test')
87
+ expect(described_class.select_path).to eq 'select_test'
88
+ end
89
+ it "uses 'select' as default" do
90
+ expect(ActiveFedora).to receive(:solr_config).and_return({})
91
+ expect(described_class.select_path).to eq 'select'
92
+ end
93
+ end
69
94
 
70
95
  describe ".add" do
71
96
  it "calls solr" do