active-fedora 12.0.0 → 12.1.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 (61) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +7 -7
  3. data/.rubocop_todo.yml +10 -100
  4. data/.travis.yml +10 -4
  5. data/CODE_OF_CONDUCT.md +36 -0
  6. data/CONTRIBUTING.md +23 -21
  7. data/History.txt +29 -29
  8. data/LICENSE +16 -14
  9. data/README.md +40 -29
  10. data/SUPPORT.md +5 -0
  11. data/active-fedora.gemspec +7 -7
  12. data/lib/active_fedora/aggregation/list_source.rb +3 -2
  13. data/lib/active_fedora/associations/builder/collection_association.rb +1 -0
  14. data/lib/active_fedora/associations/collection_association.rb +3 -0
  15. data/lib/active_fedora/associations/collection_proxy.rb +2 -0
  16. data/lib/active_fedora/associations/directly_contains_one_association.rb +1 -0
  17. data/lib/active_fedora/associations/indirectly_contains_association.rb +2 -0
  18. data/lib/active_fedora/associations/singular_association.rb +1 -0
  19. data/lib/active_fedora/attribute_methods/read.rb +1 -1
  20. data/lib/active_fedora/attribute_methods/write.rb +1 -1
  21. data/lib/active_fedora/attribute_methods.rb +1 -1
  22. data/lib/active_fedora/attributes/property_builder.rb +1 -0
  23. data/lib/active_fedora/attributes.rb +1 -1
  24. data/lib/active_fedora/callbacks.rb +7 -2
  25. data/lib/active_fedora/fedora.rb +8 -0
  26. data/lib/active_fedora/file.rb +4 -4
  27. data/lib/active_fedora/indexing/descendant_fetcher.rb +1 -1
  28. data/lib/active_fedora/indexing/field_mapper.rb +2 -0
  29. data/lib/active_fedora/indexing/suffix.rb +3 -1
  30. data/lib/active_fedora/inheritable_accessors.rb +1 -0
  31. data/lib/active_fedora/loadable_from_json.rb +1 -0
  32. data/lib/active_fedora/nested_attributes.rb +1 -0
  33. data/lib/active_fedora/persistence/null_identifier_service.rb +11 -0
  34. data/lib/active_fedora/persistence.rb +14 -1
  35. data/lib/active_fedora/reflection.rb +1 -1
  36. data/lib/active_fedora/relation/delegation.rb +2 -1
  37. data/lib/active_fedora/relation/finder_methods.rb +6 -1
  38. data/lib/active_fedora/relation/merger.rb +1 -0
  39. data/lib/active_fedora/relation.rb +14 -0
  40. data/lib/active_fedora/validations.rb +7 -0
  41. data/lib/active_fedora/version.rb +1 -1
  42. data/lib/active_fedora/with_metadata/metadata_node.rb +2 -1
  43. data/lib/active_fedora/with_metadata.rb +1 -0
  44. data/lib/active_fedora.rb +1 -1
  45. data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +1 -1
  46. data/lib/generators/active_fedora/config/solr/solr_generator.rb +2 -1
  47. data/lib/generators/active_fedora/config/solr/templates/solr/config/schema.xml +64 -51
  48. data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +4 -1
  49. data/lib/generators/active_fedora/model/templates/datastream.rb.erb +1 -1
  50. data/spec/integration/file_spec.rb +1 -1
  51. data/spec/integration/generators/fedora_generator_spec.rb +1 -1
  52. data/spec/integration/generators/solr_generator_spec.rb +1 -1
  53. data/spec/integration/relation_spec.rb +43 -0
  54. data/spec/spec_helper.rb +10 -8
  55. data/spec/support/an_active_model.rb +4 -0
  56. data/spec/unit/callback_spec.rb +8 -1
  57. data/spec/unit/finder_methods_spec.rb +47 -1
  58. data/spec/unit/validations_spec.rb +18 -0
  59. metadata +29 -21
  60. /data/lib/generators/active_fedora/config/fedora/templates/{.fcrepo_wrapper → .fcrepo_wrapper.yml} +0 -0
  61. /data/lib/generators/active_fedora/config/solr/templates/{.solr_wrapper → .solr_wrapper.yml} +0 -0
@@ -11,7 +11,8 @@ module ActiveFedora
11
11
  end
