hydra-works 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -8
  3. data/README.md +9 -9
  4. data/hydra-works.gemspec +3 -4
  5. data/lib/hydra/works.rb +22 -13
  6. data/lib/hydra/works/characterization.rb +31 -0
  7. data/lib/hydra/works/characterization/schema/audio_schema.rb +12 -0
  8. data/lib/hydra/works/characterization/schema/base_schema.rb +17 -0
  9. data/lib/hydra/works/characterization/schema/document_schema.rb +18 -0
  10. data/lib/hydra/works/characterization/schema/image_schema.rb +22 -0
  11. data/lib/hydra/works/characterization/schema/video_schema.rb +9 -0
  12. data/lib/hydra/works/models/characterization/already_there_strategy.rb +12 -0
  13. data/lib/hydra/works/models/characterization/fits_datastream.rb +162 -0
  14. data/lib/hydra/works/models/concerns/collection_behavior.rb +42 -34
  15. data/lib/hydra/works/models/concerns/file_set/characterization/audio.rb +14 -0
  16. data/lib/hydra/works/models/concerns/file_set/characterization/base.rb +23 -0
  17. data/lib/hydra/works/models/concerns/file_set/characterization/document.rb +10 -0
  18. data/lib/hydra/works/models/concerns/file_set/characterization/image.rb +10 -0
  19. data/lib/hydra/works/models/concerns/file_set/characterization/video.rb +17 -0
  20. data/lib/hydra/works/models/concerns/{generic_file → file_set}/contained_files.rb +1 -1
  21. data/lib/hydra/works/models/concerns/file_set/derivatives.rb +27 -0
  22. data/lib/hydra/works/models/concerns/{generic_file → file_set}/mime_types.rb +1 -1
  23. data/lib/hydra/works/models/concerns/{generic_file → file_set}/versioned_content.rb +2 -2
  24. data/lib/hydra/works/models/concerns/{generic_file → file_set}/virus_check.rb +1 -1
  25. data/lib/hydra/works/models/concerns/file_set_behavior.rb +67 -0
  26. data/lib/hydra/works/models/concerns/generic_file_behavior.rb +4 -50
  27. data/lib/hydra/works/models/concerns/generic_work_behavior.rb +5 -77
  28. data/lib/hydra/works/models/concerns/work_behavior.rb +118 -0
  29. data/lib/hydra/works/models/file_set.rb +7 -0
  30. data/lib/hydra/works/models/generic_file.rb +8 -8
  31. data/lib/hydra/works/models/generic_work.rb +15 -4
  32. data/lib/hydra/works/models/work.rb +6 -0
  33. data/lib/hydra/works/services/{generic_file/add_file_to_generic_file.rb → add_file_to_file_set.rb} +20 -20
  34. data/lib/hydra/works/services/add_file_to_generic_file.rb +8 -0
  35. data/lib/hydra/works/services/characterization_service.rb +118 -0
  36. data/lib/hydra/works/services/persist_derivative.rb +35 -0
  37. data/lib/hydra/works/services/{generic_file/upload_file_to_generic_file.rb → upload_file_to_file_set.rb} +3 -3
  38. data/lib/hydra/works/services/upload_file_to_generic_file.rb +8 -0
  39. data/lib/hydra/works/version.rb +1 -1
  40. data/lib/hydra/works/vocab/works_terms.rb +2 -2
  41. data/spec/fixtures/fits_0.6.2_avi.xml +29 -0
  42. data/spec/fixtures/fits_0.6.2_jp2.xml +36 -0
  43. data/spec/fixtures/fits_0.6.2_jpg.xml +43 -0
  44. data/spec/fixtures/fits_0.6.2_pdf.xml +42 -0
  45. data/spec/fixtures/fits_0.8.5_avi.xml +50 -0
  46. data/spec/fixtures/fits_0.8.5_docx.xml +41 -0
  47. data/spec/fixtures/fits_0.8.5_jp2.xml +51 -0
  48. data/spec/fixtures/fits_0.8.5_mp3.xml +47 -0
  49. data/spec/fixtures/fits_0.8.5_mp4.xml +47 -0
  50. data/spec/fixtures/fits_0.8.5_pdf.xml +54 -0
  51. data/spec/fixtures/pdf_fits.xml +54 -0
  52. data/spec/hydra/works/models/collection_spec.rb +58 -326
  53. data/spec/hydra/works/models/concerns/{generic_file → file_set}/contained_files_spec.rb +16 -16
  54. data/spec/hydra/works/models/concerns/{generic_file → file_set}/mime_types_spec.rb +2 -2
  55. data/spec/hydra/works/models/concerns/file_set/versioned_content_spec.rb +32 -0
  56. data/spec/hydra/works/models/concerns/{generic_file → file_set}/virus_check_spec.rb +3 -3
  57. data/spec/hydra/works/models/concerns/file_set_behavior_spec.rb +12 -0
  58. data/spec/hydra/works/models/generic_file_spec.rb +16 -13
  59. data/spec/hydra/works/models/generic_work_spec.rb +148 -318
  60. data/spec/hydra/works/services/{generic_file/add_file_to_generic_file_spec.rb → add_file_to_file_set_spec.rb} +4 -4
  61. data/spec/hydra/works/services/characterization_service_spec.rb +199 -0
  62. data/spec/hydra/works/services/persist_derivatives_spec.rb +57 -29
  63. data/spec/hydra/works/services/{generic_file/upload_file_spec.rb → upload_file_spec.rb} +7 -17
  64. data/spec/hydra/works_spec.rb +23 -59
  65. data/spec/spec_helper.rb +4 -2
  66. data/spec/support/file_set_helper.rb +14 -0
  67. metadata +84 -55
  68. data/lib/hydra/works/errors/full_text_extraction_error.rb +0 -5
  69. data/lib/hydra/works/models/concerns/block_child_objects.rb +0 -22
  70. data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +0 -26
  71. data/lib/hydra/works/services/generic_file/full_text_extraction_service.rb +0 -57
  72. data/lib/hydra/works/services/generic_file/generate_thumbnail.rb +0 -13
  73. data/lib/hydra/works/services/generic_file/persist_derivative.rb +0 -20
  74. data/spec/hydra/works/models/concerns/block_child_objects_spec.rb +0 -17
  75. data/spec/hydra/works/models/concerns/generic_file/versioned_content_spec.rb +0 -32
  76. data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +0 -12
  77. data/spec/hydra/works/services/full_text_extraction_service_spec.rb +0 -89
  78. data/spec/hydra/works/services/generic_file/generate/thumbnail_spec.rb +0 -19
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <fits xmlns="http://hul.harvard.edu/ois/xml/ns/fits/fits_output" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hul.harvard.edu/ois/xml/ns/fits/fits_output http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd" version="0.8.5" timestamp="8/11/15 2:29 PM">
3
+ <identification>
4
+ <identity format="Portable Document Format" mimetype="application/pdf" toolname="FITS" toolversion="0.8.5">
5
+ <tool toolname="Jhove" toolversion="1.5" />
6
+ <tool toolname="file utility" toolversion="5.14" />
7
+ <tool toolname="Exiftool" toolversion="9.13" />
8
+ <tool toolname="NLNZ Metadata Extractor" toolversion="3.4GA" />
9
+ <tool toolname="ffident" toolversion="0.2" />
10
+ <tool toolname="Tika" toolversion="1.3" />
11
+ <version toolname="Jhove" toolversion="1.5">1.3</version>
12
+ </identity>
13
+ </identification>
14
+ <fileinfo>
15
+ <size toolname="Jhove" toolversion="1.5">7618</size>
16
+ <creatingApplicationName toolname="Exiftool" toolversion="9.13">Mac OS X 10.10.3 Quartz PDFContext/TextEdit</creatingApplicationName>
17
+ <lastmodified toolname="Exiftool" toolversion="9.13" status="CONFLICT">2015:08:07 14:49:00-04:00</lastmodified>
18
+ <lastmodified toolname="Tika" toolversion="1.3" status="CONFLICT">2015-05-14T19:47:31Z</lastmodified>
19
+ <created toolname="Exiftool" toolversion="9.13" status="SINGLE_RESULT">2015:05:14 19:47:31Z</created>
20
+ <filepath toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">/home/grosscol/workspace/hydra-works/spec/fixtures/sample-file.pdf</filepath>
21
+ <filename toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">sample-file.pdf</filename>
22
+ <md5checksum toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">3a1735b5b30c4adc3f92c70004ae53ed</md5checksum>
23
+ <fslastmodified toolname="OIS File Information" toolversion="0.2" status="SINGLE_RESULT">1438973340000</fslastmodified>
24
+ </fileinfo>
25
+ <filestatus>
26
+ <well-formed toolname="Jhove" toolversion="1.5" status="SINGLE_RESULT">true</well-formed>
27
+ <valid toolname="Jhove" toolversion="1.5" status="SINGLE_RESULT">true</valid>
28
+ </filestatus>
29
+ <metadata>
30
+ <document>
31
+ <title toolname="Exiftool" toolversion="9.13">sample-file</title>
32
+ <pageCount toolname="Jhove" toolversion="1.5">1</pageCount>
33
+ <isTagged toolname="Jhove" toolversion="1.5">no</isTagged>
34
+ <hasOutline toolname="Jhove" toolversion="1.5">no</hasOutline>
35
+ <hasAnnotations toolname="Jhove" toolversion="1.5" status="SINGLE_RESULT">no</hasAnnotations>
36
+ <isRightsManaged toolname="Exiftool" toolversion="9.13" status="SINGLE_RESULT">no</isRightsManaged>
37
+ <isProtected toolname="Exiftool" toolversion="9.13">no</isProtected>
38
+ <hasForms toolname="NLNZ Metadata Extractor" toolversion="3.4GA" status="SINGLE_RESULT">no</hasForms>
39
+ </document>
40
+ </metadata>
41
+ <statistics fitsExecutionTime="890">
42
+ <tool toolname="OIS Audio Information" toolversion="0.1" status="did not run" />
43
+ <tool toolname="ADL Tool" toolversion="0.1" status="did not run" />
44
+ <tool toolname="Jhove" toolversion="1.5" executionTime="654" />
45
+ <tool toolname="file utility" toolversion="5.14" executionTime="617" />
46
+ <tool toolname="Exiftool" toolversion="9.13" executionTime="582" />
47
+ <tool toolname="NLNZ Metadata Extractor" toolversion="3.4GA" executionTime="490" />
48
+ <tool toolname="OIS File Information" toolversion="0.2" executionTime="107" />
49
+ <tool toolname="OIS XML Metadata" toolversion="0.2" status="did not run" />
50
+ <tool toolname="ffident" toolversion="0.2" executionTime="459" />
51
+ <tool toolname="Tika" toolversion="1.3" executionTime="824" />
52
+ </statistics>
53
+ </fits>
54
+
@@ -8,325 +8,70 @@ describe Hydra::Works::Collection do
8
8
  let(:collection3) { described_class.new }
