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
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::AddFileToGenericFile do
|
4
|
+
|
5
|
+
let(:generic_file) { Hydra::Works::GenericFile::Base.new }
|
6
|
+
let(:filename) { "sample-file.pdf" }
|
7
|
+
let(:filename2) { "updated-file.txt" }
|
8
|
+
let(:original_name) { "original-name.pdf" }
|
9
|
+
let(:file) { File.open(File.join(fixture_path, filename)) }
|
10
|
+
let(:file2) { File.open(File.join(fixture_path, filename2)) }
|
11
|
+
let(:type) { ::RDF::URI("http://pcdm.org/use#ExtractedText") }
|
12
|
+
let(:update_existing) { true }
|
13
|
+
let(:mime_type) { "application/pdf" }
|
14
|
+
|
15
|
+
context "when generic_file is not persisted" do
|
16
|
+
let(:generic_file) { Hydra::Works::GenericFile::Base.new }
|
17
|
+
it "saves generic_file" do
|
18
|
+
described_class.call(generic_file, file, type)
|
19
|
+
expect(generic_file.persisted?).to be true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when generic_file is not valid" do
|
24
|
+
before do
|
25
|
+
generic_file.save
|
26
|
+
allow(generic_file).to receive(:valid?).and_return(false)
|
27
|
+
end
|
28
|
+
it "returns false" do
|
29
|
+
expect( described_class.call(generic_file, file, type) ).to be false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "file responds to :mime_type and :original_name" do
|
34
|
+
before do
|
35
|
+
allow(file).to receive(:mime_type).and_return(mime_type)
|
36
|
+
allow(file).to receive(:original_name).and_return(original_name)
|
37
|
+
described_class.call(generic_file, file, type)
|
38
|
+
end
|
39
|
+
subject { generic_file.filter_files_by_type(type).first }
|
40
|
+
it "uses the mime_type and original_name methods" do
|
41
|
+
expect(subject.mime_type).to eq(mime_type)
|
42
|
+
expect(subject.original_name).to eq(original_name)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "file responds to :path but not to :mime_type nor :original_name" do
|
47
|
+
it "defaults to Hydra::PCDM for mimetype and ::File for basename." do
|
48
|
+
expect(Hydra::PCDM::GetMimeTypeForFile).to receive(:call).with(file.path)
|
49
|
+
expect(::File).to receive(:basename).with(file.path)
|
50
|
+
described_class.call(generic_file, file, type)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "adds the given file and applies the specified type to it" do
|
55
|
+
described_class.call(generic_file, file, type, update_existing: update_existing)
|
56
|
+
expect(generic_file.filter_files_by_type(type).first.content).to start_with("%PDF-1.3")
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when :type is the name of an association" do
|
60
|
+
let(:type) { :extracted_text }
|
61
|
+
before do
|
62
|
+
described_class.call(generic_file, file, type)
|
63
|
+
end
|
64
|
+
it "builds and uses the association's target" do
|
65
|
+
expect(generic_file.extracted_text.content).to start_with("%PDF-1.3")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when :versioning => true" do
|
70
|
+
let(:type) { :original_file }
|
71
|
+
let(:versioning) { true }
|
72
|
+
subject { generic_file }
|
73
|
+
it "updates the file and creates a version" do
|
74
|
+
described_class.call(generic_file, file, type, versioning: versioning)
|
75
|
+
expect(subject.original_file.versions.all.count).to eq(1)
|
76
|
+
expect(subject.original_file.content).to start_with("%PDF-1.3")
|
77
|
+
end
|
78
|
+
context "and there are already versions" do
|
79
|
+
before do
|
80
|
+
described_class.call(generic_file, file, type, versioning: versioning)
|
81
|
+
described_class.call(generic_file, file2, type, versioning: versioning)
|
82
|
+
end
|
83
|
+
it "adds to the version history" do
|
84
|
+
expect(subject.original_file.versions.all.count).to eq(2)
|
85
|
+
expect(subject.original_file.content).to eq("some updated content\n")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when :versioning => false" do
|
91
|
+
let(:type) { :original_file }
|
92
|
+
let(:versioning) { false }
|
93
|
+
before do
|
94
|
+
described_class.call(generic_file, file, type, versioning: versioning)
|
95
|
+
end
|
96
|
+
subject { generic_file }
|
97
|
+
it "skips creating versions" do
|
98
|
+
expect(subject.original_file.versions.all.count).to eq(0)
|
99
|
+
expect(subject.original_file.content).to start_with("%PDF-1.3")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "type_to_uri" do
|
104
|
+
subject { Hydra::Works::AddFileToGenericFile::Updater.allocate }
|
105
|
+
it "converts URI strings to RDF::URI" do
|
106
|
+
expect(subject.send(:type_to_uri, "http://example.com/CustomURI" )).to eq(::RDF::URI("http://example.com/CustomURI"))
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -2,39 +2,45 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hydra::Works::UploadFileToGenericFile do
|
4
4
|
|
5
|
-
let(:generic_work) { Hydra::Works::GenericWork::Base.
|
6
|
-
let(:generic_file) { Hydra::Works::GenericFile::Base.
|
7
|
-
let(:
|
8
|
-
let(:
|
9
|
-
let(:updated_filename) { "updated-file.txt"}
|
10
|
-
let(:updated_file) { File.join(fixture_path, updated_filename) }
|
5
|
+
let(:generic_work) { Hydra::Works::GenericWork::Base.new }
|
6
|
+
let(:generic_file) { Hydra::Works::GenericFile::Base.new }
|
7
|
+
let(:file) { File.open(File.join(fixture_path, "sample-file.pdf")) }
|
8
|
+
let(:updated_file) { File.open(File.join(fixture_path, "updated-file.txt")) }
|
11
9
|
let(:mime_type) { "application/pdf" }
|
12
|
-
let(:
|
10
|
+
let(:original_name) { "my_original.pdf" }
|
11
|
+
let(:updated_mime_type) { "text/plain" }
|
12
|
+
let(:updated_name) { "my_updated.txt" }
|
13
13
|
let(:additional_services) { [Hydra::Works::GenerateThumbnail] }
|
14
14
|
|
15
|
-
context "
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
context "when you provide mime_type and original_name, etc" do
|
16
|
+
it "uses the provided values" do
|
17
|
+
expect(Hydra::Works::AddFileToGenericFile).to receive(:call).with(generic_file, file, :original_file, update_existing: true, versioning: true )
|
18
|
+
described_class.call(generic_file, file )
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
# Duplicate test from add_file_spec
|
23
|
+
context "without a proper generic file" do
|
24
|
+
let(:error_message) { "supplied object must be a generic file" }
|
24
25
|
it "raises an error" do
|
25
|
-
expect( lambda { described_class.call(
|
26
|
+
expect( lambda { described_class.call(generic_work, file) }).to raise_error(ArgumentError, error_message)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
# Duplicate test from add_file_spec
|
31
|
+
context "without file that responds to read." do
|
32
|
+
let(:error_message) { "supplied file must respond to read" }
|
31
33
|
it "raises an error" do
|
32
|
-
expect( lambda { described_class.call(generic_file, "
|
34
|
+
expect( lambda { described_class.call(generic_file, ["this does not respond to read."]) }).to raise_error(ArgumentError, error_message)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
38
|
context "with an empty generic file" do
|
37
|
-
before
|
39
|
+
before do
|
40
|
+
allow(file).to receive(:mime_type).and_return(mime_type)
|
41
|
+
allow(file).to receive(:original_name).and_return(original_name)
|
42
|
+
described_class.call(generic_file, file, additional_services: additional_services)
|
43
|
+
end
|
38
44
|
|
39
45
|
describe "the uploaded file" do
|
40
46
|
subject { generic_file.original_file }
|
@@ -45,38 +51,49 @@ describe Hydra::Works::UploadFileToGenericFile do
|
|
45
51
|
expect(subject.mime_type).to eql mime_type
|
46
52
|
end
|
47
53
|
it "has a name" do
|
48
|
-
expect(subject.original_name).to eql
|
54
|
+
expect(subject.original_name).to eql original_name
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
52
58
|
describe "the generic file's generated files" do
|
53
59
|
subject { generic_file }
|
54
|
-
it "has
|
60
|
+
it "has content and generated files" do
|
61
|
+
expect(subject.original_file.content).to start_with("%PDF-1.3")
|
62
|
+
expect(subject.original_file.mime_type).to eql mime_type
|
63
|
+
expect(subject.original_file.original_name).to eql original_name
|
55
64
|
expect(subject.thumbnail.content).not_to be_nil
|
56
65
|
end
|
57
66
|
end
|
58
67
|
end
|
59
68
|
|
60
|
-
context "when
|
69
|
+
context "when updating an existing file" do
|
70
|
+
let(:additional_services) { [] }
|
71
|
+
|
61
72
|
before do
|
62
|
-
|
63
|
-
|
64
|
-
|
73
|
+
allow(file).to receive(:mime_type).and_return(mime_type)
|
74
|
+
allow(file).to receive(:original_name).and_return(original_name)
|
75
|
+
allow(updated_file).to receive(:mime_type).and_return(updated_mime_type)
|
76
|
+
allow(updated_file).to receive(:original_name).and_return(updated_name)
|
77
|
+
|
78
|
+
described_class.call(generic_file, file, additional_services: additional_services)
|
79
|
+
described_class.call(generic_file, updated_file, additional_services: additional_services, update_existing: true)
|
65
80
|
end
|
66
81
|
|
67
82
|
describe "the new file" do
|
68
83
|
subject { generic_file.original_file }
|
69
84
|
it "has updated content" do
|
70
|
-
|
85
|
+
updated_file.rewind
|
86
|
+
expect(subject.content).to eql updated_file.read
|
71
87
|
end
|
72
88
|
it "has an updated name" do
|
73
|
-
expect(subject.original_name).to eql
|
89
|
+
expect(subject.original_name).to eql updated_name
|
74
90
|
end
|
75
91
|
it "has a updated mime type" do
|
76
92
|
expect(subject.mime_type).to eql updated_mime_type
|
77
|
-
|
93
|
+
expect(subject.versions.all.count).to eql 2
|
94
|
+
end
|
78
95
|
end
|
79
96
|
end
|
80
97
|
|
81
98
|
end
|
82
|
-
|
99
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::Works::PersistDerivative do
|
4
|
+
|
5
|
+
describe 'thumbnail generation' do
|
6
|
+
before do
|
7
|
+
file = File.open(File.join(fixture_path, file_name), 'r')
|
8
|
+
Hydra::Works::UploadFileToGenericFile.call(generic_file, file)
|
9
|
+
allow_any_instance_of(Hydra::Works::GenericFile::Base).to receive(:mime_type).and_return(mime_type)
|
10
|
+
generic_file.save!
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'with a video (.avi) file' do
|
14
|
+
let(:mime_type) { 'video/avi' }
|
15
|
+
let(:file_name) { 'countdown.avi' }
|
16
|
+
let(:generic_file) { Hydra::Works::GenericFile::Base.new }
|
17
|
+
|
18
|
+
it 'lacks a thumbnail' do
|
19
|
+
expect(generic_file.thumbnail).to be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'generates a thumbnail derivative', unless: ENV['CI'] do
|
23
|
+
generic_file.create_derivatives
|
24
|
+
expect(generic_file.thumbnail).to have_content
|
25
|
+
expect(generic_file.thumbnail.mime_type).to eq('image/jpeg')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with an image file' do
|
30
|
+
let(:mime_type) { 'image/png' }
|
31
|
+
let(:file_name) { 'world.png' }
|
32
|
+
let(:generic_file) { Hydra::Works::GenericFile::Base.new }
|
33
|
+
|
34
|
+
it 'lacks a thumbnail' do
|
35
|
+
expect(generic_file.thumbnail).to be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'uses PersistDerivative service to generate a thumbnail derivative' do
|
39
|
+
generic_file.create_derivatives
|
40
|
+
expect(Hydra::Derivatives.output_file_service).to eq(Hydra::Works::PersistDerivative)
|
41
|
+
expect(generic_file.thumbnail).to have_content
|
42
|
+
expect(generic_file.thumbnail.mime_type).to eq('image/jpeg')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with an audio (.wav) file' do
|
47
|
+
let(:mime_type) { 'audio/wav' }
|
48
|
+
let(:file_name) { 'piano_note.wav' }
|
49
|
+
let(:generic_file) { Hydra::Works::GenericFile::Base.new }
|
50
|
+
|
51
|
+
it 'lacks a thumbnail' do
|
52
|
+
expect(generic_file.thumbnail).to be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'does not generate a thumbnail when derivatives are created', unless: ENV['CI'] do
|
56
|
+
generic_file.create_derivatives
|
57
|
+
expect(generic_file.thumbnail).to be_nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with an image (.jp2) file' do
|
62
|
+
let(:mime_type) { 'image/jp2' }
|
63
|
+
let(:file_name) { 'image.jp2' }
|
64
|
+
let(:generic_file) { Hydra::Works::GenericFile::Base.new }
|
65
|
+
|
66
|
+
it 'lacks a thumbnail' do
|
67
|
+
expect(generic_file.thumbnail).to be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'generates a thumbnail on job run' do
|
71
|
+
generic_file.create_derivatives
|
72
|
+
expect(generic_file.thumbnail).to have_content
|
73
|
+
expect(generic_file.thumbnail.mime_type).to eq('image/jpeg')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'with an office document (.docx) file' do
|
78
|
+
let(:mime_type) { 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
|
79
|
+
let(:file_name) { 'charter.docx' }
|
80
|
+
let(:generic_file) { Hydra::Works::GenericFile::Base.new }
|
81
|
+
|
82
|
+
it 'lacks a thumbnail' do
|
83
|
+
expect(generic_file.thumbnail).to be_nil
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'generates a thumbnail on job run', unless: ENV['CI'] do
|
87
|
+
generic_file.create_derivatives
|
88
|
+
expect(generic_file.thumbnail).to have_content
|
89
|
+
expect(generic_file.thumbnail.mime_type).to eq('image/jpeg')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/spec/hydra/works_spec.rb
CHANGED
@@ -2,91 +2,91 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hydra::Works do
|
4
4
|
|
5
|
-
let(:works_coll) { Hydra::Works::Collection.
|
6
|
-
let(:works_gwork) { Hydra::Works::GenericWork::Base.
|
7
|
-
let(:works_gfile) { Hydra::Works::GenericFile::Base.
|
5
|
+
let(:works_coll) { Hydra::Works::Collection.new }
|
6
|
+
let(:works_gwork) { Hydra::Works::GenericWork::Base.new }
|
7
|
+
let(:works_gfile) { Hydra::Works::GenericFile::Base.new }
|
8
8
|
|
9
|
-
let(:pcdm_coll) { Hydra::PCDM::Collection.
|
10
|
-
let(:pcdm_obj) { Hydra::PCDM::Object.
|
9
|
+
let(:pcdm_coll) { Hydra::PCDM::Collection.new }
|
10
|
+
let(:pcdm_obj) { Hydra::PCDM::Object.new }
|
11
11
|
let(:pcdm_file) { Hydra::PCDM::File.new }
|
12
12
|
|
13
13
|
describe 'Validations' do
|
14
14
|
|
15
|
-
describe "#
|
15
|
+
describe "#works_collection?" do
|
16
16
|
it "should return true for a works collection" do
|
17
|
-
expect(
|
17
|
+
expect( works_coll.works_collection? ).to be true
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return false for a works generic work" do
|
21
|
-
expect(
|
21
|
+
expect( works_gwork.works_collection? ).to be false
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should return false for a works generic file" do
|
25
|
-
expect(
|
25
|
+
expect( works_gfile.works_collection? ).to be false
|
26
26
|
end
|
27
27
|
|
28
|
-
it "should return
|
29
|
-
expect(
|
28
|
+
it "should return that method is not available for pcdm a collection" do
|
29
|
+
expect(pcdm_coll).not_to respond_to(:works_collection?)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "should return
|
33
|
-
expect(
|
32
|
+
it "should return that method is not available for a pcdm object" do
|
33
|
+
expect(pcdm_obj).not_to respond_to(:works_collection?)
|
34
34
|
end
|
35
35
|
|
36
|
-
it "should return
|
37
|
-
expect(
|
36
|
+
it "should return that method is not available for a pcdm file" do
|
37
|
+
expect(pcdm_file).not_to respond_to(:works_collection?)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe "#
|
41
|
+
describe "#works_generic_work?" do
|
42
42
|
it "should return false for a works collection" do
|
43
|
-
expect(
|
43
|
+
expect( works_coll.works_generic_work? ).to be false
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should return true for a works generic work" do
|
47
|
-
expect(
|
47
|
+
expect( works_gwork.works_generic_work? ).to be true
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should return false for a works generic file" do
|
51
|
-
expect(
|
51
|
+
expect( works_gfile.works_generic_work? ).to be false
|
52
52
|
end
|
53
53
|
|
54
|
-
it "should return
|
55
|
-
expect(
|
54
|
+
it "should return that method is not available for a pcdm collection" do
|
55
|
+
expect(pcdm_coll).not_to respond_to(:works_generic_work?)
|
56
56
|
end
|
57
57
|
|
58
|
-
it "should return
|
59
|
-
expect(
|
58
|
+
it "should return that method is not available for a pcdm object" do
|
59
|
+
expect(pcdm_obj).not_to respond_to(:works_generic_work?)
|
60
60
|
end
|
61
61
|
|
62
|
-
it "should return
|
63
|
-
expect(
|
62
|
+
it "should return that method is not available for a pcdm file" do
|
63
|
+
expect(pcdm_file).not_to respond_to(:works_generic_work?)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
describe "#
|
67
|
+
describe "#works_generic_file?" do
|
68
68
|
it "should return false for a works collection" do
|
69
|
-
expect(
|
69
|
+
expect( works_coll.works_generic_file? ).to be false
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should return false for a works generic work" do
|
73
|
-
expect(
|
73
|
+
expect( works_gwork.works_generic_file? ).to be false
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should return true for a works generic file" do
|
77
|
-
expect(
|
77
|
+
expect( works_gfile.works_generic_file? ).to be true
|
78
78
|
end
|
79
79
|
|
80
|
-
it "should return
|
81
|
-
expect(
|
80
|
+
it "should return that method is not available for a pcdm collection" do
|
81
|
+
expect(pcdm_coll).not_to respond_to(:works_generic_file?)
|
82
82
|
end
|
83
83
|
|
84
|
-
it "should return
|
85
|
-
expect(
|
84
|
+
it "should return that method is not available for a pcdm object" do
|
85
|
+
expect(pcdm_obj).not_to respond_to(:works_generic_file?)
|
86
86
|
end
|
87
87
|
|
88
|
-
it "should return
|
89
|
-
expect(
|
88
|
+
it "should return that method is not available for a pcdm file" do
|
89
|
+
expect(pcdm_file).not_to respond_to(:works_generic_file?)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|