12
12
 
13
13
  def solr_wrapper_config
14
- copy_file '.solr_wrapper', '.solr_wrapper'
14
+ # Overwrite the configuration files that Blacklight has installed
15
+ copy_file '.solr_wrapper.yml', force: true
15
16
  copy_file 'solr_wrapper_test.yml', 'config/solr_wrapper_test.yml'
16
17
  end
17
18
  end
@@ -48,43 +48,47 @@
48
48
  <schema name="Hydra Demo Index" version="1.5">
49
49
  <!-- attribute "name" is the name of this schema and is only used for display purposes.
50
50
  Applications should change this to reflect the nature of the search collection.
51
- version="1.4" is Solr's version number for the schema syntax and semantics. It should
51
+ version="1.5" is Solr's version number for the schema syntax and semantics. It should
52
52
  not normally be changed by applications.
53
53
  1.0: multiValued attribute did not exist, all fields are multiValued by nature
54
54
  1.1: multiValued attribute introduced, false by default
55
55
  1.2: omitTermFreqAndPositions attribute introduced, true by default except for text fields.
56
56
  1.3: removed optional field compress feature
57
57
  1.4: default auto-phrase (QueryParser feature) to off
58
+ 1.5: omitNorms defaults to true for primitive field types (int, float, boolean, string...)
59
+ # TODO 1.6: useDocValuesAsStored defaults to true.
60
+ # See https://github.com/samvera/active_fedora/issues/1346
58
61
  -->
59
62
 
60
63
  <types>
61
64
  <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
62
- <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
65
+ <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
63
66
  <fieldType name="rand" class="solr.RandomSortField" omitNorms="true"/>
64
-
67
+
65
68
  <!-- Default numeric field types. -->
66
- <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
67
- <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
68
- <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
69
- <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
70
-
71
- <!-- trie numeric field types for faster range queries -->
72
- <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
73
- <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
74
- <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
75
- <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
76
-
69
+ <fieldType name="int" class="solr.IntPointField" docValues="true"/>
70
+ <fieldType name="float" class="solr.FloatPointField" docValues="true"/>
71
+ <fieldType name="long" class="solr.LongPointField" docValues="true"/>
72
+ <fieldType name="double" class="solr.DoublePointField" docValues="true"/>
73
+
74
+ <!-- PointField numeric field types for faster range queries -->
75
+ <fieldType name="tint" class="solr.IntPointField" docValues="true"/>
76
+ <fieldType name="tfloat" class="solr.FloatPointField" docValues="true"/>
77
+ <fieldType name="tlong" class="solr.LongPointField" docValues="true"/>
78
+ <fieldType name="tdouble" class="solr.DoublePointField" docValues="true"/>
79
+
77
80
  <!-- The format for this date field is of the form 1995-12-31T23:59:59Z
78
81
  Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z
79
82
  -->
80
- <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
81
- <!-- A Trie based date field for faster date range queries and date faceting. -->
82
- <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0"/>
83
-
84
-
83
+ <fieldType name="date" class="solr.DatePointField" docValues="true"/>
84
+ <!-- A PointField based date field for faster date range queries and date faceting. -->
85
+ <fieldType name="tdate" class="solr.DatePointField" docValues="true"/>
86
+ <!-- A DateRange based date field for truly faster date range queries. -->
87
+ <fieldType name="dateRange" class="solr.DateRangeField"/>
88
+
85
89
  <!-- This point type indexes the coordinates as separate fields (subFields)
86
90
  If subFieldType is defined, it references a type, and a dynamic field
87
- definition is created matching *___<typename>. Alternately, if
91
+ definition is created matching *___<typename>. Alternately, if
88
92
  subFieldSuffix is defined, that is used to create the subFields.
89
93
  Example: if subFieldType="double", then the coordinates would be
90
94
  indexed in fields myloc_0___double,myloc_1___double.
@@ -94,17 +98,17 @@
94
98
  users normally should not need to know about them.
95
99
  -->
96
100
  <fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
97
-
101
+
98
102
  <!-- A specialized field for geospatial search. If indexed, this fieldType must not be multivalued. -->
99
103
  <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
100
-
104
+
101
105
  <!-- An alternative geospatial field type new to Solr 4. It supports multiValued and polygon shapes.