9
9
  let(:collection4) { described_class.new }
10
10
 
11
- let(:generic_work1) { Hydra::Works::GenericWork::Base.new }
12
- let(:generic_work2) { Hydra::Works::GenericWork::Base.new }
13
- let(:generic_work3) { Hydra::Works::GenericWork::Base.new }
14
- let(:generic_work4) { Hydra::Works::GenericWork::Base.new }
11
+ let(:generic_work1) { Hydra::Works::GenericWork.new }
12
+ let(:generic_work2) { Hydra::Works::GenericWork.new }
13
+ let(:generic_work3) { Hydra::Works::GenericWork.new }
14
+ let(:generic_work4) { Hydra::Works::GenericWork.new }
15
15
 
16
16
  describe '#collections' do
17
- it 'returns empty array when only generic_works are aggregated' do
18
- subject.generic_works << generic_work1
19
- subject.generic_works << generic_work2
17
+ it 'returns empty array when only works are aggregated' do
18
+ subject.ordered_members << generic_work1
19
+ subject.ordered_members << generic_work2
20
20
  expect(subject.collections).to eq []
21
21
  end
22
22
 
23
- context 'with other collections & generic_works' do
23
+ context 'with other collections & works' do
24
24
  before do
25
- subject.collections << collection1
26
- subject.collections << collection2
27
- subject.generic_works << generic_work1
28
- subject.generic_works << generic_work2
25
+ subject.ordered_members << collection1
26
+ subject.ordered_members << collection2
27
+ subject.ordered_members << generic_work1
28
+ subject.ordered_members << generic_work2
29
29
  end
