hydra-works 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.travis.yml +2 -5
- data/Gemfile +1 -3
- data/README.md +28 -13
- data/hydra-works.gemspec +4 -3
- data/lib/hydra/works.rb +7 -57
- data/lib/hydra/works/models/concerns/block_child_objects.rb +16 -0
- data/lib/hydra/works/models/concerns/collection_behavior.rb +27 -2
- data/lib/hydra/works/models/concerns/generic_file/contained_files.rb +5 -13
- data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +9 -13
- data/lib/hydra/works/models/concerns/generic_file/mime_types.rb +14 -9
- data/lib/hydra/works/models/concerns/generic_file/versioned_content.rb +18 -0
- data/lib/hydra/works/models/concerns/generic_file/virus_check.rb +48 -0
- data/lib/hydra/works/models/concerns/generic_file_behavior.rb +24 -1
- data/lib/hydra/works/models/concerns/generic_work_behavior.rb +32 -3
- data/lib/hydra/works/models/generic_file.rb +3 -0
- data/lib/hydra/works/services/generic_file/add_file_to_generic_file.rb +127 -0
- data/lib/hydra/works/services/generic_file/generate/thumbnail.rb +1 -2
- data/lib/hydra/works/services/generic_file/persist_derivative.rb +22 -0
- data/lib/hydra/works/services/generic_file/upload_file.rb +11 -19
- data/lib/hydra/works/version.rb +1 -1
- data/lib/hydra/works/vocab/works_terms.rb +1 -1
- data/spec/fixtures/Example.ogg +0 -0
- data/spec/fixtures/charter.docx +0 -0
- data/spec/fixtures/countdown.avi +0 -0
- data/spec/fixtures/image.jp2 +0 -0
- data/spec/fixtures/piano_note.wav +0 -0
- data/spec/fixtures/test5.mp3 +0 -0
- data/spec/fixtures/world.png +0 -0
- data/spec/hydra/works/models/collection_spec.rb +499 -16
- data/spec/hydra/works/models/concerns/block_child_objects_spec.rb +19 -0
- data/spec/hydra/works/models/concerns/{file → generic_file}/contained_files_spec.rb +20 -17
- data/spec/hydra/works/models/concerns/generic_file/mime_types_spec.rb +76 -0
- data/spec/hydra/works/models/concerns/generic_file/versioned_content_spec.rb +32 -0
- data/spec/hydra/works/models/concerns/generic_file/virus_check_spec.rb +50 -0
- data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +1 -1
- data/spec/hydra/works/models/generic_file_spec.rb +201 -14
- data/spec/hydra/works/models/generic_work_spec.rb +530 -14
- data/spec/hydra/works/services/generic_file/add_file_to_generic_file_spec.rb +110 -0
- data/spec/hydra/works/services/generic_file/upload_file_spec.rb +45 -28
- data/spec/hydra/works/services/persist_derivatives_spec.rb +93 -0
- data/spec/hydra/works_spec.rb +35 -35
- data/spec/spec_helper.rb +6 -0
- metadata +56 -95
- data/lib/hydra/works/models/concerns/aggregates_collections.rb +0 -16
- data/lib/hydra/works/models/concerns/aggregates_generic_files.rb +0 -20
- data/lib/hydra/works/models/concerns/aggregates_generic_works.rb +0 -20
- data/lib/hydra/works/processor.rb +0 -9
- data/lib/hydra/works/services/collection/add_collection.rb +0 -19
- data/lib/hydra/works/services/collection/add_generic_work.rb +0 -19
- data/lib/hydra/works/services/collection/add_related_object.rb +0 -19
- data/lib/hydra/works/services/collection/get_collections.rb +0 -17
- data/lib/hydra/works/services/collection/get_generic_works.rb +0 -17
- data/lib/hydra/works/services/collection/get_related_objects.rb +0 -17
- data/lib/hydra/works/services/collection/remove_collection.rb +0 -19
- data/lib/hydra/works/services/collection/remove_generic_work.rb +0 -20
- data/lib/hydra/works/services/collection/remove_related_object.rb +0 -19
- data/lib/hydra/works/services/generic_file/add_file.rb +0 -55
- data/lib/hydra/works/services/generic_file/add_generic_file.rb +0 -19
- data/lib/hydra/works/services/generic_file/add_original_file.rb +0 -11
- data/lib/hydra/works/services/generic_file/add_related_object.rb +0 -19
- data/lib/hydra/works/services/generic_file/add_versioned_original_file.rb +0 -10
- data/lib/hydra/works/services/generic_file/get_generic_files.rb +0 -17
- data/lib/hydra/works/services/generic_file/get_related_objects.rb +0 -17
- data/lib/hydra/works/services/generic_file/remove_generic_file.rb +0 -20
- data/lib/hydra/works/services/generic_file/remove_related_object.rb +0 -19
- data/lib/hydra/works/services/generic_work/add_generic_file.rb +0 -19
- data/lib/hydra/works/services/generic_work/add_generic_work.rb +0 -19
- data/lib/hydra/works/services/generic_work/add_related_object.rb +0 -19
- data/lib/hydra/works/services/generic_work/get_generic_files.rb +0 -17
- data/lib/hydra/works/services/generic_work/get_generic_works.rb +0 -17
- data/lib/hydra/works/services/generic_work/get_related_objects.rb +0 -17
- data/lib/hydra/works/services/generic_work/move_generic_file.rb +0 -19
- data/lib/hydra/works/services/generic_work/remove_generic_file.rb +0 -20
- data/lib/hydra/works/services/generic_work/remove_generic_work.rb +0 -20
- data/lib/hydra/works/services/generic_work/remove_related_object.rb +0 -19
- data/spec/hydra/works/services/collection/add_collection_spec.rb +0 -166
- data/spec/hydra/works/services/collection/add_generic_work_spec.rb +0 -155
- data/spec/hydra/works/services/collection/add_related_object_spec.rb +0 -149
- data/spec/hydra/works/services/collection/get_collections_spec.rb +0 -35
- data/spec/hydra/works/services/collection/get_generic_works_spec.rb +0 -35
- data/spec/hydra/works/services/collection/get_related_objects_spec.rb +0 -49
- data/spec/hydra/works/services/collection/remove_collection_spec.rb +0 -133
- data/spec/hydra/works/services/collection/remove_generic_work_spec.rb +0 -133
- data/spec/hydra/works/services/collection/remove_related_object_spec.rb +0 -128
- data/spec/hydra/works/services/generic_file/add_file_spec.rb +0 -28
- data/spec/hydra/works/services/generic_file/add_generic_file_spec.rb +0 -174
- data/spec/hydra/works/services/generic_file/add_related_object_spec.rb +0 -150
- data/spec/hydra/works/services/generic_file/get_generic_files_spec.rb +0 -19
- data/spec/hydra/works/services/generic_file/get_related_objects_spec.rb +0 -45
- data/spec/hydra/works/services/generic_file/remove_generic_file_spec.rb +0 -124
- data/spec/hydra/works/services/generic_file/remove_related_object_spec.rb +0 -123
- data/spec/hydra/works/services/generic_work/add_generic_file_spec.rb +0 -156
- data/spec/hydra/works/services/generic_work/add_generic_work_spec.rb +0 -157
- data/spec/hydra/works/services/generic_work/add_related_object_spec.rb +0 -148
- data/spec/hydra/works/services/generic_work/get_generic_files_spec.rb +0 -35
- data/spec/hydra/works/services/generic_work/get_generic_works_spec.rb +0 -35
- data/spec/hydra/works/services/generic_work/get_related_objects_spec.rb +0 -46
- data/spec/hydra/works/services/generic_work/move_generic_file_spec.rb +0 -21
- data/spec/hydra/works/services/generic_work/remove_generic_file_spec.rb +0 -132
- data/spec/hydra/works/services/generic_work/remove_generic_work_spec.rb +0 -133
- data/spec/hydra/works/services/generic_work/remove_related_object_spec.rb +0 -128
@@ -1,123 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Works::RemoveRelatedObjectFromGenericFile do
|
4
|
-
|
5
|
-
subject { Hydra::Works::GenericFile::Base.create }
|
6
|
-
|
7
|
-
let(:related_object1) { Hydra::PCDM::Object.create }
|
8
|
-
let(:related_work2) { Hydra::Works::GenericWork::Base.create }
|
9
|
-
let(:related_file3) { Hydra::Works::GenericFile::Base.create }
|
10
|
-
let(:related_object4) { Hydra::PCDM::Object.create }
|
11
|
-
let(:related_work5) { Hydra::Works::GenericWork::Base.create }
|
12
|
-
|
13
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
14
|
-
let(:generic_file2) { Hydra::Works::GenericFile::Base.create }
|
15
|
-
|
16
|
-
|
17
|
-
describe '#call' do
|
18
|
-
context 'when multiple related objects' do
|
19
|
-
before do
|
20
|
-
Hydra::Works::AddRelatedObjectToGenericFile.call( subject, related_object1 )
|
21
|
-
Hydra::Works::AddRelatedObjectToGenericFile.call( subject, related_work2 )
|
22
|
-
Hydra::Works::AddGenericFileToGenericFile.call( subject, generic_file2 )
|
23
|
-
Hydra::Works::AddRelatedObjectToGenericFile.call( subject, related_file3 )
|
24
|
-
Hydra::Works::AddRelatedObjectToGenericFile.call( subject, related_object4 )
|
25
|
-
Hydra::Works::AddGenericFileToGenericFile.call( subject, generic_file1 )
|
26
|
-
Hydra::Works::AddRelatedObjectToGenericFile.call( subject, related_work5 )
|
27
|
-
subject.save
|
28
|
-
expect( Hydra::Works::GetRelatedObjectsFromGenericFile.call( subject.reload )).to eq [related_object1,related_work2,related_file3,related_object4,related_work5]
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should remove first related object' do
|
32
|
-
expect( Hydra::Works::RemoveRelatedObjectFromGenericFile.call( subject, related_object1 ) ).to eq related_object1
|
33
|
-
expect( Hydra::Works::GetRelatedObjectsFromGenericFile.call( subject.reload )).to eq [related_work2,related_file3,related_object4,related_work5]
|
34
|
-
expect( Hydra::Works::GetGenericFilesFromGenericFile.call( subject.reload )).to eq [generic_file2,generic_file1]
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should remove last related object' do
|
38
|
-
expect( Hydra::Works::RemoveRelatedObjectFromGenericFile.call( subject, related_work5 ) ).to eq related_work5
|
39
|
-
expect( Hydra::Works::GetRelatedObjectsFromGenericFile.call( subject.reload )).to eq [related_object1,related_work2,related_file3,related_object4]
|
40
|
-
expect( Hydra::Works::GetGenericFilesFromGenericFile.call( subject.reload )).to eq [generic_file2,generic_file1]
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should remove middle related object' do
|
44
|
-
expect( Hydra::Works::RemoveRelatedObjectFromGenericFile.call( subject, related_file3 ) ).to eq related_file3
|
45
|
-
expect( Hydra::Works::GetRelatedObjectsFromGenericFile.call( subject.reload )).to eq [related_object1,related_work2,related_object4,related_work5]
|
46
|
-
expect( Hydra::Works::GetGenericFilesFromGenericFile.call( subject.reload )).to eq [generic_file2,generic_file1]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'with unacceptable related object' do
|
52
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
53
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
54
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
55
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
56
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
57
|
-
|
58
|
-
let(:error_type) { ArgumentError }
|
59
|
-
let(:error_message) { 'child_related_object must be a pcdm object' }
|
60
|
-
|
61
|
-
it 'should NOT remove Hydra::Works::Collection from related_objects aggregation' do
|
62
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( subject, collection1 ) }.to raise_error(ArgumentError,error_message)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should NOT remove Hydra::PCDM::Collections from related_objects aggregation' do
|
66
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( subject, pcdm_collection1 ) }.to raise_error(ArgumentError,error_message)
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should NOT remove Hydra::PCDM::Files from related_objects aggregation' do
|
70
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( subject, pcdm_file1 ) }.to raise_error(error_type,error_message)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should NOT remove non-PCDM objects from related_objects aggregation' do
|
74
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( subject, non_PCDM_object ) }.to raise_error(error_type,error_message)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should NOT remove AF::Base objects from related_objects aggregation' do
|
78
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( subject, af_base_object ) }.to raise_error(error_type,error_message)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'with unacceptable parent generic file' do
|
83
|
-
let(:related_object2) { Hydra::PCDM::Object.create }
|
84
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
85
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
86
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
87
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
88
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
89
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
90
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
91
|
-
|
92
|
-
let(:error_type) { ArgumentError }
|
93
|
-
let(:error_message) { 'parent_generic_file must be a hydra-works generic file' }
|
94
|
-
|
95
|
-
it 'should NOT accept Hydra::Works::Collection as parent generic file' do
|
96
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( collection1, related_object2 ) }.to raise_error(ArgumentError,error_message)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should NOT accept Hydra::Works::GenericWork as parent generic file' do
|
100
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( generic_work1, related_object2 ) }.to raise_error(ArgumentError,error_message)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'should NOT accept Hydra::PCDM::Collections as parent generic file' do
|
104
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( pcdm_collection1, related_object2 ) }.to raise_error(ArgumentError,error_message)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'should NOT accept Hydra::PCDM::Objects as parent generic file' do
|
108
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( pcdm_object1, related_object2 ) }.to raise_error(error_type,error_message)
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should NOT accept Hydra::PCDM::Files as parent generic file' do
|
112
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( pcdm_file1, related_object2 ) }.to raise_error(error_type,error_message)
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'should NOT accept non-PCDM objects as parent generic file' do
|
116
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( non_PCDM_object, related_object2 ) }.to raise_error(error_type,error_message)
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'should NOT accept AF::Base objects as parent generic file' do
|
120
|
-
expect{ Hydra::Works::RemoveRelatedObjectFromGenericFile.call( af_base_object, related_work2 ) }.to raise_error(error_type,error_message)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
@@ -1,156 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Works::AddGenericFileToGenericWork do
|
4
|
-
|
5
|
-
let(:subject) { Hydra::Works::GenericWork::Base.create }
|
6
|
-
|
7
|
-
describe '#call' do
|
8
|
-
context 'with acceptable generic_works' do
|
9
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
10
|
-
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
11
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
12
|
-
let(:generic_file2) { Hydra::Works::GenericFile::Base.create }
|
13
|
-
let(:generic_file3) { Hydra::Works::GenericFile::Base.create }
|
14
|
-
|
15
|
-
context 'with generic_files and generic_works' do
|
16
|
-
before do
|
17
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file1 )
|
18
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file2 )
|
19
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work1 )
|
20
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work2 )
|
21
|
-
subject.save
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should add generic_file to generic_work with generic_files and generic_works' do
|
25
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file3 )
|
26
|
-
expect( Hydra::Works::GetGenericFilesFromGenericWork.call( subject ) ).to eq [generic_file1,generic_file2,generic_file3]
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should solrize member ids' do
|
30
|
-
skip 'skipping this test because issue #109 needs to be addressed' do
|
31
|
-
expect(subject.to_solr["generic_works_ssim"]).to include(generic_work1.id,generic_work2.id)
|
32
|
-
expect(subject.to_solr["generic_works_ssim"]).not_to include(generic_file1.id,generic_file2.id,generic_file3.id)
|
33
|
-
expect(subject.to_solr["generic_files_ssim"]).to include(generic_file1.id,generic_file2.id,generic_file3.id)
|
34
|
-
expect(subject.to_solr["generic_files_ssim"]).not_to include(generic_work1.id,generic_work2.id)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'aggregates generic_files that implement Hydra::Works::GenericFileBehavior' do
|
40
|
-
before do
|
41
|
-
class DummyIncFile < ActiveFedora::Base
|
42
|
-
include Hydra::Works::GenericFileBehavior
|
43
|
-
end
|
44
|
-
end
|
45
|
-
after { Object.send(:remove_const, :DummyIncFile) }
|
46
|
-
let(:ifile1) { DummyIncFile.create }
|
47
|
-
|
48
|
-
it 'should accept implementing generic_file as a child' do
|
49
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, ifile1 )
|
50
|
-
subject.save
|
51
|
-
expect( Hydra::Works::GetGenericFilesFromGenericWork.call( subject ) ).to eq [ifile1]
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'aggregates generic_files that extend Hydra::Works::GenericFile::Base' do
|
57
|
-
before do
|
58
|
-
class DummyExtFile < Hydra::Works::GenericFile::Base
|
59
|
-
end
|
60
|
-
end
|
61
|
-
after { Object.send(:remove_const, :DummyExtFile) }
|
62
|
-
let(:efile1) { DummyExtFile.create }
|
63
|
-
|
64
|
-
it 'should accept extending generic_file as a child' do
|
65
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, efile1 )
|
66
|
-
subject.save
|
67
|
-
expect( Hydra::Works::GetGenericFilesFromGenericWork.call( subject ) ).to eq [efile1]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'with unacceptable child generic_files' do
|
73
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
74
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
75
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
76
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
77
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
78
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
79
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
80
|
-
|
81
|
-
let(:error_message) { 'child_generic_file must be a hydra-works generic file' }
|
82
|
-
|
83
|
-
it 'should NOT aggregate Hydra::Works::Collection in generic files aggregation' do
|
84
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( subject, collection1 ) }.to raise_error(ArgumentError,error_message)
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should NOT aggregate Hydra::Works::GenericWork in generic files aggregation' do
|
88
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_work1 ) }.to raise_error(ArgumentError,error_message)
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'should NOT aggregate Hydra::PCDM::Collections in generic files aggregation' do
|
92
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( subject, pcdm_collection1 ) }.to raise_error(ArgumentError,error_message)
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should NOT aggregate Hydra::PCDM::Objects in generic files aggregation' do
|
96
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( subject, pcdm_object1 ) }.to raise_error(ArgumentError,error_message)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should NOT aggregate Hydra::PCDM::Files in generic files aggregation' do
|
100
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( subject, pcdm_file1 ) }.to raise_error(ArgumentError,error_message)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'should NOT aggregate non-PCDM objects in generic files aggregation' do
|
104
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( subject, non_PCDM_object ) }.to raise_error(ArgumentError,error_message)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'should NOT aggregate AF::Base objects in generic files aggregation' do
|
108
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( subject, af_base_object ) }.to raise_error(ArgumentError,error_message)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'with unacceptable parent generic works' do
|
113
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
114
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
115
|
-
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
116
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
117
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
118
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
119
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
120
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
121
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
122
|
-
|
123
|
-
let(:error_message) { 'parent_generic_work must be a hydra-works generic work' }
|
124
|
-
|
125
|
-
it 'should NOT accept Hydra::Works::Collection as parent generic work' do
|
126
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( collection1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'should NOT accept Hydra::Works::GenericFile as parent generic work' do
|
130
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( generic_file1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'should NOT accept Hydra::PCDM::Collections as parent generic work' do
|
134
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( pcdm_collection1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'should NOT accept Hydra::PCDM::Objects as parent generic work' do
|
138
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( pcdm_object1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'should NOT accept Hydra::PCDM::Files as parent generic work' do
|
142
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( pcdm_file1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'should NOT accept non-PCDM objects as parent generic work' do
|
146
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( non_PCDM_object, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'should NOT accept AF::Base objects as parent generic work' do
|
150
|
-
expect{ Hydra::Works::AddGenericFileToGenericWork.call( af_base_object, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
end
|
@@ -1,157 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Works::AddGenericWorkToGenericWork do
|
4
|
-
|
5
|
-
let(:subject) { Hydra::Works::GenericWork::Base.create }
|
6
|
-
|
7
|
-
describe '#call' do
|
8
|
-
context 'with acceptable generic_works' do
|
9
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
10
|
-
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
11
|
-
let(:generic_work3) { Hydra::Works::GenericWork::Base.create }
|
12
|
-
let(:generic_work4) { Hydra::Works::GenericWork::Base.create }
|
13
|
-
let(:generic_work5) { Hydra::Works::GenericWork::Base.create }
|
14
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
15
|
-
let(:generic_file2) { Hydra::Works::GenericFile::Base.create }
|
16
|
-
|
17
|
-
context 'with generic_files and generic_works' do
|
18
|
-
before do
|
19
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file1 )
|
20
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file2 )
|
21
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work1 )
|
22
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work2 )
|
23
|
-
subject.save
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should add generic_work to generic_work with generic_files and generic_works' do
|
27
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work3 )
|
28
|
-
expect( Hydra::Works::GetGenericWorksFromGenericWork.call( subject ) ).to eq [generic_work1,generic_work2,generic_work3]
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should solrize member ids' do
|
32
|
-
skip 'skipping this test because issue #109 needs to be addressed' do
|
33
|
-
expect(subject.to_solr['generic_works_ssim']).to include(generic_work1.id,generic_work2.id,generic_work3.id)
|
34
|
-
expect(subject.to_solr['generic_works_ssim']).not_to include(generic_file1.id,generic_file2.id)
|
35
|
-
expect(subject.to_solr['generic_files_ssim']).to include(generic_file1.id,generic_file2.id)
|
36
|
-
expect(subject.to_solr['generic_files_ssim']).not_to include(generic_work1.id,generic_work2.id,generic_work3.id)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'aggregates generic_works that implement Hydra::Works::GenericWorkBehavior' do
|
42
|
-
before do
|
43
|
-
class DummyIncWork < ActiveFedora::Base
|
44
|
-
include Hydra::Works::GenericWorkBehavior
|
45
|
-
end
|
46
|
-
end
|
47
|
-
after { Object.send(:remove_const, :DummyIncWork) }
|
48
|
-
let(:iwork1) { DummyIncWork.create }
|
49
|
-
|
50
|
-
it 'should accept implementing generic_work as a child' do
|
51
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, iwork1 )
|
52
|
-
subject.save
|
53
|
-
expect( Hydra::Works::GetGenericWorksFromGenericWork.call( subject ) ).to eq [iwork1]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe 'aggregates generic_works that extend Hydra::Works::GenericWork::Base' do
|
58
|
-
before do
|
59
|
-
class DummyExtWork < Hydra::Works::GenericWork::Base
|
60
|
-
end
|
61
|
-
end
|
62
|
-
after { Object.send(:remove_const, :DummyExtWork) }
|
63
|
-
let(:ework1) { DummyExtWork.create }
|
64
|
-
|
65
|
-
it 'should accept extending generic_work as a child' do
|
66
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, ework1 )
|
67
|
-
subject.save
|
68
|
-
expect( Hydra::Works::GetGenericWorksFromGenericWork.call( subject ) ).to eq [ework1]
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'with unacceptable child generic_works' do
|
74
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
75
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
76
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
77
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
78
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
79
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
80
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
81
|
-
|
82
|
-
let(:error_message) { 'child_generic_work must be a hydra-works generic work' }
|
83
|
-
|
84
|
-
it 'should NOT aggregate Hydra::Works::Collection in generic works aggregation' do
|
85
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( subject, collection1 ) }.to raise_error(ArgumentError,error_message)
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should NOT aggregate Hydra::Works::GenericFile in generic works aggregation' do
|
89
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_file1 ) }.to raise_error(ArgumentError,error_message)
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'should NOT aggregate Hydra::PCDM::Collections in generic works aggregation' do
|
93
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( subject, pcdm_collection1 ) }.to raise_error(ArgumentError,error_message)
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should NOT aggregate Hydra::PCDM::Objects in generic works aggregation' do
|
97
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( subject, pcdm_object1 ) }.to raise_error(ArgumentError,error_message)
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'should NOT aggregate Hydra::PCDM::Files in generic works aggregation' do
|
101
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( subject, pcdm_file1 ) }.to raise_error(ArgumentError,error_message)
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should NOT aggregate non-PCDM objects in generic works aggregation' do
|
105
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( subject, non_PCDM_object ) }.to raise_error(ArgumentError,error_message)
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'should NOT aggregate AF::Base objects in generic works aggregation' do
|
109
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( subject, af_base_object ) }.to raise_error(ArgumentError,error_message)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context 'with unacceptable parent generic works' do
|
114
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
115
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
116
|
-
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
117
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
118
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
119
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
120
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
121
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
122
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
123
|
-
|
124
|
-
let(:error_message) { 'parent_generic_work must be a hydra-works generic work' }
|
125
|
-
|
126
|
-
it 'should NOT accept Hydra::Works::Collection as parent generic work' do
|
127
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( collection1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'should NOT accept Hydra::Works::GenericFile as parent generic work' do
|
131
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( generic_file1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'should NOT accept Hydra::PCDM::Collections as parent generic work' do
|
135
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( pcdm_collection1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'should NOT accept Hydra::PCDM::Objects as parent generic work' do
|
139
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( pcdm_object1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'should NOT accept Hydra::PCDM::Files as parent generic work' do
|
143
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( pcdm_file1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'should NOT accept non-PCDM objects as parent generic work' do
|
147
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( non_PCDM_object, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'should NOT accept AF::Base objects as parent generic work' do
|
151
|
-
expect{ Hydra::Works::AddGenericWorkToGenericWork.call( af_base_object, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|
@@ -1,148 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Works::AddRelatedObjectToGenericWork do
|
4
|
-
|
5
|
-
let(:subject) { Hydra::Works::GenericWork::Base.create }
|
6
|
-
|
7
|
-
describe '#call' do
|
8
|
-
|
9
|
-
context 'with acceptable related objects' do
|
10
|
-
let(:object1) { Hydra::PCDM::Object.create }
|
11
|
-
let(:object2) { Hydra::PCDM::Object.create }
|
12
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
13
|
-
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
14
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
15
|
-
let(:generic_file2) { Hydra::Works::GenericFile::Base.create }
|
16
|
-
|
17
|
-
it 'should add various types of related objects to generic_work' do
|
18
|
-
Hydra::Works::AddRelatedObjectToGenericWork.call( subject, generic_work1 )
|
19
|
-
Hydra::Works::AddRelatedObjectToGenericWork.call( subject, generic_file1 )
|
20
|
-
Hydra::Works::AddRelatedObjectToGenericWork.call( subject, object1 )
|
21
|
-
related_objects = Hydra::Works::GetRelatedObjectsFromGenericWork.call( subject )
|
22
|
-
expect( related_objects.include? generic_work1 ).to be true
|
23
|
-
expect( related_objects.include? generic_file1 ).to be true
|
24
|
-
expect( related_objects.include? object1 ).to be true
|
25
|
-
expect( related_objects.size ).to eq 3
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'with generic_works and generic_files' do
|
29
|
-
before do
|
30
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file1 )
|
31
|
-
Hydra::Works::AddGenericFileToGenericWork.call( subject, generic_file2 )
|
32
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work1 )
|
33
|
-
Hydra::Works::AddGenericWorkToGenericWork.call( subject, generic_work2 )
|
34
|
-
Hydra::Works::AddRelatedObjectToGenericWork.call( subject, object1 )
|
35
|
-
subject.save
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should add a related object to generic_work with generic_works and generic_files' do
|
39
|
-
Hydra::Works::AddRelatedObjectToGenericWork.call( subject, object2 )
|
40
|
-
related_objects = Hydra::Works::GetRelatedObjectsFromGenericWork.call( subject )
|
41
|
-
expect( related_objects.include? object1 ).to be true
|
42
|
-
expect( related_objects.include? object2 ).to be true
|
43
|
-
expect( related_objects.size ).to eq 2
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should solrize member ids' do
|
47
|
-
skip 'skipping this test because issue #109 needs to be addressed' do
|
48
|
-
expect(subject.to_solr["generic_works_ssim"]).to include(generic_work1.id,generic_work2.id)
|
49
|
-
expect(subject.to_solr["generic_works_ssim"]).not_to include(generic_file2.id,generic_file1.id,object1.id,object2.id)
|
50
|
-
expect(subject.to_solr["generic_files_ssim"]).to include(generic_file2.id,generic_file1.id)
|
51
|
-
expect(subject.to_solr["generic_files_ssim"]).not_to include(object1.id,object2.id,generic_work1.id,generic_work2.id)
|
52
|
-
expect(subject.to_solr["related_objects_ssim"]).to include(object1.id,object2.id)
|
53
|
-
expect(subject.to_solr["related_objects_ssim"]).not_to include(generic_file2.id,generic_file1.id,generic_work1.id,generic_work2.id)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'with unacceptable child related objects' do
|
60
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
61
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
62
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
63
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
64
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
65
|
-
|
66
|
-
let(:error_message) { 'child_related_object must be a pcdm object' }
|
67
|
-
|
68
|
-
it 'should NOT aggregate Hydra::Works::Collection in related objects aggregation' do
|
69
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( subject, collection1 ) }.to raise_error(ArgumentError,error_message)
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'should NOT aggregate Hydra::PCDM::Collections in related objects aggregation' do
|
73
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( subject, pcdm_collection1 ) }.to raise_error(ArgumentError,error_message)
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should NOT aggregate Hydra::PCDM::Files in related objects aggregation' do
|
77
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( subject, pcdm_file1 ) }.to raise_error(ArgumentError,error_message)
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'should NOT aggregate non-PCDM objects in related objects aggregation' do
|
81
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( subject, non_PCDM_object ) }.to raise_error(ArgumentError,error_message)
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should NOT aggregate AF::Base objects in related objects aggregation' do
|
85
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( subject, af_base_object ) }.to raise_error(ArgumentError,error_message)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'with unacceptable parent generic work' do
|
90
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
91
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
92
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
93
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
94
|
-
let(:pcdm_object2) { Hydra::PCDM::Object.create }
|
95
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
96
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
97
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
98
|
-
|
99
|
-
let(:error_message) { 'parent_generic_work must be a hydra-works generic work' }
|
100
|
-
|
101
|
-
it 'should NOT accept Hydra::Works::Collection as parent generic work' do
|
102
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( collection1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'should NOT accept Hydra::Works::GenericFile as parent generic work' do
|
106
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( generic_file1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'should NOT accept Hydra::PCDM::Collections as parent generic work' do
|
110
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( pcdm_collection1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should NOT accept Hydra::PCDM::Objects as parent generic work' do
|
114
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( pcdm_object1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'should NOT accept Hydra::PCDM::Files as parent generic work' do
|
118
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( pcdm_file1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'should NOT accept non-PCDM objects as parent generic work' do
|
122
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( non_PCDM_object, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'should NOT accept AF::Base objects as parent generic work' do
|
126
|
-
expect{ Hydra::Works::AddRelatedObjectToGenericWork.call( af_base_object, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
context 'with invalid bahaviors' do
|
132
|
-
let(:object1) { Hydra::PCDM::Object.create }
|
133
|
-
let(:object2) { Hydra::PCDM::Object.create }
|
134
|
-
|
135
|
-
it 'should NOT allow related objects to repeat' do
|
136
|
-
skip 'skipping this test because issue pcdm#92 needs to be addressed' do
|
137
|
-
Hydra::Works::AddRelatedObjectToGenericWork.call( subject, object1 )
|
138
|
-
Hydra::Works::AddRelatedObjectToGenericWork.call( subject, object2 )
|
139
|
-
Hydra::Works::AddRelatedObjectToGenericWork.call( subject, object1 )
|
140
|
-
related_objects = Hydra::Works::GetRelatedObjectsFromGenericWork.call( subject )
|
141
|
-
expect( related_objects.include? object1 ).to be true
|
142
|
-
expect( related_objects.include? object2 ).to be true
|
143
|
-
expect( related_objects.size ).to eq 2
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|