102
106
  For more information about this and other Spatial fields new to Solr 4, see:
103
107
  http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
104
108
  -->
105
109
  <fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
106
110
  geo="true" distErrPct="0.025" maxDistErr="0.000009" distanceUnits="degrees" />
107
-
111
+
108
112
  <fieldType name="text" class="solr.TextField" omitNorms="false">
109
113
  <analyzer>
110
114
  <tokenizer class="solr.ICUTokenizerFactory"/>
@@ -112,7 +116,7 @@
112
116
  <filter class="solr.TrimFilterFactory"/>
113
117
  </analyzer>
114
118
  </fieldType>
115
-
119
+
116
120
  <!-- A text field that only splits on whitespace for exact matching of words -->
117
121
  <fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100">
118
122
  <analyzer>
@@ -120,7 +124,7 @@
120
124
  <filter class="solr.TrimFilterFactory"/>
121
125
  </analyzer>
122
126
  </fieldType>
123
-
127
+
124
128
  <!-- single token analyzed text, for sorting. Punctuation is significant. -->
125
129
  <fieldtype name="alphaSort" class="solr.TextField" sortMissingLast="true" omitNorms="true">
126
130
  <analyzer>
@@ -129,7 +133,7 @@
129
133
  <filter class="solr.TrimFilterFactory" />
130
134
  </analyzer>
131
135
  </fieldtype>
132
-
136
+
133
137
  <!-- A text field with defaults appropriate for English -->
134
138
  <fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
135
139
  <analyzer>
@@ -144,7 +148,7 @@
144
148
  <filter class="solr.TrimFilterFactory"/>
145
149
  </analyzer>
146
150
  </fieldType>
147
-
151
+
148
152
  <!-- queries for paths match documents at that path, or in descendent paths -->
149
153
  <fieldType name="descendent_path" class="solr.TextField">
150
154
  <analyzer type="index">
@@ -154,7 +158,7 @@
154
158
  <tokenizer class="solr.KeywordTokenizerFactory" />
155
159
  </analyzer>
156
160
  </fieldType>
157
-
161
+
158
162
  <!-- queries for paths match documents at that path, or in ancestor paths -->
159
163
  <fieldType name="ancestor_path" class="solr.TextField">
160
164
  <analyzer type="index">
@@ -179,12 +183,12 @@
179
183
  <fields>
180
184
  <!-- If you remove this field, you must _also_ disable the update log in solrconfig.xml
181
185
  or Solr won't start. _version_ and update log are required for SolrCloud
182
- -->
186
+ -->
183
187
  <field name="_version_" type="long" indexed="true" stored="true"/>
184
-
188
+
185
189
  <field name="id" type="string" stored="true" indexed="true" multiValued="false" required="true"/>
186
190
  <field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
187
-
191
+
188
192
  <field name="lat" type="tdouble" stored="true" indexed="true" multiValued="false"/>
189
193
  <field name="lng" type="tdouble" stored="true" indexed="true" multiValued="false"/>
190
194
 
@@ -201,7 +205,7 @@
201
205
  <dynamicField name="*_timv" type="text" stored="false" indexed="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true"/>
202
206
  <dynamicField name="*_tsiv" type="text" stored="true" indexed="true" multiValued="false" termVectors="true" termPositions="true" termOffsets="true"/>
203
207
  <dynamicField name="*_tsimv" type="text" stored="true" indexed="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true"/>
204
-
208
+
205
209
  <!-- English text (_te...) -->
206
210
  <dynamicField name="*_tei" type="text_en" stored="false" indexed="true" multiValued="false"/>
207
211
  <dynamicField name="*_teim" type="text_en" stored="false" indexed="true" multiValued="true"/>
@@ -213,7 +217,7 @@
213
217
  <dynamicField name="*_teimv" type="text_en" stored="false" indexed="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true"/>
214
218
  <dynamicField name="*_tesiv" type="text_en" stored="true" indexed="true" multiValued="false" termVectors="true" termPositions="true" termOffsets="true"/>
215
219
  <dynamicField name="*_tesimv" type="text_en" stored="true" indexed="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true"/>
216
-
220
+
217
221
  <!-- string (_s...) -->
218
222
  <dynamicField name="*_si" type="string" stored="false" indexed="true" multiValued="false"/>