30
30
 
31
31
  it 'returns only collections' do
32
- expect(subject.collections).to eq [collection1, collection2]
32
+ expect(subject.ordered_collections).to eq [collection1, collection2]
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
- describe '#collections <<' do
38
- context 'with acceptable collections' do
39
- context 'with collections and generic_works' do
40
- before do
41
- subject.collections << collection1
42
- subject.collections << collection2
43
- subject.generic_works << generic_work1
44
- subject.generic_works << generic_work2
45
- end
46
-
47
- it 'adds an generic_work to collection with collections and generic_works' do
48
- subject.collections << collection3
49
- expect(subject.collections).to eq [collection1, collection2, collection3]
50
- end
51
- end
52
-
53
- describe 'aggregates collections that implement Hydra::Works' do
54
- before do
55
- class Kollection < ActiveFedora::Base
56
- include Hydra::Works::CollectionBehavior
57
- end
58
- end
59
- after { Object.send(:remove_const, :Kollection) }
60
- let(:kollection1) { Kollection.new }
61
-
62
- it 'accepts implementing collection as a child' do
63
- subject.collections << kollection1
64
- expect(subject.collections).to eq [kollection1]
65
- end
66
-
67
- it 'accepts implementing collection as a parent' do
68
- subject.collections << collection1
69
- expect(subject.collections).to eq [collection1]
70
- end
71
- end
72
-
73
- describe 'aggregates collections that extend Hydra::Works' do
74
- before do
75
- class Cullection < Hydra::Works::Collection
76
- end
77
- end
78
- after { Object.send(:remove_const, :Cullection) }
79
- let(:cullection1) { Cullection.new }
80
-
81
- it 'accepts extending collection as a child' do
82
- subject.collections << cullection1
83
- expect(subject.collections).to eq [cullection1]
84
- end
85
-
86
- it 'accepts extending collection as a parent' do
87
- subject.collections << collection1
88
- expect(subject.collections).to eq [collection1]
89
- end
90
- end
91
- end
92
-
93
- context 'with unacceptable inputs' do
94
- before(:all) do
95
- @works_collection101 = described_class.new
96
- @generic_work101 = Hydra::Works::GenericWork::Base.new
97
- @generic_file101 = Hydra::Works::GenericFile::Base.new
98
- @pcdm_collection101 = Hydra::PCDM::Collection.new
99
- @pcdm_object101 = Hydra::PCDM::Object.new
100
- @pcdm_file101 = Hydra::PCDM::File.new
101
- @non_pcdm_object = "I'm not a PCDM object"
102
- @af_base_object = ActiveFedora::Base.new
103
- end
104
-
105
- context 'that are unacceptable child collections' do
106
- let(:error_type1) { ArgumentError }
107
- let(:error_message1) { /Hydra::Works::Generic(Work|File)::Base with ID: was expected to works_collection\?, but it was false/ }
108
- let(:error_type2) { NoMethodError }
109
- let(:error_message2) { /undefined method `works_collection\?' for .*/ }
110
-
111
- it 'does not aggregate Hydra::Works::GenericWork in collections aggregation' do
112
- expect { subject.collections << @generic_work101 }.to raise_error(error_type1, error_message1)
113
- end
114
-
115
- it 'does not aggregate Hydra::Works::GenericFile in collections aggregation' do
116
- expect { subject.collections << @generic_file101 }.to raise_error(error_type1, error_message1)
117
- end
118
-
119
- it 'does not aggregate Hydra::PCDM::Collections in collections aggregation' do
120
- expect { subject.collections << @pcdm_collection101 }.to raise_error(error_type2, error_message2)
121
- end
122
-
123
- it 'does not aggregate Hydra::PCDM::Objects in collections aggregation' do
124
- expect { subject.collections << @pcdm_object101 }.to raise_error(error_type2, error_message2)
125
- end
126
-
127
- it 'does not aggregate Hydra::PCDM::Files in collections aggregation' do
128
- expect { subject.collections << @pcdm_file101 }.to raise_error(error_type2, error_message2)
129
- end
130
-
131
- it 'does not aggregate non-PCDM objects in collections aggregation' do
132
- expect { subject.collections << @non_pcdm_object }.to raise_error(error_type2, error_message2)
133
- end
134
-
135
- it 'does not aggregate AF::Base objects in collections aggregation' do
136
- expect { subject.collections << @af_base_object }.to raise_error(error_type2, error_message2)
137
- end
138
- end
139
- end
140
- end
141
-
142
- describe 'collections.delete' do
143
- context 'when multiple collections' do
144
- before do
145
- subject.collections << collection1
146
- subject.collections << collection2
147
- subject.generic_works << generic_work2
148
- subject.collections << collection3
149
- subject.generic_works << generic_work1
150
- expect(subject.collections).to eq [collection1, collection2, collection3]
151
- end
152
-
153
- it 'removes first collection' do
154
- expect(subject.collections.delete collection1).to eq [collection1]
155
- expect(subject.collections).to eq [collection2, collection3]
156
- expect(subject.generic_works).to eq [generic_work2, generic_work1]
157
- end
158
-
159
- it 'removes last collection' do
160
- expect(subject.collections.delete collection3).to eq [collection3]
161
- expect(subject.collections).to eq [collection1, collection2]
162
- expect(subject.generic_works). to eq [generic_work2, generic_work1]
163
- end
164
-
165
- it 'removes middle collection' do
166
- expect(subject.collections.delete collection2).to eq [collection2]
167
- expect(subject.collections).to eq [collection1, collection3]
168
- expect(subject.generic_works). to eq [generic_work2, generic_work1]
169
- end
170
- end
171
- end
172
-
173
- describe '#generic_works' do
37
+ describe '#works' do
174
38
  it 'returns empty array when only collections are aggregated' do
175
- subject.collections << collection1
176
- subject.collections << collection2
177
- expect(subject.generic_works). to eq []
39
+ subject.ordered_members << collection1
40
+ subject.ordered_members << collection2
41
+ expect(subject.ordered_works). to eq []
178
42
  end
179
43
 
180
44
  context 'with collections and generic works' do
181
45
  before do
182
- subject.collections << collection1
183
- subject.collections << collection2
184
- subject.generic_works << generic_work1
185
- subject.generic_works << generic_work2
46
+ subject.ordered_members << collection1
47
+ subject.ordered_members << collection2
48
+ subject.ordered_members << generic_work1
49
+ subject.ordered_members << generic_work2
186
50
  end
187
51
 
188
52
  it 'returns only generic works' do
189
- expect(subject.generic_works). to eq [generic_work1, generic_work2]
53
+ expect(subject.ordered_works). to eq [generic_work1, generic_work2]
190
54
  end
191
55
  end
192
56
  end
193
57
 
194
- describe '#generic_works <<' do
195
- context 'with acceptable generic_works' do
196
- context 'with collections and generic_works' do
197
- before do
198
- subject.collections << collection1
199
- subject.collections << collection2
200
- subject.generic_works << generic_work1
201
- subject.generic_works << generic_work2
202
- end
203
-
204
- it 'adds generic_work to collection with collections and generic_works' do
205
- subject.generic_works << generic_work3
206
- expect(subject.generic_works).to eq [generic_work1, generic_work2, generic_work3]
207
- end
208
- end
209
-
210
- describe 'aggregates generic_works that implement Hydra::Works' do
211
- before do
212
- class DummyIncWork < ActiveFedora::Base
213
- include Hydra::Works::GenericWorkBehavior
214
- end
215
- end
216
- after { Object.send(:remove_const, :DummyIncWork) }
217
- let(:iwork1) { DummyIncWork.new }
218
-
219
- it 'accepts implementing generic_work as a child' do
220
- subject.generic_works << iwork1
221
- expect(subject.generic_works).to eq [iwork1]
222
- end
223
- end
224
-
225
- describe 'aggregates generic_works that extend Hydra::Works' do
226
- before do
227
- class DummyExtWork < Hydra::Works::GenericWork::Base
228
- end
229
- end
230
- after { Object.send(:remove_const, :DummyExtWork) }
231
- let(:ework1) { DummyExtWork.new }
232
-
233
- it 'accepts extending generic_work as a child' do
234
- subject.generic_works << ework1
235
- expect(subject.generic_works).to eq [ework1]
236
- end
237
- end
238
- end
239
-
240
- context 'with unacceptable inputs' do
241
- before(:all) do
242
- @works_collection101 = described_class.new
243
- @works_collection102 = described_class.new
244
- @generic_file101 = Hydra::Works::GenericFile::Base.new
245
- @pcdm_collection101 = Hydra::PCDM::Collection.new
246
- @pcdm_object101 = Hydra::PCDM::Object.new
247
- @pcdm_file101 = Hydra::PCDM::File.new
248
- @non_pcdm_object = "I'm not a PCDM object"
249
- @af_base_object = ActiveFedora::Base.new
250
- end
251
-
252
- context 'that are unacceptable child generic works' do
253
- let(:error_type1) { ArgumentError }
254
- let(:error_message1) { /Hydra::Works::(GenericFile::Base|Collection) with ID: was expected to works_generic_work\?, but it was false/ }
255
- let(:error_type2) { NoMethodError }
256
- let(:error_message2) { /undefined method `works_generic_work\?' for .*/ }
257
-
258
- it 'does not aggregate Hydra::Works::Collection in generic works aggregation' do
259
- expect { subject.generic_works << @works_collection101 }.to raise_error(error_type1, error_message1)
260
- end
261
-
262
- it 'does not aggregate Hydra::Works::GenericFile in generic works aggregation' do
263
- expect { subject.generic_works << @generic_file101 }.to raise_error(error_type1, error_message1)
264
- end
265
-
266
- it 'does not aggregate Hydra::PCDM::Collections in generic works aggregation' do
267
- expect { subject.generic_works << @pcdm_collection101 }.to raise_error(error_type2, error_message2)
268
- end
269
-
270
- it 'does not aggregate Hydra::PCDM::Objects in generic works aggregation' do
271
- expect { subject.generic_works << @pcdm_object101 }.to raise_error(error_type2, error_message2)
272
- end
273
-
274
- it 'does not aggregate Hydra::PCDM::Files in generic works aggregation' do
275
- expect { subject.generic_works << @pcdm_file101 }.to raise_error(error_type2, error_message2)
276
- end
277
-
278
- it 'does not aggregate non-PCDM objects in generic works aggregation' do
279
- expect { subject.generic_works << @non_pcdm_object }.to raise_error(error_type2, error_message2)
280
- end
281
-
282
- it 'does not aggregate AF::Base objects in generic works aggregation' do
283
- expect { subject.generic_works << @af_base_object }.to raise_error(error_type2, error_message2)
284
- end
285
- end
286
- end
287
- end
288
-
289
- describe '#generic_works.delete' do
290
- context 'when multiple generic works' do
291
- before do
292
- subject.generic_works << generic_work1
293
- subject.generic_works << generic_work2
294
- subject.collections << collection2
295
- subject.generic_works << generic_work3
296
- subject.collections << collection1
297
- expect(subject.generic_works). to eq [generic_work1, generic_work2, generic_work3]
298
- end
299
-
300
- it 'removes first generic work' do
301
- expect(subject.generic_works.delete generic_work1).to eq [generic_work1]
302
- expect(subject.generic_works). to eq [generic_work2, generic_work3]
303
- expect(subject.collections).to eq [collection2, collection1]
304
- end
305
-
306
- it 'removes last generic work' do
307
- expect(subject.generic_works.delete generic_work3).to eq [generic_work3]
308
- expect(subject.generic_works). to eq [generic_work1, generic_work2]
309
- expect(subject.collections).to eq [collection2, collection1]
310
- end
311
-
312
- it 'removes middle generic work' do
313
- expect(subject.generic_works.delete generic_work2).to eq [generic_work2]
314
- expect(subject.generic_works). to eq [generic_work1, generic_work3]
315
- expect(subject.collections).to eq [collection2, collection1]
316
- end
58
+ describe "#ordered_work_ids" do
59
+ it "returns IDs of ordered works" do
60
+ subject.ordered_members << generic_work1
61
+ expect(subject.ordered_work_ids).to eq [generic_work1.id]
317
62
  end
318
63
  end
319
64
 
320
65
  describe '#related_objects' do
321
- let(:generic_file1) { Hydra::Works::GenericFile::Base.new }
66
+ let(:generic_file1) { Hydra::Works::FileSet.new }
322
67
  let(:object1) { Hydra::PCDM::Object.new }
323
68
  let(:object2) { Hydra::PCDM::Object.new }
324
69
 
325
70
  context 'with collections and generic works' do
326
71
  before do
327
- subject.collections << collection1
328
- subject.collections << collection2
329
- subject.generic_works << generic_work1
72
+ subject.ordered_members << collection1
73
+ subject.ordered_members << collection2
74
+ subject.ordered_members << generic_work1
330
75
  end
331
76
 
332
77
  it 'returns empty array when only collections and generic works are aggregated' do
@@ -356,7 +101,7 @@ describe Hydra::Works::Collection do
356
101
  context 'with acceptable related objects' do
357
102
  let(:object1) { Hydra::PCDM::Object.new }
358
103
  let(:object2) { Hydra::PCDM::Object.new }
359
- let(:generic_file1) { Hydra::Works::GenericFile::Base.new }
104
+ let(:generic_file1) { Hydra::Works::FileSet.new }
360
105
 
361
106
  it 'adds various types of related objects to collection' do
362
107
  subject.related_objects << generic_work1
@@ -370,16 +115,16 @@ describe Hydra::Works::Collection do
370
115
  expect(subject.related_objects.size).to eq 3
371
116
  end
372
117
 
373
- context 'with collections and generic_works' do
118
+ context 'with collections and works' do
374
119
  before do
375
- subject.collections << collection1
376
- subject.collections << collection2
377
- subject.generic_works << generic_work1
378
- subject.generic_works << generic_work2
120
+ subject.ordered_members << collection1
121
+ subject.ordered_members << collection2
122
+ subject.ordered_members << generic_work1
123
+ subject.ordered_members << generic_work2
379
124
  subject.related_objects << object1
380
125
  end
381
126
 
382
- it 'adds a related object to collection with collections and generic_works' do
127
+ it 'adds a related object to collection with collections and works' do
383
128
  subject.related_objects << object2
384
129
  subject.save
385
130
  subject.reload
@@ -437,20 +182,20 @@ describe Hydra::Works::Collection do
437
182
 
438
183
  describe '#related_objects.delete' do
439
184
  let(:related_object1) { Hydra::PCDM::Object.new }
440
- let(:related_work2) { Hydra::Works::GenericWork::Base.new }
441
- let(:related_file3) { Hydra::Works::GenericFile::Base.new }
185
+ let(:related_work2) { Hydra::Works::GenericWork.new }
186
+ let(:related_file3) { Hydra::Works::FileSet.new }
442
187
  let(:related_object4) { Hydra::PCDM::Object.new }
443
- let(:related_work5) { Hydra::Works::GenericWork::Base.new }
188
+ let(:related_work5) { Hydra::Works::GenericWork.new }
444
189
 
445
190
  context 'when multiple related objects' do
446
191
  before do
447
192
  subject.related_objects << related_object1
448
193
  subject.related_objects << related_work2
449
- subject.collections << collection2
450
- subject.generic_works << generic_work1
194
+ subject.members << collection2
195
+ subject.members << generic_work1
451
196
  subject.related_objects << related_file3
452
197
  subject.related_objects << related_object4
453
- subject.collections << collection1
198
+ subject.members << collection1
454
199
  subject.related_objects << related_work5
455
200
  expect(subject.related_objects).to eq [related_object1, related_work2, related_file3, related_object4, related_work5]
456
201
  end
@@ -459,39 +204,25 @@ describe Hydra::Works::Collection do
459
204
  expect(subject.related_objects.delete related_object1).to eq [related_object1]
460
205
  expect(subject.related_objects).to eq [related_work2, related_file3, related_object4, related_work5]
461
206
  expect(subject.collections).to eq [collection2, collection1]
462
- expect(subject.generic_works). to eq [generic_work1]
207
+ expect(subject.works). to eq [generic_work1]
463
208
  end
464
209
 
465
210
  it 'removes last related object' do
466
211
  expect(subject.related_objects.delete related_work5).to eq [related_work5]
467
212
  expect(subject.related_objects).to eq [related_object1, related_work2, related_file3, related_object4]
468
213
  expect(subject.collections).to eq [collection2, collection1]
469
- expect(subject.generic_works). to eq [generic_work1]
214
+ expect(subject.works). to eq [generic_work1]
470
215
  end
471
216
 
472
217
  it 'removes middle related object' do
473
218
  expect(subject.related_objects.delete related_file3).to eq [related_file3]
474
219
  expect(subject.related_objects).to eq [related_object1, related_work2, related_object4, related_work5]
475
220
  expect(subject.collections).to eq [collection2, collection1]
476
- expect(subject.generic_works). to eq [generic_work1]
221
+ expect(subject.works). to eq [generic_work1]
477
222
  end
478
223
  end
479
224
  end
480
225
 
481
- describe '#collections=' do
482
- it 'aggregates collections' do
483
- collection1.collections = [collection2, collection3]
484
- expect(collection1.collections).to eq [collection2, collection3]
485
- end
486
- end
487
-
488
- describe '#generic_works=' do
489
- it 'aggregates generic_works' do
490
- collection1.generic_works = [generic_work1, generic_work2]
491
- expect(collection1.generic_works).to eq [generic_work1, generic_work2]
492
- end
493
- end
494
-
495
226
  describe 'Related objects' do
496
227
  let(:object) { Hydra::PCDM::Object.new }
497
228
  let(:collection) { described_class.new }
@@ -507,7 +238,7 @@ describe Hydra::Works::Collection do
507
238
 
508
239
  describe 'should have parent collection accessors' do
509
240
  before do
510
- collection1.collections << collection2
241
+ collection1.ordered_members << collection2
511
242
  collection1.save
512
243
  end
513
244
 
@@ -521,16 +252,17 @@ describe Hydra::Works::Collection do
521
252
 
522
253
  describe 'make sure deprecated methods still work' do
523
254
  it 'deprecated methods should pass' do
524
- expect(collection1.child_collections = [collection2]).to eq [collection2]
525
- expect(collection1.child_collections << collection3).to eq [collection2, collection3]
526
- expect(collection1.child_collections += [collection4]).to eq [collection2, collection3, collection4]
527
- expect(collection1.child_generic_works = [generic_work1]).to eq [generic_work1]
528
- expect(collection1.child_generic_works << generic_work2).to eq [generic_work1, generic_work2]
529
- expect(collection1.child_generic_works += [generic_work3]).to eq [generic_work1, generic_work2, generic_work3]
530
- collection1.save # required until issue AF-Agg-75 is fixed
531
- expect(collection2.parent_collections).to eq [collection1]
532
- expect(collection2.parents).to eq [collection1]
533
- expect(collection2.parent_collection_ids).to eq [collection1.id]
255
+ Deprecation.silence(Hydra::Works::CollectionBehavior) do
256
+ collection1.ordered_members << collection2
257
+ collection1.ordered_members << generic_work1
258
+ expect(collection1.child_collections).to eq [collection2]
259
+ expect(collection1.child_collection_ids).to eq [collection2.id]
260
+ expect(collection1.child_generic_works).to eq [generic_work1]
261
+ expect(collection1.child_generic_work_ids).to eq [generic_work1.id]
262
+ collection1.save # required until issue AF-Agg-75 is fixed
263
+ expect(collection2.parent_collections).to eq [collection1]
264
+ expect(collection2.parents).to eq [collection1]
265
+ end
534
266
  end
535
267
  end
536
268
  end