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,166 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Works::AddCollectionToCollection do
|
4
|
-
|
5
|
-
subject { Hydra::Works::Collection.create }
|
6
|
-
|
7
|
-
describe '#call' do
|
8
|
-
context 'with acceptable collections' do
|
9
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
10
|
-
let(:collection2) { Hydra::Works::Collection.create }
|
11
|
-
let(:collection3) { Hydra::Works::Collection.create }
|
12
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
13
|
-
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
14
|
-
|
15
|
-
context 'with collections and generic_works' do
|
16
|
-
before do
|
17
|
-
Hydra::Works::AddCollectionToCollection.call( subject, collection1 )
|
18
|
-
Hydra::Works::AddCollectionToCollection.call( subject, collection2 )
|
19
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work1 )
|
20
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work2 )
|
21
|
-
subject.save
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should add an generic_work to collection with collections and generic_works' do
|
25
|
-
Hydra::Works::AddCollectionToCollection.call( subject, collection3 )
|
26
|
-
expect( Hydra::Works::GetCollectionsFromCollection.call( subject ) ).to eq [collection1,collection2,collection3]
|
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(collection2.id,collection1.id,collection3.id)
|
33
|
-
expect(subject.to_solr["collections_ssim"]).to include(collection2.id,collection1.id,collection3.id)
|
34
|
-
expect(subject.to_solr["collections_ssim"]).not_to include(generic_work1.id,generic_work2.id)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'aggregates collections that implement Hydra::Works' do
|
40
|
-
before do
|
41
|
-
class Kollection < ActiveFedora::Base
|
42
|
-
include Hydra::Works::CollectionBehavior
|
43
|
-
end
|
44
|
-
end
|
45
|
-
after { Object.send(:remove_const, :Kollection) }
|
46
|
-
let(:kollection1) { Kollection.create }
|
47
|
-
|
48
|
-
it 'should accept implementing collection as a child' do
|
49
|
-
Hydra::Works::AddCollectionToCollection.call( subject, kollection1 )
|
50
|
-
subject.save
|
51
|
-
expect( Hydra::Works::GetCollectionsFromCollection.call( subject ) ).to eq [kollection1]
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should accept implementing collection as a parent' do
|
55
|
-
Hydra::Works::AddCollectionToCollection.call( kollection1, collection1 )
|
56
|
-
subject.save
|
57
|
-
expect( Hydra::Works::GetCollectionsFromCollection.call( kollection1 ) ).to eq [collection1]
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'aggregates collections that extend Hydra::Works' do
|
62
|
-
before do
|
63
|
-
class Cullection < Hydra::Works::Collection
|
64
|
-
end
|
65
|
-
end
|
66
|
-
after { Object.send(:remove_const, :Cullection) }
|
67
|
-
let(:cullection1) { Cullection.create }
|
68
|
-
|
69
|
-
it 'should accept extending collection as a child' do
|
70
|
-
Hydra::Works::AddCollectionToCollection.call( subject, cullection1 )
|
71
|
-
subject.save
|
72
|
-
expect( Hydra::Works::GetCollectionsFromCollection.call( subject ) ).to eq [cullection1]
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should accept extending collection as a parent' do
|
76
|
-
Hydra::Works::AddCollectionToCollection.call( cullection1, collection1 )
|
77
|
-
subject.save
|
78
|
-
expect( Hydra::Works::GetCollectionsFromCollection.call( cullection1 ) ).to eq [collection1]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'with unacceptable child collections' do
|
84
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
85
|
-
let(:generic_file1) { Hydra::Works::GenericFile::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_message) { 'child_collection must be a hydra-works collection' }
|
93
|
-
|
94
|
-
it 'should NOT aggregate Hydra::Works::GenericWork in collections aggregation' do
|
95
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( subject, generic_work1 ) }.to raise_error(ArgumentError,error_message)
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should NOT aggregate Hydra::Works::GenericFile in collections aggregation' do
|
99
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( subject, generic_file1 ) }.to raise_error(ArgumentError,error_message)
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should NOT aggregate Hydra::PCDM::Collections in collections aggregation' do
|
103
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( subject, pcdm_collection1 ) }.to raise_error(ArgumentError,error_message)
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'should NOT aggregate Hydra::PCDM::Objects in collections aggregation' do
|
107
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( subject, pcdm_object1 ) }.to raise_error(ArgumentError,error_message)
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should NOT aggregate Hydra::PCDM::Files in collections aggregation' do
|
111
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( subject, pcdm_file1 ) }.to raise_error(ArgumentError,error_message)
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'should NOT aggregate non-PCDM objects in collections aggregation' do
|
115
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( subject, non_PCDM_object ) }.to raise_error(ArgumentError,error_message)
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should NOT aggregate AF::Base objects in collections aggregation' do
|
119
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( subject, af_base_object ) }.to raise_error(ArgumentError,error_message)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context 'with unacceptable parent collections' do
|
124
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
125
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
126
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
127
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
128
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
129
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
130
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
131
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
132
|
-
|
133
|
-
let(:error_message) { 'parent_collection must be a hydra-works collection' }
|
134
|
-
|
135
|
-
it 'should NOT accept Hydra::Works::GenericWork as parent collection' do
|
136
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( generic_work1, collection1 ) }.to raise_error(ArgumentError,error_message)
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'should NOT accept Hydra::Works::GenericFile as parent collection' do
|
140
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( generic_file1, collection1 ) }.to raise_error(ArgumentError,error_message)
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'should NOT accept Hydra::PCDM::Collections as parent collection' do
|
144
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( pcdm_collection1, collection1 ) }.to raise_error(ArgumentError,error_message)
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'should NOT accept Hydra::PCDM::Objects as parent collection' do
|
148
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( pcdm_object1, collection1 ) }.to raise_error(ArgumentError,error_message)
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'should NOT accept Hydra::PCDM::Files as parent collection' do
|
152
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( pcdm_file1, collection1 ) }.to raise_error(ArgumentError,error_message)
|
153
|
-
end
|
154
|
-
|
155
|
-
it 'should NOT accept non-PCDM objects as parent collection' do
|
156
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( non_PCDM_object, collection1 ) }.to raise_error(ArgumentError,error_message)
|
157
|
-
end
|
158
|
-
|
159
|
-
it 'should NOT accept AF::Base objects as parent collection' do
|
160
|
-
expect{ Hydra::Works::AddCollectionToCollection.call( af_base_object, collection1 ) }.to raise_error(ArgumentError,error_message)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
@@ -1,155 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Works::AddGenericWorkToCollection do
|
4
|
-
|
5
|
-
let(:subject) { Hydra::Works::Collection.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(:collection1) { Hydra::Works::Collection.create }
|
13
|
-
let(:collection2) { Hydra::Works::Collection.create }
|
14
|
-
|
15
|
-
context 'with collections and generic_works' do
|
16
|
-
before do
|
17
|
-
Hydra::Works::AddCollectionToCollection.call( subject, collection1 )
|
18
|
-
Hydra::Works::AddCollectionToCollection.call( subject, collection2 )
|
19
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work1 )
|
20
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work2 )
|
21
|
-
subject.save
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should add generic_work to collection with collections and generic_works' do
|
25
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work3 )
|
26
|
-
expect( Hydra::Works::GetGenericWorksFromCollection.call( subject ) ).to eq [generic_work1,generic_work2,generic_work3]
|
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,generic_work3.id)
|
32
|
-
expect(subject.to_solr["generic_works_ssim"]).not_to include(collection2.id,collection1.id)
|
33
|
-
expect(subject.to_solr["collections_ssim"]).to include(collection2.id,collection1.id)
|
34
|
-
expect(subject.to_solr["collections_ssim"]).not_to include(generic_work1.id,generic_work2.id,generic_work3.id)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'aggregates generic_works that implement Hydra::Works' do
|
40
|
-
before do
|
41
|
-
class DummyIncWork < ActiveFedora::Base
|
42
|
-
include Hydra::Works::GenericWorkBehavior
|
43
|
-
end
|
44
|
-
end
|
45
|
-
after { Object.send(:remove_const, :DummyIncWork) }
|
46
|
-
let(:iwork1) { DummyIncWork.create }
|
47
|
-
|
48
|
-
it 'should accept implementing generic_work as a child' do
|
49
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, iwork1 )
|
50
|
-
subject.save
|
51
|
-
expect( Hydra::Works::GetGenericWorksFromCollection.call( subject ) ).to eq [iwork1]
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'aggregates generic_works that extend Hydra::Works' do
|
57
|
-
before do
|
58
|
-
class DummyExtWork < Hydra::Works::GenericWork::Base
|
59
|
-
end
|
60
|
-
end
|
61
|
-
after { Object.send(:remove_const, :DummyExtWork) }
|
62
|
-
let(:ework1) { DummyExtWork.create }
|
63
|
-
|
64
|
-
it 'should accept extending generic_work as a child' do
|
65
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, ework1 )
|
66
|
-
subject.save
|
67
|
-
expect( Hydra::Works::GetGenericWorksFromCollection.call( subject ) ).to eq [ework1]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'with unacceptable child generic_works' do
|
73
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
74
|
-
let(:generic_file1) { Hydra::Works::GenericFile::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_work must be a hydra-works generic work' }
|
82
|
-
|
83
|
-
it 'should NOT aggregate Hydra::Works::Collection in hydra works collections aggregation' do
|
84
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( subject, collection1 ) }.to raise_error(ArgumentError,error_message)
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should NOT aggregate Hydra::Works::GenericFile in hydra works collections aggregation' do
|
88
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( subject, generic_file1 ) }.to raise_error(ArgumentError,error_message)
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'should NOT aggregate Hydra::PCDM::Collections in hydra works collections aggregation' do
|
92
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( subject, pcdm_collection1 ) }.to raise_error(ArgumentError,error_message)
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should NOT aggregate Hydra::PCDM::Objects in hydra works collections aggregation' do
|
96
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( subject, pcdm_object1 ) }.to raise_error(ArgumentError,error_message)
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should NOT aggregate Hydra::PCDM::Files in hydra works collections aggregation' do
|
100
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( subject, pcdm_file1 ) }.to raise_error(ArgumentError,error_message)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'should NOT aggregate non-PCDM objects in hydra works collections aggregation' do
|
104
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( subject, non_PCDM_object ) }.to raise_error(ArgumentError,error_message)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'should NOT aggregate AF::Base objects in hydra works collections aggregation' do
|
108
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( subject, af_base_object ) }.to raise_error(ArgumentError,error_message)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'with unacceptable parent collections' do
|
113
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
114
|
-
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
115
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
116
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
117
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
118
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
119
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
120
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
121
|
-
|
122
|
-
let(:error_message) { 'parent_collection must be a hydra-works collection' }
|
123
|
-
|
124
|
-
it 'should NOT accept Hydra::Works::GenericWork as parent collection' do
|
125
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( generic_work1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'should NOT accept Hydra::Works::GenericFile as parent collection' do
|
129
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( generic_file1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'should NOT accept Hydra::PCDM::Collections as parent collection' do
|
133
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( pcdm_collection1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'should NOT accept Hydra::PCDM::Objects as parent collection' do
|
137
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( pcdm_object1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'should NOT accept Hydra::PCDM::Files as parent collection' do
|
141
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( pcdm_file1, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'should NOT accept non-PCDM objects as parent collection' do
|
145
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( non_PCDM_object, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'should NOT accept AF::Base objects as parent collection' do
|
149
|
-
expect{ Hydra::Works::AddGenericWorkToCollection.call( af_base_object, generic_work2 ) }.to raise_error(ArgumentError,error_message)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
@@ -1,149 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Works::AddRelatedObjectToCollection do
|
4
|
-
|
5
|
-
let(:subject) { Hydra::Works::Collection.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(:collection1) { Hydra::Works::Collection.create }
|
13
|
-
let(:collection2) { Hydra::Works::Collection.create }
|
14
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
15
|
-
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
16
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
17
|
-
|
18
|
-
it 'should add various types of related objects to collection' do
|
19
|
-
Hydra::Works::AddRelatedObjectToCollection.call( subject, generic_work1 )
|
20
|
-
Hydra::Works::AddRelatedObjectToCollection.call( subject, generic_file1 )
|
21
|
-
Hydra::Works::AddRelatedObjectToCollection.call( subject, object1 )
|
22
|
-
related_objects = Hydra::Works::GetRelatedObjectsFromCollection.call( subject )
|
23
|
-
expect( related_objects.include? generic_work1 ).to be true
|
24
|
-
expect( related_objects.include? generic_file1 ).to be true
|
25
|
-
expect( related_objects.include? object1 ).to be true
|
26
|
-
expect( related_objects.size ).to eq 3
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with collections and generic_works' do
|
30
|
-
before do
|
31
|
-
Hydra::Works::AddCollectionToCollection.call( subject, collection1 )
|
32
|
-
Hydra::Works::AddCollectionToCollection.call( subject, collection2 )
|
33
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work1 )
|
34
|
-
Hydra::Works::AddGenericWorkToCollection.call( subject, generic_work2 )
|
35
|
-
Hydra::Works::AddRelatedObjectToCollection.call( subject, object1 )
|
36
|
-
subject.save
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should add a related object to collection with collections and generic_works' do
|
40
|
-
Hydra::Works::AddRelatedObjectToCollection.call( subject, object2 )
|
41
|
-
related_objects = Hydra::Works::GetRelatedObjectsFromCollection.call( subject )
|
42
|
-
expect( related_objects.include? object1 ).to be true
|
43
|
-
expect( related_objects.include? object2 ).to be true
|
44
|
-
expect( related_objects.size ).to eq 2
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should solrize member ids' do
|
48
|
-
skip 'skipping this test because issue #109 needs to be addressed' do
|
49
|
-
expect(subject.to_solr["generic_works_ssim"]).to include(generic_work1.id,generic_work2.id)
|
50
|
-
expect(subject.to_solr["generic_works_ssim"]).not_to include(collection2.id,collection1.id,object1.id,object2.id)
|
51
|
-
expect(subject.to_solr["collections_ssim"]).to include(collection2.id,collection1.id)
|
52
|
-
expect(subject.to_solr["collections_ssim"]).not_to include(object1.id,object2.id,generic_work1.id,generic_work2.id)
|
53
|
-
expect(subject.to_solr["related_objects_ssim"]).to include(object1.id,object2.id)
|
54
|
-
expect(subject.to_solr["related_objects_ssim"]).not_to include(collection2.id,collection1.id,generic_work1.id,generic_work2.id)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'with unacceptable child related objects' do
|
61
|
-
let(:collection1) { Hydra::Works::Collection.create }
|
62
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
63
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
64
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
65
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
66
|
-
|
67
|
-
let(:error_message) { 'child_related_object must be a pcdm object' }
|
68
|
-
|
69
|
-
it 'should NOT aggregate Hydra::Works::Collection in related objects aggregation' do
|
70
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( subject, collection1 ) }.to raise_error(ArgumentError,error_message)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should NOT aggregate Hydra::PCDM::Collections in related objects aggregation' do
|
74
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( subject, pcdm_collection1 ) }.to raise_error(ArgumentError,error_message)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should NOT aggregate Hydra::PCDM::Files in related objects aggregation' do
|
78
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( subject, pcdm_file1 ) }.to raise_error(ArgumentError,error_message)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'should NOT aggregate non-PCDM objects in related objects aggregation' do
|
82
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( subject, non_PCDM_object ) }.to raise_error(ArgumentError,error_message)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should NOT aggregate AF::Base objects in related objects aggregation' do
|
86
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( subject, af_base_object ) }.to raise_error(ArgumentError,error_message)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'with unacceptable parent collections' do
|
91
|
-
let(:pcdm_object2) { Hydra::PCDM::Object.create }
|
92
|
-
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
93
|
-
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
94
|
-
let(:pcdm_collection1) { Hydra::PCDM::Collection.create }
|
95
|
-
let(:pcdm_object1) { Hydra::PCDM::Object.create }
|
96
|
-
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
97
|
-
let(:non_PCDM_object) { "I'm not a PCDM object" }
|
98
|
-
let(:af_base_object) { ActiveFedora::Base.create }
|
99
|
-
|
100
|
-
let(:error_message) { 'parent_collection must be a hydra-works collection' }
|
101
|
-
|
102
|
-
it 'should NOT accept Hydra::Works::GenericWork as parent collection' do
|
103
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( generic_work1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'should NOT accept Hydra::Works::GenericFile as parent collection' do
|
107
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( generic_file1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should NOT accept Hydra::PCDM::Collections as parent collection' do
|
111
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( pcdm_collection1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'should NOT accept Hydra::PCDM::Objects as parent collection' do
|
115
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( pcdm_object1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should NOT accept Hydra::PCDM::Files as parent collection' do
|
119
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( pcdm_file1, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should NOT accept non-PCDM objects as parent collection' do
|
123
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( non_PCDM_object, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'should NOT accept AF::Base objects as parent collection' do
|
127
|
-
expect{ Hydra::Works::AddRelatedObjectToCollection.call( af_base_object, pcdm_object2 ) }.to raise_error(ArgumentError,error_message)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
context 'with invalid behaviors' do
|
133
|
-
let(:object1) { Hydra::PCDM::Object.create }
|
134
|
-
let(:object2) { Hydra::PCDM::Object.create }
|
135
|
-
|
136
|
-
it 'should NOT allow related objects to repeat' do
|
137
|
-
skip 'skipping this test because issue pcdm#92 needs to be addressed' do
|
138
|
-
Hydra::Works::AddRelatedObjectToCollection.call( subject, object1 )
|
139
|
-
Hydra::Works::AddRelatedObjectToCollection.call( subject, object2 )
|
140
|
-
Hydra::Works::AddRelatedObjectToCollection.call( subject, object1 )
|
141
|
-
related_objects = Hydra::Works::GetRelatedObjectsFromCollection.call( subject )
|
142
|
-
expect( related_objects.include? object1 ).to be true
|
143
|
-
expect( related_objects.include? object2 ).to be true
|
144
|
-
expect( related_objects.size ).to eq 2
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|