219
223
  <dynamicField name="*_sim" type="string" stored="false" indexed="true" multiValued="true"/>
@@ -222,7 +226,7 @@
222
226
  <dynamicField name="*_ssi" type="string" stored="true" indexed="true" multiValued="false"/>
223
227
  <dynamicField name="*_ssim" type="string" stored="true" indexed="true" multiValued="true"/>
224
228
  <dynamicField name="*_ssort" type="alphaSort" stored="false" indexed="true" multiValued="false"/>
225
-
229
+
226
230
  <!-- integer (_i...) -->
227
231
  <dynamicField name="*_ii" type="int" stored="false" indexed="true" multiValued="false"/>
228
232
  <dynamicField name="*_iim" type="int" stored="false" indexed="true" multiValued="true"/>
@@ -230,15 +234,15 @@
230
234
  <dynamicField name="*_ism" type="int" stored="true" indexed="false" multiValued="true"/>
231
235
  <dynamicField name="*_isi" type="int" stored="true" indexed="true" multiValued="false"/>
232
236
  <dynamicField name="*_isim" type="int" stored="true" indexed="true" multiValued="true"/>
233
-
234
- <!-- trie integer (_it...) (for faster range queries) -->
237
+
238
+ <!-- IntegerPointField (_it...) (for faster range queries) -->
235
239
  <dynamicField name="*_iti" type="tint" stored="false" indexed="true" multiValued="false"/>
236
240
  <dynamicField name="*_itim" type="tint" stored="false" indexed="true" multiValued="true"/>
237
241
  <dynamicField name="*_its" type="tint" stored="true" indexed="false" multiValued="false"/>
238
242
  <dynamicField name="*_itsm" type="tint" stored="true" indexed="false" multiValued="true"/>
239
243
  <dynamicField name="*_itsi" type="tint" stored="true" indexed="true" multiValued="false"/>
240
244
  <dynamicField name="*_itsim" type="tint" stored="true" indexed="true" multiValued="true"/>
241
-
245
+
242
246
  <!-- date (_dt...) -->
243
247
  <!-- The format for this date field is of the form 1995-12-31T23:59:59Z
244
248
  Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z -->
@@ -248,15 +252,24 @@
248
252
  <dynamicField name="*_dtsm" type="date" stored="true" indexed="false" multiValued="true"/>
249
253
  <dynamicField name="*_dtsi" type="date" stored="true" indexed="true" multiValued="false"/>
250
254
  <dynamicField name="*_dtsim" type="date" stored="true" indexed="true" multiValued="true"/>
251
-
252
- <!-- trie date (_dtt...) (for faster range queries) -->
255
+
256
+ <!-- DatePointField (_dtt...) (for faster range queries) -->
253
257
  <dynamicField name="*_dtti" type="tdate" stored="false" indexed="true" multiValued="false"/>
254
258
  <dynamicField name="*_dttim" type="tdate" stored="false" indexed="true" multiValued="true"/>
255
259
  <dynamicField name="*_dtts" type="tdate" stored="true" indexed="false" multiValued="false"/>
256
260
  <dynamicField name="*_dttsm" type="tdate" stored="true" indexed="false" multiValued="true"/>
257
261
  <dynamicField name="*_dttsi" type="tdate" stored="true" indexed="true" multiValued="false"/>
258
262
  <dynamicField name="*_dttsim" type="tdate" stored="true" indexed="true" multiValued="true"/>
259
-
263
+
264
+
265
+ <!-- date range (_dr...) (for faster AND better range queries) -->
266
+ <dynamicField name="*_dri" type="dateRange" stored="false" indexed="true" multiValued="false"/>
267
+ <dynamicField name="*_drim" type="dateRange" stored="false" indexed="true" multiValued="true"/>
268
+ <dynamicField name="*_drs" type="dateRange" stored="true" indexed="false" multiValued="false"/>
269
+ <dynamicField name="*_drsm" type="dateRange" stored="true" indexed="false" multiValued="true"/>
270
+ <dynamicField name="*_drsi" type="dateRange" stored="true" indexed="true" multiValued="false"/>
271
+ <dynamicField name="*_drsim" type="dateRange" stored="true" indexed="true" multiValued="true"/>
272
+
260
273
  <!-- long (_l...) -->
