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.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -8
- data/README.md +9 -9
- data/hydra-works.gemspec +3 -4
- data/lib/hydra/works.rb +22 -13
- data/lib/hydra/works/characterization.rb +31 -0
- data/lib/hydra/works/characterization/schema/audio_schema.rb +12 -0
- data/lib/hydra/works/characterization/schema/base_schema.rb +17 -0
- data/lib/hydra/works/characterization/schema/document_schema.rb +18 -0
- data/lib/hydra/works/characterization/schema/image_schema.rb +22 -0
- data/lib/hydra/works/characterization/schema/video_schema.rb +9 -0
- data/lib/hydra/works/models/characterization/already_there_strategy.rb +12 -0
- data/lib/hydra/works/models/characterization/fits_datastream.rb +162 -0
- data/lib/hydra/works/models/concerns/collection_behavior.rb +42 -34
- data/lib/hydra/works/models/concerns/file_set/characterization/audio.rb +14 -0
- data/lib/hydra/works/models/concerns/file_set/characterization/base.rb +23 -0
- data/lib/hydra/works/models/concerns/file_set/characterization/document.rb +10 -0
- data/lib/hydra/works/models/concerns/file_set/characterization/image.rb +10 -0
- data/lib/hydra/works/models/concerns/file_set/characterization/video.rb +17 -0
- data/lib/hydra/works/models/concerns/{generic_file → file_set}/contained_files.rb +1 -1
- data/lib/hydra/works/models/concerns/file_set/derivatives.rb +27 -0
- data/lib/hydra/works/models/concerns/{generic_file → file_set}/mime_types.rb +1 -1
- data/lib/hydra/works/models/concerns/{generic_file → file_set}/versioned_content.rb +2 -2
- data/lib/hydra/works/models/concerns/{generic_file → file_set}/virus_check.rb +1 -1
- data/lib/hydra/works/models/concerns/file_set_behavior.rb +67 -0
- data/lib/hydra/works/models/concerns/generic_file_behavior.rb +4 -50
- data/lib/hydra/works/models/concerns/generic_work_behavior.rb +5 -77
- data/lib/hydra/works/models/concerns/work_behavior.rb +118 -0
- data/lib/hydra/works/models/file_set.rb +7 -0
- data/lib/hydra/works/models/generic_file.rb +8 -8
- data/lib/hydra/works/models/generic_work.rb +15 -4
- data/lib/hydra/works/models/work.rb +6 -0
- data/lib/hydra/works/services/{generic_file/add_file_to_generic_file.rb → add_file_to_file_set.rb} +20 -20
- data/lib/hydra/works/services/add_file_to_generic_file.rb +8 -0
- data/lib/hydra/works/services/characterization_service.rb +118 -0
- data/lib/hydra/works/services/persist_derivative.rb +35 -0
- data/lib/hydra/works/services/{generic_file/upload_file_to_generic_file.rb → upload_file_to_file_set.rb} +3 -3
- data/lib/hydra/works/services/upload_file_to_generic_file.rb +8 -0
- data/lib/hydra/works/version.rb +1 -1
- data/lib/hydra/works/vocab/works_terms.rb +2 -2
- data/spec/fixtures/fits_0.6.2_avi.xml +29 -0
- data/spec/fixtures/fits_0.6.2_jp2.xml +36 -0
- data/spec/fixtures/fits_0.6.2_jpg.xml +43 -0
- data/spec/fixtures/fits_0.6.2_pdf.xml +42 -0
- data/spec/fixtures/fits_0.8.5_avi.xml +50 -0
- data/spec/fixtures/fits_0.8.5_docx.xml +41 -0
- data/spec/fixtures/fits_0.8.5_jp2.xml +51 -0
- data/spec/fixtures/fits_0.8.5_mp3.xml +47 -0
- data/spec/fixtures/fits_0.8.5_mp4.xml +47 -0
- data/spec/fixtures/fits_0.8.5_pdf.xml +54 -0
- data/spec/fixtures/pdf_fits.xml +54 -0
- data/spec/hydra/works/models/collection_spec.rb +58 -326
- data/spec/hydra/works/models/concerns/{generic_file → file_set}/contained_files_spec.rb +16 -16
- data/spec/hydra/works/models/concerns/{generic_file → file_set}/mime_types_spec.rb +2 -2
- data/spec/hydra/works/models/concerns/file_set/versioned_content_spec.rb +32 -0
- data/spec/hydra/works/models/concerns/{generic_file → file_set}/virus_check_spec.rb +3 -3
- data/spec/hydra/works/models/concerns/file_set_behavior_spec.rb +12 -0
- data/spec/hydra/works/models/generic_file_spec.rb +16 -13
- data/spec/hydra/works/models/generic_work_spec.rb +148 -318
- data/spec/hydra/works/services/{generic_file/add_file_to_generic_file_spec.rb → add_file_to_file_set_spec.rb} +4 -4
- data/spec/hydra/works/services/characterization_service_spec.rb +199 -0
- data/spec/hydra/works/services/persist_derivatives_spec.rb +57 -29
- data/spec/hydra/works/services/{generic_file/upload_file_spec.rb → upload_file_spec.rb} +7 -17
- data/spec/hydra/works_spec.rb +23 -59
- data/spec/spec_helper.rb +4 -2
- data/spec/support/file_set_helper.rb +14 -0
- metadata +84 -55
- data/lib/hydra/works/errors/full_text_extraction_error.rb +0 -5
- data/lib/hydra/works/models/concerns/block_child_objects.rb +0 -22
- data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +0 -26
- data/lib/hydra/works/services/generic_file/full_text_extraction_service.rb +0 -57
- data/lib/hydra/works/services/generic_file/generate_thumbnail.rb +0 -13
- data/lib/hydra/works/services/generic_file/persist_derivative.rb +0 -20
- data/spec/hydra/works/models/concerns/block_child_objects_spec.rb +0 -17
- data/spec/hydra/works/models/concerns/generic_file/versioned_content_spec.rb +0 -32
- data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +0 -12
- data/spec/hydra/works/services/full_text_extraction_service_spec.rb +0 -89
- data/spec/hydra/works/services/generic_file/generate/thumbnail_spec.rb +0 -19
@@ -1,29 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Hydra::Works::
|
4
|
-
let(:
|
5
|
-
Hydra::Works::
|
3
|
+
describe Hydra::Works::ContainedFiles do
|
4
|
+
let(:file_set) do
|
5
|
+
Hydra::Works::FileSet.create
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:thumbnail) do
|
9
|
-
file =
|
9
|
+
file = file_set.files.build
|
10
10
|
Hydra::PCDM::AddTypeToFile.call(file, pcdm_thumbnail_uri)
|
11
11
|
end
|
12
12
|
|
13
|
-
let(:file) {
|
13
|
+
let(:file) { file_set.files.build }
|
14
14
|
let(:pcdm_thumbnail_uri) { ::RDF::URI('http://pcdm.org/use#ThumbnailImage') }
|
15
15
|
|
16
16
|
before do
|
17
|
-
|
17
|
+
file_set.files = [file]
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#thumbnail' do
|
21
21
|
context 'when a thumbnail is present' do
|
22
22
|
before do
|
23
|
-
original_file =
|
23
|
+
original_file = file_set.build_thumbnail
|
24
24
|
original_file.content = 'thumbnail'
|
25
25
|
end
|
26
|
-
subject {
|
26
|
+
subject { file_set.thumbnail }
|
27
27
|
it 'can be saved without errors' do
|
28
28
|
expect(subject.save).to be_truthy
|
29
29
|
end
|
@@ -37,7 +37,7 @@ describe Hydra::Works::GenericFile::ContainedFiles do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'when building new thumbnail' do
|
40
|
-
subject {
|
40
|
+
subject { file_set.build_thumbnail }
|
41
41
|
it 'initializes an unsaved File object with Thumbnail type' do
|
42
42
|
expect(subject).to be_new_record
|
43
43
|
expect(subject.metadata_node.type).to include(pcdm_thumbnail_uri)
|
@@ -49,10 +49,10 @@ describe Hydra::Works::GenericFile::ContainedFiles do
|
|
49
49
|
describe '#original_file' do
|
50
50
|
context 'when an original file is present' do
|
51
51
|
before do
|
52
|
-
original_file =
|
52
|
+
original_file = file_set.build_original_file
|
53
53
|
original_file.content = 'original_file'
|
54
54
|
end
|
55
|
-
subject {
|
55
|
+
subject { file_set.original_file }
|
56
56
|
|
57
57
|
it 'can be saved without errors' do
|
58
58
|
expect(subject.save).to be_truthy
|
@@ -63,12 +63,12 @@ describe Hydra::Works::GenericFile::ContainedFiles do
|
|
63
63
|
end
|
64
64
|
it 'retains origin pcdm.File RDF type' do
|
65
65
|
expect(subject.metadata_node.type).to include(::RDF::URI('http://pcdm.org/use#OriginalFile'))
|
66
|
-
expect(
|
66
|
+
expect(file_set.original_file.metadata_node.type).to include(Hydra::PCDM::Vocab::PCDMTerms.File)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
context 'when building original file' do
|
71
|
-
subject {
|
71
|
+
subject { file_set.build_original_file }
|
72
72
|
it 'initializes an unsaved File object with OrignalFile type' do
|
73
73
|
expect(subject).to be_new_record
|
74
74
|
expect(subject.metadata_node.type).to include(::RDF::URI('http://pcdm.org/use#OriginalFile'))
|
@@ -80,10 +80,10 @@ describe Hydra::Works::GenericFile::ContainedFiles do
|
|
80
80
|
describe '#extracted_text' do
|
81
81
|
context 'when extracted text is present' do
|
82
82
|
before do
|
83
|
-
extracted_text =
|
83
|
+
extracted_text = file_set.build_extracted_text
|
84
84
|
extracted_text.content = 'extracted_text'
|
85
85
|
end
|
86
|
-
subject {
|
86
|
+
subject { file_set.extracted_text }
|
87
87
|
it 'can be saved without errors' do
|
88
88
|
expect(subject.save).to be_truthy
|
89
89
|
end
|
@@ -97,7 +97,7 @@ describe Hydra::Works::GenericFile::ContainedFiles do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
context 'when building new extracted text object' do
|
100
|
-
subject {
|
100
|
+
subject { file_set.build_extracted_text }
|
101
101
|
it 'initializes an unsaved File object with ExtractedText type' do
|
102
102
|
expect(subject).to be_new_record
|
103
103
|
expect(subject.metadata_node.type).to include(::RDF::URI('http://pcdm.org/use#ExtractedText'))
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::VersionedContent do
|
4
|
+
let(:file_set) { Hydra::Works::FileSet.new }
|
5
|
+
before do
|
6
|
+
Hydra::Works::UploadFileToFileSet.call(file_set, File.open(File.join(fixture_path, 'sample-file.pdf')))
|
7
|
+
Hydra::Works::UploadFileToFileSet.call(file_set, File.open(File.join(fixture_path, 'updated-file.txt')))
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'content_versions' do
|
11
|
+
subject { file_set.content_versions }
|
12
|
+
it 'lists all of the versions of original_file' do
|
13
|
+
expect(subject.count).to eq(2)
|
14
|
+
expect(subject.map(&:uri)).to eq(file_set.original_file.versions.all.map(&:uri))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'latest_content_version' do
|
19
|
+
subject { file_set.latest_content_version }
|
20
|
+
it 'returns the most recent version entry for original_file' do
|
21
|
+
# Can't use a simple equivalence because they are actually different ResourceVersion objects
|
22
|
+
expect(subject.uri).to eq(file_set.original_file.versions.last.uri)
|
23
|
+
expect(subject.label).to eq(file_set.original_file.versions.last.label)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'current_content_version_uri' do
|
28
|
+
it 'returns the URI of the most recent version of original_file' do
|
29
|
+
expect(file_set.current_content_version_uri).to eq(file_set.original_file.versions.last.uri)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Hydra::Works::
|
3
|
+
describe Hydra::Works::VirusCheck do
|
4
4
|
before do
|
5
5
|
class FileWithVirusCheck < ActiveFedora::Base
|
6
|
-
include Hydra::Works::
|
7
|
-
include Hydra::Works::
|
6
|
+
include Hydra::Works::FileSetBehavior
|
7
|
+
include Hydra::Works::VirusCheck
|
8
8
|
end
|
9
9
|
class ClamAV
|
10
10
|
def self.instance
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::FileSetBehavior do
|
4
|
+
class IncludesFileSetBehavior < ActiveFedora::Base
|
5
|
+
include Hydra::Works::FileSetBehavior
|
6
|
+
end
|
7
|
+
subject { IncludesFileSetBehavior.new }
|
8
|
+
|
9
|
+
it 'ensures that objects will be recognized as file_sets' do
|
10
|
+
expect(subject).to be_file_set
|
11
|
+
end
|
12
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Hydra::Works::
|
3
|
+
describe Hydra::Works::FileSet do
|
4
4
|
let(:generic_file1) { described_class.new }
|
5
5
|
|
6
6
|
describe 'Related objects' do
|
@@ -38,8 +38,8 @@ describe Hydra::Works::GenericFile::Base do
|
|
38
38
|
context 'with acceptable related objects' do
|
39
39
|
let(:object1) { Hydra::PCDM::Object.create }
|
40
40
|
let(:object2) { Hydra::PCDM::Object.new }
|
41
|
-
let(:generic_work1) { Hydra::Works::GenericWork
|
42
|
-
let(:generic_work2) { Hydra::Works::GenericWork
|
41
|
+
let(:generic_work1) { Hydra::Works::GenericWork.create }
|
42
|
+
let(:generic_work2) { Hydra::Works::GenericWork.new }
|
43
43
|
let(:generic_file1) { described_class.create }
|
44
44
|
|
45
45
|
it 'adds various types of related objects to generic_file' do
|
@@ -135,7 +135,7 @@ describe Hydra::Works::GenericFile::Base do
|
|
135
135
|
let(:object1) { Hydra::PCDM::Object.new }
|
136
136
|
let(:object2) { Hydra::PCDM::Object.new }
|
137
137
|
|
138
|
-
let(:generic_work1) { Hydra::Works::GenericWork
|
138
|
+
let(:generic_work1) { Hydra::Works::GenericWork.new }
|
139
139
|
let(:generic_file1) { described_class.new }
|
140
140
|
|
141
141
|
context 'with generic files' do
|
@@ -167,10 +167,10 @@ describe Hydra::Works::GenericFile::Base do
|
|
167
167
|
subject { described_class.new }
|
168
168
|
|
169
169
|
let(:related_object1) { Hydra::PCDM::Object.new }
|
170
|
-
let(:related_work2) { Hydra::Works::GenericWork
|
170
|
+
let(:related_work2) { Hydra::Works::GenericWork.new }
|
171
171
|
let(:related_file3) { described_class.new }
|
172
172
|
let(:related_object4) { Hydra::PCDM::Object.new }
|
173
|
-
let(:related_work5) { Hydra::Works::GenericWork
|
173
|
+
let(:related_work5) { Hydra::Works::GenericWork.new }
|
174
174
|
|
175
175
|
let(:generic_file1) { described_class.new }
|
176
176
|
let(:generic_file2) { described_class.new }
|
@@ -207,28 +207,31 @@ describe Hydra::Works::GenericFile::Base do
|
|
207
207
|
end
|
208
208
|
|
209
209
|
describe 'should have parent work accessors' do
|
210
|
-
let(:generic_work1) { Hydra::Works::GenericWork
|
210
|
+
let(:generic_work1) { Hydra::Works::GenericWork.create }
|
211
211
|
before do
|
212
|
-
generic_work1.
|
212
|
+
generic_work1.ordered_members << generic_file1
|
213
|
+
generic_work1.save
|
213
214
|
end
|
214
215
|
|
215
216
|
it 'has parents' do
|
216
217
|
expect(generic_file1.member_of).to eq [generic_work1]
|
217
218
|
end
|
218
219
|
it 'has a parent work' do
|
219
|
-
expect(generic_file1.
|
220
|
+
expect(generic_file1.in_works).to eq [generic_work1]
|
220
221
|
end
|
221
222
|
end
|
222
223
|
|
223
224
|
describe 'make sure deprecated methods still work' do
|
224
|
-
let(:generic_work1) { Hydra::Works::GenericWork
|
225
|
+
let(:generic_work1) { Hydra::Works::GenericWork.create }
|
225
226
|
before do
|
226
|
-
generic_work1.
|
227
|
+
generic_work1.ordered_members << generic_file1
|
227
228
|
generic_work1.save # required until issue AF-Agg-75 is fixed
|
228
229
|
end
|
229
230
|
it 'deprecated methods should pass' do
|
230
|
-
|
231
|
-
|
231
|
+
Deprecation.silence(Hydra::Works::GenericFileBehavior) do
|
232
|
+
expect(generic_file1.generic_works).to eq [generic_work1]
|
233
|
+
expect(generic_file1.parents).to eq [generic_work1]
|
234
|
+
end
|
232
235
|
end
|
233
236
|
end
|
234
237
|
end
|
@@ -1,58 +1,82 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hydra::Works::GenericWork do
|
4
|
-
subject {
|
4
|
+
subject { described_class.new }
|
5
5
|
|
6
|
-
let(:generic_work1) {
|
7
|
-
let(:generic_work2) {
|
8
|
-
let(:generic_work3) {
|
9
|
-
let(:generic_work4) {
|
10
|
-
let(:generic_work5) {
|
6
|
+
let(:generic_work1) { described_class.new }
|
7
|
+
let(:generic_work2) { described_class.new }
|
8
|
+
let(:generic_work3) { described_class.new }
|
9
|
+
let(:generic_work4) { described_class.new }
|
10
|
+
let(:generic_work5) { described_class.new }
|
11
11
|
|
12
|
-
let(:
|
13
|
-
let(:
|
12
|
+
let(:file_set1) { Hydra::Works::FileSet.new }
|
13
|
+
let(:file_set2) { Hydra::Works::FileSet.new }
|
14
14
|
|
15
15
|
let(:object1) { Hydra::PCDM::Object.new }
|
16
16
|
let(:object2) { Hydra::PCDM::Object.new }
|
17
17
|
|
18
18
|
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
19
19
|
|
20
|
-
describe
|
21
|
-
it
|
22
|
-
generic_work1.
|
23
|
-
|
20
|
+
describe "#file_set_ids" do
|
21
|
+
it "returns non-ordered file set IDs" do
|
22
|
+
generic_work1.members << file_set1
|
23
|
+
generic_work1.ordered_members << file_set2
|
24
|
+
|
25
|
+
expect(generic_work1.file_set_ids).to eq [file_set1.id, file_set2.id]
|
26
|
+
expect(generic_work1.ordered_file_set_ids).to eq [file_set2.id]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#file_sets" do
|
31
|
+
it "returns non-ordered file sets" do
|
32
|
+
generic_work1.members << file_set1
|
33
|
+
generic_work1.ordered_members << file_set2
|
34
|
+
|
35
|
+
expect(generic_work1.file_sets).to eq [file_set1, file_set2]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#work_ids" do
|
40
|
+
it "returns non-ordered file set IDs" do
|
41
|
+
generic_work1.members << generic_work2
|
42
|
+
generic_work1.ordered_members << generic_work3
|
43
|
+
|
44
|
+
expect(generic_work1.work_ids).to eq [generic_work2.id, generic_work3.id]
|
45
|
+
expect(generic_work1.ordered_work_ids).to eq [generic_work3.id]
|
24
46
|
end
|
25
47
|
end
|
26
48
|
|
27
|
-
describe
|
28
|
-
it
|
29
|
-
generic_work1.
|
30
|
-
|
49
|
+
describe "#works" do
|
50
|
+
it "returns non-ordered file sets" do
|
51
|
+
generic_work1.members << generic_work2
|
52
|
+
generic_work1.ordered_members << generic_work3
|
53
|
+
|
54
|
+
expect(generic_work1.works).to eq [generic_work2, generic_work3]
|
31
55
|
end
|
32
56
|
end
|
33
57
|
|
34
|
-
describe '#
|
35
|
-
it 'lists
|
36
|
-
generic_work1.
|
37
|
-
expect(generic_work1.
|
58
|
+
describe '#ordered_file_set_ids' do
|
59
|
+
it 'lists file_set ids' do
|
60
|
+
generic_work1.ordered_members = [file_set1, file_set2]
|
61
|
+
expect(generic_work1.ordered_file_set_ids).to eq [file_set1.id, file_set2.id]
|
38
62
|
end
|
39
63
|
end
|
40
64
|
|
41
65
|
context 'sub-class' do
|
42
66
|
before do
|
43
|
-
class TestWork < Hydra::Works::GenericWork
|
67
|
+
class TestWork < Hydra::Works::GenericWork
|
44
68
|
end
|
45
69
|
end
|
46
70
|
|
47
|
-
subject { TestWork.new(
|
71
|
+
subject { TestWork.new(ordered_members: [file_set1]) }
|
48
72
|
|
49
73
|
it 'has many generic files' do
|
50
|
-
expect(subject.
|
74
|
+
expect(subject.ordered_file_sets).to eq [file_set1]
|
51
75
|
end
|
52
76
|
end
|
53
77
|
|
54
78
|
describe 'Related objects' do
|
55
|
-
let(:generic_work1) {
|
79
|
+
let(:generic_work1) { described_class.new }
|
56
80
|
let(:object1) { Hydra::PCDM::Object.new }
|
57
81
|
|
58
82
|
before do
|
@@ -64,249 +88,48 @@ describe Hydra::Works::GenericWork do
|
|
64
88
|
end
|
65
89
|
end
|
66
90
|
|
67
|
-
describe '#
|
68
|
-
context 'with acceptable
|
69
|
-
context 'with
|
91
|
+
describe '#ordered_works' do
|
92
|
+
context 'with acceptable works' do
|
93
|
+
context 'with file_sets and works' do
|
70
94
|
before do
|
71
|
-
subject.
|
72
|
-
subject.
|
73
|
-
subject.
|
74
|
-
subject.
|
95
|
+
subject.ordered_members << file_set1
|
96
|
+
subject.ordered_members << file_set2
|
97
|
+
subject.ordered_members << generic_work1
|
98
|
+
subject.ordered_members << generic_work2
|
75
99
|
end
|
76
100
|
|
77
|
-
it 'adds generic_work to generic_work with
|
78
|
-
subject.
|
79
|
-
expect(subject.
|
101
|
+
it 'adds generic_work to generic_work with file_sets and works' do
|
102
|
+
subject.ordered_members << generic_work3
|
103
|
+
expect(subject.ordered_works).to eq [generic_work1, generic_work2, generic_work3]
|
80
104
|
end
|
81
105
|
end
|
82
106
|
|
83
|
-
describe 'aggregates
|
107
|
+
describe 'aggregates works that implement Hydra::Works::WorkBehavior' do
|
84
108
|
before do
|
85
109
|
class DummyIncWork < ActiveFedora::Base
|
86
|
-
include Hydra::Works::
|
110
|
+
include Hydra::Works::WorkBehavior
|
87
111
|
end
|
88
112
|
end
|
89
113
|
after { Object.send(:remove_const, :DummyIncWork) }
|
90
114
|
let(:iwork1) { DummyIncWork.new }
|
91
115
|
|
92
116
|
it 'accepts implementing generic_work as a child' do
|
93
|
-
subject.
|
94
|
-
expect(subject.
|
117
|
+
subject.ordered_members << iwork1
|
118
|
+
expect(subject.ordered_works).to eq [iwork1]
|
95
119
|
end
|
96
120
|
end
|
97
121
|
|
98
|
-
describe 'aggregates
|
122
|
+
describe 'aggregates works that extend Hydra::Works::GenericWork' do
|
99
123
|
before do
|
100
|
-
class DummyExtWork < Hydra::Works::GenericWork
|
124
|
+
class DummyExtWork < Hydra::Works::GenericWork
|
101
125
|
end
|
102
126
|
end
|
103
127
|
after { Object.send(:remove_const, :DummyExtWork) }
|
104
128
|
let(:ework1) { DummyExtWork.new }
|
105
129
|
|
106
130
|
it 'accepts extending generic_work as a child' do
|
107
|
-
subject.
|
108
|
-
expect(subject.
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context 'with unacceptable inputs' do
|
114
|
-
before(:all) do
|
115
|
-
@generic_work102 = Hydra::Works::GenericWork::Base.new
|
116
|
-
|
117
|
-
@works_collection101 = Hydra::Works::Collection.new
|
118
|
-
@generic_file101 = Hydra::Works::GenericFile::Base.new
|
119
|
-
@pcdm_collection101 = Hydra::PCDM::Collection.new
|
120
|
-
@pcdm_object101 = Hydra::PCDM::Object.new
|
121
|
-
@pcdm_file101 = Hydra::PCDM::File.new
|
122
|
-
@non_pcdm_object = "I'm not a PCDM object"
|
123
|
-
@af_base_object = ActiveFedora::Base.new
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'that are unacceptable child generic works' do
|
127
|
-
let(:error_type1) { ArgumentError }
|
128
|
-
let(:error_message1) { /Hydra::Works::(GenericFile::Base|Collection) with ID: was expected to works_generic_work\?, but it was false/ }
|
129
|
-
let(:error_type2) { NoMethodError }
|
130
|
-
let(:error_message2) { /undefined method `works_generic_work\?' for .*/ }
|
131
|
-
|
132
|
-
it 'does not aggregate Hydra::Works::Collection in generic works aggregation' do
|
133
|
-
expect { subject.generic_works << @works_collection101 }.to raise_error(error_type1, error_message1)
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'does not aggregate Hydra::Works::GenericFile in generic works aggregation' do
|
137
|
-
expect { subject.generic_works << @generic_file101 }.to raise_error(error_type1, error_message1)
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'does not aggregate Hydra::PCDM::Collections in generic works aggregation' do
|
141
|
-
expect { subject.generic_works << @pcdm_collection101 }.to raise_error(error_type2, error_message2)
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'does not aggregate Hydra::PCDM::Objects in generic works aggregation' do
|
145
|
-
expect { subject.generic_works << @pcdm_object101 }.to raise_error(error_type2, error_message2)
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'does not aggregate Hydra::PCDM::Files in generic works aggregation' do
|
149
|
-
expect { subject.generic_works << @pcdm_file101 }.to raise_error(error_type2, error_message2)
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'does not aggregate non-PCDM objects in generic works aggregation' do
|
153
|
-
expect { subject.generic_works << @non_pcdm_object }.to raise_error(error_type2, error_message2)
|
154
|
-
end
|
155
|
-
|
156
|
-
it 'does not aggregate AF::Base objects in generic works aggregation' do
|
157
|
-
expect { subject.generic_works << @af_base_object }.to raise_error(error_type2, error_message2)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe '#generic_files <<' do
|
164
|
-
it 'returns empty array when only generic_files are aggregated' do
|
165
|
-
subject.generic_files << generic_file1
|
166
|
-
subject.generic_files << generic_file2
|
167
|
-
expect(subject.generic_works).to eq []
|
168
|
-
end
|
169
|
-
|
170
|
-
context 'with generic_files and generic_works' do
|
171
|
-
before do
|
172
|
-
subject.generic_files << generic_file1
|
173
|
-
subject.generic_files << generic_file2
|
174
|
-
subject.generic_works << generic_work1
|
175
|
-
subject.generic_works << generic_work2
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'returns only generic_works' do
|
179
|
-
expect(subject.generic_works).to eq [generic_work1, generic_work2]
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe '#generic_works.delete' do
|
185
|
-
context 'when multiple collections' do
|
186
|
-
before do
|
187
|
-
subject.generic_works << generic_work1
|
188
|
-
subject.generic_works << generic_work2
|
189
|
-
subject.generic_files << generic_file2
|
190
|
-
subject.generic_works << generic_work3
|
191
|
-
subject.generic_works << generic_work4
|
192
|
-
subject.generic_files << generic_file1
|
193
|
-
subject.generic_works << generic_work5
|
194
|
-
expect(subject.generic_works).to eq [generic_work1, generic_work2, generic_work3, generic_work4, generic_work5]
|
195
|
-
end
|
196
|
-
|
197
|
-
it 'removes first collection' do
|
198
|
-
expect(subject.generic_works.delete generic_work1).to eq [generic_work1]
|
199
|
-
expect(subject.generic_works).to eq [generic_work2, generic_work3, generic_work4, generic_work5]
|
200
|
-
expect(subject.generic_files).to eq [generic_file2, generic_file1]
|
201
|
-
end
|
202
|
-
|
203
|
-
it 'removes last collection' do
|
204
|
-
expect(subject.generic_works.delete generic_work5).to eq [generic_work5]
|
205
|
-
expect(subject.generic_works).to eq [generic_work1, generic_work2, generic_work3, generic_work4]
|
206
|
-
expect(subject.generic_files).to eq [generic_file2, generic_file1]
|
207
|
-
end
|
208
|
-
|
209
|
-
it 'removes middle collection' do
|
210
|
-
expect(subject.generic_works.delete generic_work3).to eq [generic_work3]
|
211
|
-
expect(subject.generic_works).to eq [generic_work1, generic_work2, generic_work4, generic_work5]
|
212
|
-
expect(subject.generic_files).to eq [generic_file2, generic_file1]
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
describe '#generic_works <<' do
|
218
|
-
context 'with acceptable generic_works' do
|
219
|
-
context 'with generic_files and generic_works' do
|
220
|
-
let(:generic_file3) { Hydra::Works::GenericFile::Base.new }
|
221
|
-
before do
|
222
|
-
subject.generic_files << generic_file1
|
223
|
-
subject.generic_files << generic_file2
|
224
|
-
subject.generic_works << generic_work1
|
225
|
-
subject.generic_works << generic_work2
|
226
|
-
end
|
227
|
-
|
228
|
-
it 'adds generic_file to generic_work with generic_files and generic_works' do
|
229
|
-
subject.generic_files << generic_file3
|
230
|
-
expect(subject.generic_files).to eq [generic_file1, generic_file2, generic_file3]
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
describe 'aggregates generic_files that implement Hydra::Works::GenericFileBehavior' do
|
235
|
-
before do
|
236
|
-
class DummyIncFile < ActiveFedora::Base
|
237
|
-
include Hydra::Works::GenericFileBehavior
|
238
|
-
end
|
239
|
-
end
|
240
|
-
after { Object.send(:remove_const, :DummyIncFile) }
|
241
|
-
let(:ifile1) { DummyIncFile.new }
|
242
|
-
|
243
|
-
it 'accepts implementing generic_file as a child' do
|
244
|
-
subject.generic_files << ifile1
|
245
|
-
expect(subject.generic_files).to eq [ifile1]
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
describe 'aggregates generic_files that extend Hydra::Works::GenericFile::Base' do
|
250
|
-
before do
|
251
|
-
class DummyExtFile < Hydra::Works::GenericFile::Base
|
252
|
-
end
|
253
|
-
end
|
254
|
-
after { Object.send(:remove_const, :DummyExtFile) }
|
255
|
-
let(:efile1) { DummyExtFile.new }
|
256
|
-
|
257
|
-
it 'accepts extending generic_file as a child' do
|
258
|
-
subject.generic_files << efile1
|
259
|
-
expect(subject.generic_files).to eq [efile1]
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
context 'with unacceptable inputs' do
|
265
|
-
before(:all) do
|
266
|
-
@generic_work102 = Hydra::Works::GenericWork::Base.new
|
267
|
-
|
268
|
-
@works_collection101 = Hydra::Works::Collection.new
|
269
|
-
@generic_work101 = Hydra::Works::GenericWork::Base.new
|
270
|
-
@generic_file101 = Hydra::Works::GenericFile::Base.new
|
271
|
-
@pcdm_collection101 = Hydra::PCDM::Collection.new
|
272
|
-
@pcdm_object101 = Hydra::PCDM::Object.new
|
273
|
-
@pcdm_file101 = Hydra::PCDM::File.new
|
274
|
-
@non_pcdm_object = "I'm not a PCDM object"
|
275
|
-
@af_base_object = ActiveFedora::Base.new
|
276
|
-
end
|
277
|
-
|
278
|
-
context 'that are unacceptable child generic files' do
|
279
|
-
let(:error_type1) { ArgumentError }
|
280
|
-
let(:error_message1) { /Hydra::Works::(GenericWork::Base|Collection) with ID: was expected to works_generic_file\?, but it was false/ }
|
281
|
-
let(:error_type2) { NoMethodError }
|
282
|
-
let(:error_message2) { /undefined method `works_generic_file\?' for .*/ }
|
283
|
-
|
284
|
-
it 'does not aggregate Hydra::Works::Collection in generic files aggregation' do
|
285
|
-
expect { subject.generic_files << @works_collection101 }.to raise_error(error_type1, error_message1)
|
286
|
-
end
|
287
|
-
|
288
|
-
it 'does not aggregate Hydra::Works::GenericWork in generic files aggregation' do
|
289
|
-
expect { subject.generic_files << @generic_work101 }.to raise_error(error_type1, error_message1)
|
290
|
-
end
|
291
|
-
|
292
|
-
it 'does not aggregate Hydra::PCDM::Collections in generic files aggregation' do
|
293
|
-
expect { subject.generic_files << @pcdm_collection101 }.to raise_error(error_type2, error_message2)
|
294
|
-
end
|
295
|
-
|
296
|
-
it 'does not aggregate Hydra::PCDM::Objects in generic files aggregation' do
|
297
|
-
expect { subject.generic_files << @pcdm_object101 }.to raise_error(error_type2, error_message2)
|
298
|
-
end
|
299
|
-
|
300
|
-
it 'does not aggregate Hydra::PCDM::Files in generic files aggregation' do
|
301
|
-
expect { subject.generic_files << @pcdm_file101 }.to raise_error(error_type2, error_message2)
|
302
|
-
end
|
303
|
-
|
304
|
-
it 'does not aggregate non-PCDM objects in generic files aggregation' do
|
305
|
-
expect { subject.generic_files << @non_pcdm_object }.to raise_error(error_type2, error_message2)
|
306
|
-
end
|
307
|
-
|
308
|
-
it 'does not aggregate AF::Base objects in generic files aggregation' do
|
309
|
-
expect { subject.generic_files << @af_base_object }.to raise_error(error_type2, error_message2)
|
131
|
+
subject.ordered_members << ework1
|
132
|
+
expect(subject.ordered_works).to eq [ework1]
|
310
133
|
end
|
311
134
|
end
|
312
135
|
end
|
@@ -314,71 +137,72 @@ describe Hydra::Works::GenericWork do
|
|
314
137
|
|
315
138
|
context 'move generic file' do
|
316
139
|
before do
|
317
|
-
subject.
|
318
|
-
subject.
|
140
|
+
subject.ordered_members << file_set1
|
141
|
+
subject.ordered_members << file_set2
|
319
142
|
end
|
320
143
|
it 'moves file from one work to another' do
|
321
|
-
expect(subject.
|
322
|
-
expect(generic_work1.
|
323
|
-
|
324
|
-
|
325
|
-
expect(
|
144
|
+
expect(subject.ordered_file_sets).to eq([file_set1, file_set2])
|
145
|
+
expect(generic_work1.ordered_file_sets).to eq([])
|
146
|
+
subject.ordered_member_proxies.delete_at(0)
|
147
|
+
generic_work1.ordered_members << file_set1
|
148
|
+
expect(subject.ordered_file_sets).to eq([file_set2])
|
149
|
+
expect(generic_work1.ordered_file_sets).to eq([file_set1])
|
326
150
|
end
|
327
151
|
end
|
328
152
|
|
329
|
-
describe '#
|
330
|
-
it 'returns empty array when only
|
331
|
-
subject.
|
332
|
-
subject.
|
333
|
-
expect(subject.
|
153
|
+
describe '#file_sets' do
|
154
|
+
it 'returns empty array when only works are aggregated' do
|
155
|
+
subject.ordered_members << generic_work1
|
156
|
+
subject.ordered_members << generic_work2
|
157
|
+
expect(subject.ordered_file_sets).to eq []
|
334
158
|
end
|
335
159
|
|
336
|
-
context 'with
|
160
|
+
context 'with file_sets and works' do
|
337
161
|
before do
|
338
|
-
subject.
|
339
|
-
subject.
|
340
|
-
subject.
|
341
|
-
subject.
|
162
|
+
subject.ordered_members << file_set1
|
163
|
+
subject.ordered_members << file_set2
|
164
|
+
subject.ordered_members << generic_work1
|
165
|
+
subject.ordered_members << generic_work2
|
342
166
|
end
|
343
167
|
|
344
|
-
it 'returns only
|
345
|
-
expect(subject.
|
168
|
+
it 'returns only file_sets' do
|
169
|
+
expect(subject.ordered_file_sets).to eq [file_set1, file_set2]
|
346
170
|
end
|
347
171
|
end
|
348
172
|
end
|
349
173
|
|
350
|
-
describe '#
|
174
|
+
describe '#file_sets.delete' do
|
351
175
|
context 'when multiple collections' do
|
352
|
-
let(:
|
353
|
-
let(:
|
354
|
-
let(:
|
176
|
+
let(:file_set3) { Hydra::Works::FileSet.new }
|
177
|
+
let(:file_set4) { Hydra::Works::FileSet.new }
|
178
|
+
let(:file_set5) { Hydra::Works::FileSet.new }
|
355
179
|
before do
|
356
|
-
subject.
|
357
|
-
subject.
|
358
|
-
subject.
|
359
|
-
subject.
|
360
|
-
subject.
|
361
|
-
subject.
|
362
|
-
subject.
|
363
|
-
expect(subject.
|
180
|
+
subject.ordered_members << file_set1
|
181
|
+
subject.ordered_members << file_set2
|
182
|
+
subject.ordered_members << generic_work2
|
183
|
+
subject.ordered_members << file_set3
|
184
|
+
subject.ordered_members << file_set4
|
185
|
+
subject.ordered_members << generic_work1
|
186
|
+
subject.ordered_members << file_set5
|
187
|
+
expect(subject.ordered_file_sets).to eq [file_set1, file_set2, file_set3, file_set4, file_set5]
|
364
188
|
end
|
365
189
|
|
366
190
|
it 'removes first collection' do
|
367
|
-
|
368
|
-
expect(subject.
|
369
|
-
expect(subject.
|
191
|
+
subject.ordered_member_proxies.delete_at(0)
|
192
|
+
expect(subject.ordered_file_sets).to eq [file_set2, file_set3, file_set4, file_set5]
|
193
|
+
expect(subject.ordered_works).to eq [generic_work2, generic_work1]
|
370
194
|
end
|
371
195
|
|
372
196
|
it 'removes last collection' do
|
373
|
-
|
374
|
-
expect(subject.
|
375
|
-
expect(subject.
|
197
|
+
subject.ordered_member_proxies.delete_at(6)
|
198
|
+
expect(subject.ordered_file_sets).to eq [file_set1, file_set2, file_set3, file_set4]
|
199
|
+
expect(subject.ordered_works).to eq [generic_work2, generic_work1]
|
376
200
|
end
|
377
201
|
|
378
202
|
it 'removes middle collection' do
|
379
|
-
|
380
|
-
expect(subject.
|
381
|
-
expect(subject.
|
203
|
+
subject.ordered_member_proxies.delete_at(3)
|
204
|
+
expect(subject.ordered_file_sets).to eq [file_set1, file_set2, file_set4, file_set5]
|
205
|
+
expect(subject.ordered_works).to eq [generic_work2, generic_work1]
|
382
206
|
end
|
383
207
|
end
|
384
208
|
end
|
@@ -387,26 +211,26 @@ describe Hydra::Works::GenericWork do
|
|
387
211
|
context 'with acceptable related objects' do
|
388
212
|
it 'adds various types of related objects to generic_work' do
|
389
213
|
subject.related_objects << generic_work1
|
390
|
-
subject.related_objects <<
|
214
|
+
subject.related_objects << file_set1
|
391
215
|
subject.related_objects << object1
|
392
216
|
subject.save
|
393
217
|
subject.reload
|
394
218
|
expect(subject.related_objects.include? generic_work1).to be true
|
395
|
-
expect(subject.related_objects.include?
|
219
|
+
expect(subject.related_objects.include? file_set1).to be true
|
396
220
|
expect(subject.related_objects.include? object1).to be true
|
397
221
|
expect(subject.related_objects.size).to eq 3
|
398
222
|
end
|
399
223
|
|
400
|
-
context 'with
|
224
|
+
context 'with works and file_sets' do
|
401
225
|
before do
|
402
|
-
subject.
|
403
|
-
subject.
|
404
|
-
subject.
|
405
|
-
subject.
|
226
|
+
subject.ordered_file_sets << file_set1
|
227
|
+
subject.ordered_file_sets << file_set2
|
228
|
+
subject.ordered_works << generic_work1
|
229
|
+
subject.ordered_works << generic_work2
|
406
230
|
subject.related_objects << object1
|
407
231
|
end
|
408
232
|
|
409
|
-
it 'adds a related object to
|
233
|
+
it 'adds a related object to file_set with works and file_sets' do
|
410
234
|
subject.related_objects << object2
|
411
235
|
subject.save
|
412
236
|
subject.reload
|
@@ -462,11 +286,11 @@ describe Hydra::Works::GenericWork do
|
|
462
286
|
end
|
463
287
|
|
464
288
|
describe '#related_objects <<' do
|
465
|
-
context 'with
|
289
|
+
context 'with file sets and works' do
|
466
290
|
before do
|
467
|
-
subject.
|
468
|
-
subject.
|
469
|
-
subject.
|
291
|
+
subject.ordered_members << generic_work1
|
292
|
+
subject.ordered_members << generic_work1
|
293
|
+
subject.ordered_members << file_set1
|
470
294
|
end
|
471
295
|
|
472
296
|
it 'returns empty array when only generic files and generic works are aggregated' do
|
@@ -480,9 +304,9 @@ describe Hydra::Works::GenericWork do
|
|
480
304
|
|
481
305
|
it 'returns related objects of various types' do
|
482
306
|
subject.related_objects << generic_work2
|
483
|
-
subject.related_objects <<
|
307
|
+
subject.related_objects << file_set1
|
484
308
|
subject.related_objects << object1
|
485
|
-
expect(subject.related_objects).to eq [generic_work2,
|
309
|
+
expect(subject.related_objects).to eq [generic_work2, file_set1, object1]
|
486
310
|
expect(subject.related_objects.size).to eq 3
|
487
311
|
end
|
488
312
|
end
|
@@ -491,18 +315,18 @@ describe Hydra::Works::GenericWork do
|
|
491
315
|
describe '#related_objects.delete' do
|
492
316
|
context 'when multiple related objects' do
|
493
317
|
let(:related_object1) { Hydra::PCDM::Object.new }
|
494
|
-
let(:related_work2) {
|
495
|
-
let(:related_file3) { Hydra::Works::
|
318
|
+
let(:related_work2) { described_class.new }
|
319
|
+
let(:related_file3) { Hydra::Works::FileSet.new }
|
496
320
|
let(:related_object4) { Hydra::PCDM::Object.new }
|
497
|
-
let(:related_work5) {
|
321
|
+
let(:related_work5) { described_class.new }
|
498
322
|
before do
|
499
323
|
subject.related_objects << related_object1
|
500
324
|
subject.related_objects << related_work2
|
501
|
-
subject.
|
502
|
-
subject.
|
325
|
+
subject.ordered_members << generic_work2
|
326
|
+
subject.ordered_members << file_set1
|
503
327
|
subject.related_objects << related_file3
|
504
328
|
subject.related_objects << related_object4
|
505
|
-
subject.
|
329
|
+
subject.ordered_members << generic_work1
|
506
330
|
subject.related_objects << related_work5
|
507
331
|
expect(subject.related_objects).to eq [related_object1, related_work2, related_file3, related_object4, related_work5]
|
508
332
|
end
|
@@ -510,22 +334,22 @@ describe Hydra::Works::GenericWork do
|
|
510
334
|
it 'removes first related object' do
|
511
335
|
expect(subject.related_objects.delete related_object1).to eq [related_object1]
|
512
336
|
expect(subject.related_objects).to eq [related_work2, related_file3, related_object4, related_work5]
|
513
|
-
expect(subject.
|
514
|
-
expect(subject.
|
337
|
+
expect(subject.ordered_works).to eq [generic_work2, generic_work1]
|
338
|
+
expect(subject.ordered_file_sets).to eq [file_set1]
|
515
339
|
end
|
516
340
|
|
517
341
|
it 'removes last related object' do
|
518
342
|
expect(subject.related_objects.delete related_work5).to eq [related_work5]
|
519
343
|
expect(subject.related_objects).to eq [related_object1, related_work2, related_file3, related_object4]
|
520
|
-
expect(subject.
|
521
|
-
expect(subject.
|
344
|
+
expect(subject.ordered_works).to eq [generic_work2, generic_work1]
|
345
|
+
expect(subject.ordered_file_sets).to eq [file_set1]
|
522
346
|
end
|
523
347
|
|
524
348
|
it 'removes middle related object' do
|
525
349
|
expect(subject.related_objects.delete related_file3).to eq [related_file3]
|
526
350
|
expect(subject.related_objects).to eq [related_object1, related_work2, related_object4, related_work5]
|
527
|
-
expect(subject.
|
528
|
-
expect(subject.
|
351
|
+
expect(subject.ordered_works).to eq [generic_work2, generic_work1]
|
352
|
+
expect(subject.ordered_file_sets).to eq [file_set1]
|
529
353
|
end
|
530
354
|
end
|
531
355
|
end
|
@@ -533,8 +357,8 @@ describe Hydra::Works::GenericWork do
|
|
533
357
|
describe 'should have parent work and collection accessors' do
|
534
358
|
let(:collection1) { Hydra::Works::Collection.new }
|
535
359
|
before do
|
536
|
-
collection1.
|
537
|
-
generic_work1.
|
360
|
+
collection1.ordered_members << generic_work2
|
361
|
+
generic_work1.ordered_members << generic_work2
|
538
362
|
collection1.save
|
539
363
|
generic_work1.save
|
540
364
|
generic_work2.save
|
@@ -547,18 +371,24 @@ describe Hydra::Works::GenericWork do
|
|
547
371
|
expect(generic_work2.in_collections).to eq [collection1]
|
548
372
|
end
|
549
373
|
it 'has a parent generic_work' do
|
550
|
-
expect(generic_work2.
|
374
|
+
expect(generic_work2.in_works).to eq [generic_work1]
|
551
375
|
end
|
552
376
|
end
|
553
377
|
|
554
378
|
describe 'make sure deprecated methods still work' do
|
379
|
+
let(:collection1) { Hydra::Works::Collection.new }
|
555
380
|
it 'deprecated methods should pass' do
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
381
|
+
Deprecation.silence(Hydra::Works::WorkBehavior) do
|
382
|
+
collection1.ordered_members << generic_work1
|
383
|
+
generic_work1.ordered_members << generic_work2
|
384
|
+
expect(generic_work1.child_generic_works).to eq [generic_work2]
|
385
|
+
expect(generic_work1.child_generic_work_ids).to eq [generic_work2.id]
|
386
|
+
generic_work1.save # required until issue AF-Agg-75 is fixed
|
387
|
+
collection1.save
|
388
|
+
expect(generic_work2.parent_generic_works).to eq [generic_work1]
|
389
|
+
expect(generic_work1.parent_collections).to eq [collection1]
|
390
|
+
expect(generic_work2.parents).to eq [generic_work1]
|
391
|
+
end
|
562
392
|
end
|
563
393
|
end
|
564
394
|
end
|