hydra-works 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +14 -0
- data/CONTRIBUTING.md +115 -0
- data/Gemfile +14 -0
- data/LICENSE +16 -0
- data/README.md +80 -0
- data/Rakefile +23 -0
- data/hydra-works.gemspec +33 -0
- data/lib/hydra/works.rb +81 -0
- data/lib/hydra/works/models/collection.rb +5 -0
- data/lib/hydra/works/models/concerns/aggregates_collections.rb +16 -0
- data/lib/hydra/works/models/concerns/aggregates_generic_files.rb +20 -0
- data/lib/hydra/works/models/concerns/aggregates_generic_works.rb +20 -0
- data/lib/hydra/works/models/concerns/collection_behavior.rb +28 -0
- data/lib/hydra/works/models/concerns/generic_file/contained_files.rb +22 -0
- data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +32 -0
- data/lib/hydra/works/models/concerns/generic_file/mime_types.rb +69 -0
- data/lib/hydra/works/models/concerns/generic_file_behavior.rb +25 -0
- data/lib/hydra/works/models/concerns/generic_work_behavior.rb +30 -0
- data/lib/hydra/works/models/generic_file.rb +17 -0
- data/lib/hydra/works/models/generic_work.rb +9 -0
- data/lib/hydra/works/processor.rb +9 -0
- data/lib/hydra/works/services/collection/add_collection.rb +19 -0
- data/lib/hydra/works/services/collection/add_generic_work.rb +19 -0
- data/lib/hydra/works/services/collection/add_related_object.rb +19 -0
- data/lib/hydra/works/services/collection/get_collections.rb +17 -0
- data/lib/hydra/works/services/collection/get_generic_works.rb +17 -0
- data/lib/hydra/works/services/collection/get_related_objects.rb +17 -0
- data/lib/hydra/works/services/collection/remove_collection.rb +19 -0
- data/lib/hydra/works/services/collection/remove_generic_work.rb +20 -0
- data/lib/hydra/works/services/collection/remove_related_object.rb +19 -0
- data/lib/hydra/works/services/generic_file/add_file.rb +55 -0
- data/lib/hydra/works/services/generic_file/add_generic_file.rb +19 -0
- data/lib/hydra/works/services/generic_file/add_original_file.rb +11 -0
- data/lib/hydra/works/services/generic_file/add_related_object.rb +19 -0
- data/lib/hydra/works/services/generic_file/add_versioned_original_file.rb +10 -0
- data/lib/hydra/works/services/generic_file/generate/thumbnail.rb +19 -0
- data/lib/hydra/works/services/generic_file/get_generic_files.rb +17 -0
- data/lib/hydra/works/services/generic_file/get_related_objects.rb +17 -0
- data/lib/hydra/works/services/generic_file/remove_generic_file.rb +20 -0
- data/lib/hydra/works/services/generic_file/remove_related_object.rb +19 -0
- data/lib/hydra/works/services/generic_file/upload_file.rb +32 -0
- data/lib/hydra/works/services/generic_work/add_generic_file.rb +19 -0
- data/lib/hydra/works/services/generic_work/add_generic_work.rb +19 -0
- data/lib/hydra/works/services/generic_work/add_related_object.rb +19 -0
- data/lib/hydra/works/services/generic_work/get_generic_files.rb +17 -0
- data/lib/hydra/works/services/generic_work/get_generic_works.rb +17 -0
- data/lib/hydra/works/services/generic_work/get_related_objects.rb +17 -0
- data/lib/hydra/works/services/generic_work/move_generic_file.rb +19 -0
- data/lib/hydra/works/services/generic_work/remove_generic_file.rb +20 -0
- data/lib/hydra/works/services/generic_work/remove_generic_work.rb +20 -0
- data/lib/hydra/works/services/generic_work/remove_related_object.rb +19 -0
- data/lib/hydra/works/version.rb +5 -0
- data/lib/hydra/works/vocab/works_terms.rb +12 -0
- data/spec/fixtures/sample-file.pdf +0 -0
- data/spec/fixtures/updated-file.txt +1 -0
- data/spec/hydra/works/models/collection_spec.rb +41 -0
- data/spec/hydra/works/models/concerns/file/contained_files_spec.rb +113 -0
- data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +12 -0
- data/spec/hydra/works/models/generic_file_spec.rb +45 -0
- data/spec/hydra/works/models/generic_work_spec.rb +50 -0
- data/spec/hydra/works/services/collection/add_collection_spec.rb +166 -0
- data/spec/hydra/works/services/collection/add_generic_work_spec.rb +155 -0
- data/spec/hydra/works/services/collection/add_related_object_spec.rb +149 -0
- data/spec/hydra/works/services/collection/get_collections_spec.rb +35 -0
- data/spec/hydra/works/services/collection/get_generic_works_spec.rb +35 -0
- data/spec/hydra/works/services/collection/get_related_objects_spec.rb +49 -0
- data/spec/hydra/works/services/collection/remove_collection_spec.rb +133 -0
- data/spec/hydra/works/services/collection/remove_generic_work_spec.rb +133 -0
- data/spec/hydra/works/services/collection/remove_related_object_spec.rb +128 -0
- data/spec/hydra/works/services/generic_file/add_file_spec.rb +28 -0
- data/spec/hydra/works/services/generic_file/add_generic_file_spec.rb +174 -0
- data/spec/hydra/works/services/generic_file/add_related_object_spec.rb +150 -0
- data/spec/hydra/works/services/generic_file/generate/thumbnail_spec.rb +21 -0
- data/spec/hydra/works/services/generic_file/get_generic_files_spec.rb +19 -0
- data/spec/hydra/works/services/generic_file/get_related_objects_spec.rb +45 -0
- data/spec/hydra/works/services/generic_file/remove_generic_file_spec.rb +124 -0
- data/spec/hydra/works/services/generic_file/remove_related_object_spec.rb +123 -0
- data/spec/hydra/works/services/generic_file/upload_file_spec.rb +82 -0
- data/spec/hydra/works/services/generic_work/add_generic_file_spec.rb +156 -0
- data/spec/hydra/works/services/generic_work/add_generic_work_spec.rb +157 -0
- data/spec/hydra/works/services/generic_work/add_related_object_spec.rb +148 -0
- data/spec/hydra/works/services/generic_work/get_generic_files_spec.rb +35 -0
- data/spec/hydra/works/services/generic_work/get_generic_works_spec.rb +35 -0
- data/spec/hydra/works/services/generic_work/get_related_objects_spec.rb +46 -0
- data/spec/hydra/works/services/generic_work/move_generic_file_spec.rb +21 -0
- data/spec/hydra/works/services/generic_work/remove_generic_file_spec.rb +132 -0
- data/spec/hydra/works/services/generic_work/remove_generic_work_spec.rb +133 -0
- data/spec/hydra/works/services/generic_work/remove_related_object_spec.rb +128 -0
- data/spec/hydra/works_spec.rb +149 -0
- data/spec/spec_helper.rb +40 -0
- data/use-cases/conference_event_use_case.md +16 -0
- data/use-cases/lafayette_college_geospatial_use_case.md +80 -0
- data/use-cases/northwestern_adminset_use-case.md +19 -0
- data/use-cases/northwestern_displayset_use_case.md +23 -0
- data/use-cases/northwestern_playlist_use_case.md +21 -0
- data/use-cases/princeton_book_use_case.md +117 -0
- data/use-cases/scholarsphere_use_case.md +32 -0
- data/use-cases/stanford_data_model_use_case.md +86 -0
- data/use-cases/ucin_linked_resource_use_case.md +21 -0
- metadata +338 -0
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
some updated content
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::Collection do
|
4
|
+
|
5
|
+
let(:collection1) { Hydra::Works::Collection.create }
|
6
|
+
let(:collection2) { Hydra::Works::Collection.create }
|
7
|
+
let(:collection3) { Hydra::Works::Collection.create }
|
8
|
+
|
9
|
+
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
10
|
+
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
11
|
+
|
12
|
+
describe '#collections=' do
|
13
|
+
it 'should aggregate collections' do
|
14
|
+
collection1.collections = [collection2, collection3]
|
15
|
+
collection1.save
|
16
|
+
expect(collection1.collections).to eq [collection2, collection3]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#generic_works=' do
|
21
|
+
it 'should aggregate generic_works' do
|
22
|
+
collection1.generic_works = [generic_work1,generic_work2]
|
23
|
+
collection1.save
|
24
|
+
expect(collection1.generic_works).to eq [generic_work1,generic_work2]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'Related objects' do
|
29
|
+
let(:object) { Hydra::PCDM::Object.create }
|
30
|
+
let(:collection) { Hydra::Works::Collection.create }
|
31
|
+
|
32
|
+
before do
|
33
|
+
collection.related_objects = [object]
|
34
|
+
collection.save
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'persists' do
|
38
|
+
expect(collection.reload.related_objects).to eq [object]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::GenericFile::ContainedFiles do
|
4
|
+
|
5
|
+
let(:generic_file) do
|
6
|
+
Hydra::Works::GenericFile::Base.create
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:thumbnail) do
|
10
|
+
file = generic_file.files.build
|
11
|
+
Hydra::PCDM::AddTypeToFile.call(file, pcdm_thumbnail_uri)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:file) { generic_file.files.build }
|
15
|
+
let(:pcdm_thumbnail_uri) { ::RDF::URI("http://pcdm.org/ThumbnailImage") }
|
16
|
+
|
17
|
+
before do
|
18
|
+
generic_file.files = [file]
|
19
|
+
generic_file.save
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#thumbnail" do
|
23
|
+
|
24
|
+
context "when a thumbnail is present" do
|
25
|
+
before do
|
26
|
+
generic_file.thumbnail.content = "thumbnail"
|
27
|
+
end
|
28
|
+
subject { generic_file.thumbnail }
|
29
|
+
it "can be saved without errors" do
|
30
|
+
expect(subject.save).to be_truthy
|
31
|
+
end
|
32
|
+
it "retrieves content of the thumbnail" do
|
33
|
+
expect(subject.content).to eql "thumbnail"
|
34
|
+
end
|
35
|
+
it "retains origin pcdm.File RDF type" do
|
36
|
+
expect(subject.metadata_node.type).to include( ::RDF::URI("http://pcdm.org/ThumbnailImage") )
|
37
|
+
expect(subject.metadata_node.type).to include(RDFVocabularies::PCDMTerms.File)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when no thumbnail is present" do
|
42
|
+
subject { generic_file.thumbnail }
|
43
|
+
it "initializes an unsaved File object with Thumbnail type" do
|
44
|
+
expect(subject).to be_new_record
|
45
|
+
expect(subject.metadata_node.type).to include(pcdm_thumbnail_uri)
|
46
|
+
expect(subject.metadata_node.type).to include(RDFVocabularies::PCDMTerms.File)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#original_file" do
|
53
|
+
|
54
|
+
context "when an original file is present" do
|
55
|
+
before do
|
56
|
+
generic_file.original_file.content = "original_file"
|
57
|
+
end
|
58
|
+
subject { generic_file.original_file }
|
59
|
+
|
60
|
+
it "can be saved without errors" do
|
61
|
+
expect(subject.save).to be_truthy
|
62
|
+
end
|
63
|
+
it "retrieves content of the original_file" do
|
64
|
+
expect(subject.content).to eql "original_file"
|
65
|
+
end
|
66
|
+
it "retains origin pcdm.File RDF type" do
|
67
|
+
expect(subject.metadata_node.type).to include(::RDF::URI("http://pcdm.org/OriginalFile") )
|
68
|
+
expect(generic_file.original_file.metadata_node.type).to include(RDFVocabularies::PCDMTerms.File)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when no original file is present" do
|
73
|
+
subject { generic_file.original_file }
|
74
|
+
it "initializes an unsaved File object with OrignalFile type" do
|
75
|
+
expect(subject).to be_new_record
|
76
|
+
expect(subject.metadata_node.type).to include(::RDF::URI("http://pcdm.org/OriginalFile") )
|
77
|
+
expect(subject.metadata_node.type).to include(RDFVocabularies::PCDMTerms.File)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#extracted_text" do
|
84
|
+
|
85
|
+
context "when extracted text is present" do
|
86
|
+
before do
|
87
|
+
generic_file.extracted_text.content = "extracted_text"
|
88
|
+
end
|
89
|
+
subject { generic_file.extracted_text }
|
90
|
+
it "can be saved without errors" do
|
91
|
+
expect(subject.save).to be_truthy
|
92
|
+
end
|
93
|
+
it "retrieves content of the extracted_text" do
|
94
|
+
expect(subject.content).to eql "extracted_text"
|
95
|
+
end
|
96
|
+
it "retains origin pcdm.File RDF type" do
|
97
|
+
expect(subject.metadata_node.type).to include(::RDF::URI("http://pcdm.org/ExtractedText") )
|
98
|
+
expect(subject.metadata_node.type).to include(RDFVocabularies::PCDMTerms.File)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "when no extracted text is present" do
|
103
|
+
subject { generic_file.extracted_text }
|
104
|
+
it "initializes an unsaved File object with ExtractedText type" do
|
105
|
+
expect(subject).to be_new_record
|
106
|
+
expect(subject.metadata_node.type).to include(::RDF::URI("http://pcdm.org/ExtractedText") )
|
107
|
+
expect(subject.metadata_node.type).to include(RDFVocabularies::PCDMTerms.File)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::GenericFileBehavior do
|
4
|
+
class IncludesGenericFileBehavior < ActiveFedora::Base
|
5
|
+
include Hydra::Works::GenericFileBehavior
|
6
|
+
end
|
7
|
+
subject { IncludesGenericFileBehavior.new }
|
8
|
+
|
9
|
+
it "ensures that objects will be recognized as generic_files" do
|
10
|
+
expect(Hydra::Works.generic_file? subject).to be_truthy
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::GenericFile::Base do
|
4
|
+
|
5
|
+
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
6
|
+
let(:generic_file2) { Hydra::Works::GenericFile::Base.create }
|
7
|
+
let(:generic_file3) { Hydra::Works::GenericFile::Base.create }
|
8
|
+
|
9
|
+
describe '#generic_files=' do
|
10
|
+
it 'should aggregate generic_files' do
|
11
|
+
generic_file1.generic_files = [generic_file2, generic_file3]
|
12
|
+
generic_file1.save
|
13
|
+
expect(generic_file1.generic_files).to eq [generic_file2, generic_file3]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'Related objects' do
|
18
|
+
let(:object1) { Hydra::PCDM::Object.create }
|
19
|
+
|
20
|
+
before do
|
21
|
+
generic_file1.related_objects = [object1]
|
22
|
+
generic_file1.save
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'persists' do
|
26
|
+
expect(generic_file1.reload.related_objects).to eq [object1]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#files' do
|
31
|
+
let(:object) { described_class.create }
|
32
|
+
let(:file1) { object.files.build }
|
33
|
+
let(:file2) { object.files.build }
|
34
|
+
|
35
|
+
before do
|
36
|
+
file1.content = "I'm a file"
|
37
|
+
file2.content = "I am too"
|
38
|
+
object.save!
|
39
|
+
end
|
40
|
+
|
41
|
+
subject { described_class.find(object.id).files }
|
42
|
+
|
43
|
+
it { is_expected.to eq [file1, file2] }
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::GenericWork do
|
4
|
+
|
5
|
+
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
6
|
+
let(:generic_work2) { Hydra::Works::GenericWork::Base.create }
|
7
|
+
let(:generic_work3) { Hydra::Works::GenericWork::Base.create }
|
8
|
+
|
9
|
+
let(:generic_file1) { Hydra::Works::GenericFile::Base.create }
|
10
|
+
let(:generic_file2) { Hydra::Works::GenericFile::Base.create }
|
11
|
+
|
12
|
+
let(:pcdm_file1) { Hydra::PCDM::File.new }
|
13
|
+
|
14
|
+
describe '#generic_works=' do
|
15
|
+
it 'should aggregate generic_works' do
|
16
|
+
generic_work1.generic_works = [generic_work2, generic_work3]
|
17
|
+
generic_work1.save
|
18
|
+
expect(generic_work1.generic_works).to eq [generic_work2, generic_work3]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#generic_files=' do
|
23
|
+
it 'should aggregate generic_files' do
|
24
|
+
generic_work1.generic_files = [generic_file1, generic_file2]
|
25
|
+
generic_work1.save
|
26
|
+
expect(generic_work1.generic_files).to eq [generic_file1, generic_file2]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#contains' do
|
31
|
+
it 'should present as a missing method' do
|
32
|
+
expect{ generic_work1.contains = [pcdm_file1] }.to raise_error(NoMethodError,"works can not directly contain files. You must add a GenericFile to the work's members and add files to that GenericFile.")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'Related objects' do
|
37
|
+
let(:generic_work1) { Hydra::Works::GenericWork::Base.create }
|
38
|
+
let(:object1) { Hydra::PCDM::Object.create }
|
39
|
+
|
40
|
+
before do
|
41
|
+
generic_work1.related_objects = [object1]
|
42
|
+
generic_work1.save
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'persists' do
|
46
|
+
expect(generic_work1.reload.related_objects).to eq [object1]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,166 @@
|
|
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
|