261
274
  <dynamicField name="*_li" type="long" stored="false" indexed="true" multiValued="false"/>
262
275
  <dynamicField name="*_lim" type="long" stored="false" indexed="true" multiValued="true"/>
@@ -264,15 +277,15 @@
264
277
  <dynamicField name="*_lsm" type="long" stored="true" indexed="false" multiValued="true"/>
265
278
  <dynamicField name="*_lsi" type="long" stored="true" indexed="true" multiValued="false"/>
266
279
  <dynamicField name="*_lsim" type="long" stored="true" indexed="true" multiValued="true"/>
267
-
268
- <!-- trie long (_lt...) (for faster range queries) -->
280
+
281
+ <!-- LongPointField (_lt...) (for faster range queries) -->
269
282
  <dynamicField name="*_lti" type="tlong" stored="false" indexed="true" multiValued="false"/>
270
283
  <dynamicField name="*_ltim" type="tlong" stored="false" indexed="true" multiValued="true"/>
271
284
  <dynamicField name="*_lts" type="tlong" stored="true" indexed="false" multiValued="false"/>
272
285
  <dynamicField name="*_ltsm" type="tlong" stored="true" indexed="false" multiValued="true"/>
273
286
  <dynamicField name="*_ltsi" type="tlong" stored="true" indexed="true" multiValued="false"/>
274
287
  <dynamicField name="*_ltsim" type="tlong" stored="true" indexed="true" multiValued="true"/>
275
-
288
+
276
289
  <!-- double (_db...) -->
277
290
  <dynamicField name="*_dbi" type="double" stored="false" indexed="true" multiValued="false"/>
278
291
  <dynamicField name="*_dbim" type="double" stored="false" indexed="true" multiValued="true"/>
@@ -280,15 +293,15 @@
280
293
  <dynamicField name="*_dbsm" type="double" stored="true" indexed="false" multiValued="true"/>
281
294
  <dynamicField name="*_dbsi" type="double" stored="true" indexed="true" multiValued="false"/>
282
295
  <dynamicField name="*_dbsim" type="double" stored="true" indexed="true" multiValued="true"/>
283
-
284
- <!-- trie double (_dbt...) (for faster range queries) -->
296
+
297
+ <!-- DoublePointField (_dbt...) (for faster range queries) -->
285
298
  <dynamicField name="*_dbti" type="tdouble" stored="false" indexed="true" multiValued="false"/>
286
299
  <dynamicField name="*_dbtim" type="tdouble" stored="false" indexed="true" multiValued="true"/>
287
300
  <dynamicField name="*_dbts" type="tdouble" stored="true" indexed="false" multiValued="false"/>
288
301
  <dynamicField name="*_dbtsm" type="tdouble" stored="true" indexed="false" multiValued="true"/>
289
302
  <dynamicField name="*_dbtsi" type="tdouble" stored="true" indexed="true" multiValued="false"/>
290
303
  <dynamicField name="*_dbtsim" type="tdouble" stored="true" indexed="true" multiValued="true"/>
291
-
304
+
292
305
  <!-- float (_f...) -->
293
306
  <dynamicField name="*_fi" type="float" stored="false" indexed="true" multiValued="false"/>
294
307
  <dynamicField name="*_fim" type="float" stored="false" indexed="true" multiValued="true"/>
@@ -296,20 +309,20 @@
296
309
  <dynamicField name="*_fsm" type="float" stored="true" indexed="false" multiValued="true"/>
297
310
  <dynamicField name="*_fsi" type="float" stored="true" indexed="true" multiValued="false"/>
298
311
  <dynamicField name="*_fsim" type="float" stored="true" indexed="true" multiValued="true"/>
299
-
300
- <!-- trie float (_ft...) (for faster range queries) -->
312
+
313
+ <!-- FloatPointField (_ft...) (for faster range queries) -->
301
314
  <dynamicField name="*_fti" type="tfloat" stored="false" indexed="true" multiValued="false"/>
302
315
  <dynamicField name="*_ftim" type="tfloat" stored="false" indexed="true" multiValued="true"/>
303
316
  <dynamicField name="*_fts" type="tfloat" stored="true" indexed="false" multiValued="false"/>
304
317
  <dynamicField name="*_ftsm" type="tfloat" stored="true" indexed="false" multiValued="true"/>
305
318
  <dynamicField name="*_ftsi" type="tfloat" stored="true" indexed="true" multiValued="false"/>
306
319
  <dynamicField name="*_ftsim" type="tfloat" stored="true" indexed="true" multiValued="true"/>
307
-
320
+
308
321
  <!-- boolean (_b...) -->
309
322
  <dynamicField name="*_bi" type="boolean" stored="false" indexed="true" multiValued="false"/>
310
323
  <dynamicField name="*_bs" type="boolean" stored="true" indexed="false" multiValued="false"/>
311
324
  <dynamicField name="*_bsi" type="boolean" stored="true" indexed="true" multiValued="false"/>
312
-
325
+
313
326
  <!-- Type used to index the lat and lon components for the "location" FieldType -->
314
327
  <dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false" />
315
328
 
@@ -329,7 +342,7 @@
329
342
 
330
343
  </fields>
331
344
 
332
- <!-- Field to use to determine and enforce document uniqueness.
345
+ <!-- Field to use to determine and enforce document uniqueness.
333
346
  Unless this field is marked with required="false", it will be a required field
334
347
  -->
335
348
  <uniqueKey>id</uniqueKey>
@@ -284,6 +284,8 @@
284
284
  -->
285
285
  </searchComponent>
286
286
 
287
+ <!-- suggest searchComponent and requestHandler disabled by default due to performance penalties -->
288
+ <!--
287
289
  <searchComponent name="suggest" class="solr.SuggestComponent">
288
290
  <lst name="suggester">
289
291
  <str name="name">mySuggester</str>
@@ -304,7 +306,8 @@
304
306
  <str>suggest</str>
305
307
  </arr>
306
308
  </requestHandler>
307
-
309
+ -->
310
+
308
311
  <requestHandler name="/update/extract" class="org.apache.solr.handler.extraction.ExtractingRequestHandler">
309
312
  <lst name="defaults">
310
313
  <str name="fmap.Last-Modified">last_modified</str>
@@ -3,7 +3,7 @@
3
3
  class <%= class_name %>Metadata < ActiveFedora::OmDatastream
4
4
 
5
5
  # Define a terminology for parsing this XML document
6
- # See: https://github.com/projecthydra/om/wiki/Tame-your-XML-with-OM
6
+ # See: https://github.com/samvera/om/wiki/Tame-your-XML-with-OM
7
7
  #
8
8
  # set_terminology do |t|
9
9
  # t.root(path: "fields")
@@ -74,7 +74,7 @@ describe ActiveFedora::File do
74
74
 
75
75
  describe "changed attributes are set" do
76
76
  it "marks profile as changed" do
77
- expect_any_instance_of(SampleResource).to receive(:attribute_will_change!).with(:profile)
77
+ expect_any_instance_of(SampleResource).to receive(:attribute_will_change!).with(:ldp_source)
78
78
  test_object
79
79
  end
80
80
  end
@@ -6,7 +6,7 @@ describe ActiveFedora::Config::FedoraGenerator do
6
6
  let(:generator) { described_class.new }
7
7
  let(:files_to_test) { [
8
8
  'config/fcrepo_wrapper_test.yml',
9
- '.fcrepo_wrapper'
9
+ '.fcrepo_wrapper.yml'
10
10
  ]}
11
11
 
12
12
  before do
@@ -6,7 +6,7 @@ describe ActiveFedora::Config::SolrGenerator do
6
6
  let(:generator) { described_class.new }
7
7
  let(:files_to_test) { [
8
8
  'config/solr_wrapper_test.yml',
9
- '.solr_wrapper'
9
+ '.solr_wrapper.yml'
10
10
  ]}
11
11
 
12
12
  it "creates config files" do
@@ -22,6 +22,10 @@ describe ActiveFedora::Base do
22
22
  end
23
23
 
24
24
  it { is_expected.to respond_to(:each_with_index) }
25
+ it { expect(libraries.any?).to eq false }
26
+ it { is_expected.to be_blank }
27
+ it { is_expected.to be_empty }
28
+ it { is_expected.not_to be_present }
25
29
 
26
30
  context "when some records exist" do
27
31
  before do
@@ -41,6 +45,45 @@ describe ActiveFedora::Base do
41
45
  expect_any_instance_of(ActiveFedora::Relation).to_not receive :find_each
42
46
  libraries[0]
43
47
  end
48
+
49
+ it "does not reload" do
50
+ expect_any_instance_of(ActiveFedora::Relation).to_not receive :find_each
51
+ libraries.each { |l| l.id }
52
+ end
53
+ end
54
+
55
+ it { expect(libraries.any?).to eq true }
56
+ it { is_expected.not_to be_blank }
57
+ it { is_expected.not_to be_empty }
58
+ it { is_expected.to be_present }
59
+
60
+ describe '#each' do
61
+ before { Book.create }
62
+
63
+ it 'returns an enumerator' do
64
+ expect(libraries.each).to be_a Enumerator
65
+ end
66
+
67
+ it 'yields the items' do
68
+ expect { |b| libraries.each(&b) }
69
+ .to yield_successive_args(*Library.all.to_a)
70
+ end
71
+
72
+ it 'when called from Base yields all items' do
73
+ expect { |b| ActiveFedora::Base.all.each(&b) }
74
+ .to yield_successive_args(*(Library.all.to_a + Book.all.to_a))
75
+ end
76
+
77
+ context 'when cached' do
78
+ it 'returns an enumerator' do
79
+ expect(libraries.each).to be_a Enumerator
80
+ end
81
+
82
+ it 'yields the items' do
83
+ expect { |b| libraries.each(&b) }
84
+ .to yield_successive_args(*Library.all.to_a)
85
+ end
86
+ end
44
87
  end
45
88
 
46
89
  describe "#find" do
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,17 @@
1
- ENV["environment"] ||= 'test'
2
- require "bundler/setup"
1
+ ENV["environment"] ||= "test"
3
2
 
3
+ require "bundler/setup"
4
4
  require 'simplecov'
5
5
  require 'coveralls'
6
6
 
7
- SimpleCov.start do
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
8
+ [
9
+ SimpleCov::Formatter::HTMLFormatter,
10
+ Coveralls::SimpleCov::Formatter
11
+ ]
12
+ )
13
+
14
+ SimpleCov.start "rails" do
8
15
  add_filter "/spec/"
9
16
  end
10
17
 
@@ -17,11 +24,6 @@ require 'pry' unless ENV['TRAVIS']
17
24
 
18
25
  ActiveFedora::Base.logger = Logger.new(STDERR)
19
26
  ActiveFedora::Base.logger.level = Logger::WARN
20
- # require 'http_logger'
21
- # HttpLogger.logger = Logger.new(STDOUT)
22
- # HttpLogger.ignore = [/localhost:8983\/solr/]
23
- # HttpLogger.colorize = false
24
- # HttpLogger.log_headers = true
25
27
 
26
28
  Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
27
29
 
@@ -11,6 +11,10 @@ shared_examples_for "An ActiveModel" do
11
11
  expect(one).to eq the_other
12
12
  end
13
13
 
14
+ def assert_respond_to(obj, meth, _msg = nil)
15
+ expect(obj).to respond_to meth
16
+ end
17
+
14
18
  include ActiveModel::Lint::Tests
15
19
 
16
20
  ActiveModel::Lint::Tests.public_instance_methods.map(&:to_s).grep(/^test/).each do |m|
@@ -12,6 +12,9 @@ describe ActiveFedora::Base do
12
12
  after_update :a_update
13
13
  after_find :a_find
14
14
 
15
+ after_update_index :a_update_index
16
+ before_update_index :b_update_index
17
+
15
18
  before_destroy :do_stuff
16
19
 
17
20
  def do_stuff
@@ -24,12 +27,14 @@ describe ActiveFedora::Base do
24
27
  Object.send(:remove_const, :CallbackStub)
25
28
  end
26
29
 
27
- it "has after_initialize, before_save, after_save, before_create, after_create" do
30
+ it "has after_initialize, before_save, after_save, before_create, after_create, after_update_index, before_update_index" do
28
31
  allow_any_instance_of(CallbackStub).to receive(:a_init)
29
32
  allow_any_instance_of(CallbackStub).to receive :b_create
30
33
  allow_any_instance_of(CallbackStub).to receive :a_create
31
34
  allow_any_instance_of(CallbackStub).to receive(:b_save)
32
35
  allow_any_instance_of(CallbackStub).to receive(:a_save)
36
+ allow_any_instance_of(CallbackStub).to receive(:a_update_index)
37
+ allow_any_instance_of(CallbackStub).to receive(:b_update_index)
33
38
  @cb = CallbackStub.new
34
39
  @cb.save
35
40
  end
@@ -40,6 +45,8 @@ describe ActiveFedora::Base do
40
45
  allow_any_instance_of(CallbackStub).to receive(:a_create)
41
46
  allow_any_instance_of(CallbackStub).to receive(:b_save)
42
47
  allow_any_instance_of(CallbackStub).to receive(:a_save)
48
+ allow_any_instance_of(CallbackStub).to receive(:a_update_index)
49
+ allow_any_instance_of(CallbackStub).to receive(:b_update_index)
43
50
  @cb = CallbackStub.new
44
51
  @cb.save
45
52
  allow_any_instance_of(CallbackStub).to receive(:a_init)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ActiveFedora::FinderMethods do
3
+ RSpec.describe ActiveFedora::FinderMethods do
4
4
  let(:object_class) do
5
5
  Class.new do
6
6
  def self.delegated_attributes
@@ -30,6 +30,52 @@ describe ActiveFedora::FinderMethods do
30
30
 
31
31
  let(:finder) { finder_class.new }
32
32
 
33
+ describe '#equivalent_class?' do
34
+ let(:child_class) { Class.new(object_class) }
35
+ let(:object_class) { Class.new }
36
+ it 'is true for the exact class' do
37
+ expect(finder.send(:equivalent_class?, object_class)).to be true
38
+ end
39
+
40
+ it 'is true for child classes' do
41
+ expect(finder.send(:equivalent_class?, child_class)).to be true
42
+ end
43
+
44
+ it 'is falsey for non-decendants' do
45
+ expect(finder.send(:equivalent_class?, Class.new)).to be_nil
46
+ end
47
+ end
48
+
49
+ describe '#class_to_load' do
50
+ subject(:class_to_load) { finder.send(:class_to_load, resource, true) }
51
+
52
+ let(:best_model) { Class.new }
53
+ let(:mapper) { instance_double(ActiveFedora::DefaultModelMapper, classifier: classifier) }
54
+ let(:classifier) { instance_double(ActiveFedora::ModelClassifier, best_model: best_model) }
55
+ let(:resource) { instance_double(Hash) }
56
+
57
+ before do
58
+ allow(ActiveFedora).to receive(:model_mapper).and_return(mapper)
59
+ end
60
+
61
+ context 'when using the default implementation' do
62
+ it 'raises an error' do
63
+ expect { class_to_load }.to raise_error ActiveFedora::ModelMismatch
64
+ end
65
+ end
66
+
67
+ context 'when a custom finder overrides equivalent_class?' do
68
+ before do
69
+ allow(finder).to receive(:equivalent_class?).and_return(true)
70
+ end
71
+
72
+ it 'calls the overridden implementation' do
73
+ expect(class_to_load).to eq best_model
74
+ expect(finder).to have_received(:equivalent_class?).with(best_model)
75
+ end
76
+ end
77
+ end
78
+
33
79
  describe "#condition_to_clauses" do
34
80
  subject { finder.send(:condition_to_clauses, key, value) }
35
81
  let(:key) { 'library_id' }
@@ -8,6 +8,16 @@ describe ActiveFedora::Base do
8
8
 
9
9
  validates_presence_of :fubar
10
10
  validates_length_of :swank, minimum: 5
11
+
12
+ before_validation :before_validation_callback
13
+ after_validation :after_validation_callback
14
+
15
+ def before_validation_callback
16
+ # no-op
17
+ end
18
+ def after_validation_callback
19
+ # no-op
20
+ end
11
21
  end
12
22
  end
13
23
 
@@ -71,4 +81,12 @@ describe ActiveFedora::Base do
71
81
  end
72
82
  end
73
83
  end
84
+
85
+ describe 'validation callbacks' do
86
+ it 'calls callbacks' do
87
+ expect(validation_stub).to receive(:before_validation_callback)
88
+ expect(validation_stub).to receive(:after_validation_callback)
89
+ validation_stub.validate
90
+ end
91
+ end
74
92
  end