ddr-models 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +12 -0
- data/README.md +5 -0
- data/Rakefile +37 -0
- data/app/models/attachment.rb +7 -0
- data/app/models/collection.rb +54 -0
- data/app/models/component.rb +15 -0
- data/app/models/item.rb +19 -0
- data/app/models/solr_document.rb +36 -0
- data/app/models/target.rb +8 -0
- data/config/initializers/active_fedora_base.rb +77 -0
- data/config/initializers/active_fedora_datastream.rb +5 -0
- data/config/initializers/ddr.rb +8 -0
- data/config/initializers/devise.rb +245 -0
- data/config/initializers/devise.rb~ +245 -0
- data/config/initializers/subscriptions.rb +15 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20141021233359_create_events.rb +28 -0
- data/db/migrate/20141021234156_create_minted_ids.rb +19 -0
- data/db/migrate/20141103192146_create_workflow_state.rb +13 -0
- data/db/migrate/20141104181418_create_users.rb +34 -0
- data/db/migrate/20141104181418_create_users.rb~ +6 -0
- data/lib/ddr-models.rb +1 -0
- data/lib/ddr/actions.rb +8 -0
- data/lib/ddr/actions/fixity_check.rb +35 -0
- data/lib/ddr/auth.rb +45 -0
- data/lib/ddr/auth.rb~ +47 -0
- data/lib/ddr/auth/ability.rb +204 -0
- data/lib/ddr/auth/ability.rb~ +204 -0
- data/lib/ddr/auth/group_service.rb +53 -0
- data/lib/ddr/auth/group_service.rb~ +53 -0
- data/lib/ddr/auth/grouper_service.rb +76 -0
- data/lib/ddr/auth/grouper_service.rb~ +77 -0
- data/lib/ddr/auth/remote_group_service.rb +35 -0
- data/lib/ddr/auth/remote_group_service.rb~ +35 -0
- data/lib/ddr/auth/superuser.rb +13 -0
- data/lib/ddr/auth/superuser.rb~ +9 -0
- data/lib/ddr/auth/user.rb +71 -0
- data/lib/ddr/auth/user.rb~ +65 -0
- data/lib/ddr/configurable.rb +34 -0
- data/lib/ddr/datastreams.rb +32 -0
- data/lib/ddr/datastreams/content_metadata_datastream.rb +147 -0
- data/lib/ddr/datastreams/datastream_behavior.rb +95 -0
- data/lib/ddr/datastreams/descriptive_metadata_datastream.rb +84 -0
- data/lib/ddr/datastreams/properties_datastream.rb +25 -0
- data/lib/ddr/datastreams/role_assignments_datastream.rb +19 -0
- data/lib/ddr/events.rb +17 -0
- data/lib/ddr/events/creation_event.rb +12 -0
- data/lib/ddr/events/event.rb +163 -0
- data/lib/ddr/events/fixity_check_event.rb +43 -0
- data/lib/ddr/events/ingestion_event.rb +12 -0
- data/lib/ddr/events/preservation_event_behavior.rb +37 -0
- data/lib/ddr/events/preservation_event_type.rb +24 -0
- data/lib/ddr/events/reindex_object_after_save.rb +18 -0
- data/lib/ddr/events/update_event.rb +9 -0
- data/lib/ddr/events/validation_event.rb +11 -0
- data/lib/ddr/events/virus_check_event.rb +30 -0
- data/lib/ddr/index_fields.rb +39 -0
- data/lib/ddr/metadata.rb +22 -0
- data/lib/ddr/metadata/duke_terms.rb +15 -0
- data/lib/ddr/metadata/premis_event.rb +59 -0
- data/lib/ddr/metadata/rdf_vocabulary_parser.rb +45 -0
- data/lib/ddr/metadata/roles_vocabulary.rb +10 -0
- data/lib/ddr/metadata/sources/duketerms.rdf.xml +856 -0
- data/lib/ddr/metadata/vocabulary.rb +37 -0
- data/lib/ddr/models.rb +60 -0
- data/lib/ddr/models/access_controllable.rb +23 -0
- data/lib/ddr/models/base.rb +37 -0
- data/lib/ddr/models/describable.rb +81 -0
- data/lib/ddr/models/engine.rb +58 -0
- data/lib/ddr/models/error.rb +12 -0
- data/lib/ddr/models/event_loggable.rb +36 -0
- data/lib/ddr/models/file_management.rb +183 -0
- data/lib/ddr/models/fixity_checkable.rb +20 -0
- data/lib/ddr/models/governable.rb +48 -0
- data/lib/ddr/models/has_attachments.rb +12 -0
- data/lib/ddr/models/has_children.rb +21 -0
- data/lib/ddr/models/has_content.rb +114 -0
- data/lib/ddr/models/has_content_metadata.rb +16 -0
- data/lib/ddr/models/has_properties.rb +15 -0
- data/lib/ddr/models/has_role_assignments.rb +17 -0
- data/lib/ddr/models/has_thumbnail.rb +27 -0
- data/lib/ddr/models/has_workflow.rb +29 -0
- data/lib/ddr/models/indexing.rb +53 -0
- data/lib/ddr/models/licensable.rb +28 -0
- data/lib/ddr/models/minted_id.rb +10 -0
- data/lib/ddr/models/permanent_identification.rb +48 -0
- data/lib/ddr/models/solr_document.rb +193 -0
- data/lib/ddr/models/version.rb +5 -0
- data/lib/ddr/notifications.rb +15 -0
- data/lib/ddr/services.rb +8 -0
- data/lib/ddr/services/id_service.rb +48 -0
- data/lib/ddr/utils.rb +153 -0
- data/lib/ddr/workflow.rb +8 -0
- data/lib/ddr/workflow/workflow_state.rb +39 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +5 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +80 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +4974 -0
- data/spec/dummy/log/test.log +55627 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/attachment_factories.rb +15 -0
- data/spec/factories/collection_factories.rb +16 -0
- data/spec/factories/component_factories.rb +15 -0
- data/spec/factories/event_factories.rb +7 -0
- data/spec/factories/item_factories.rb +16 -0
- data/spec/factories/target_factories.rb +11 -0
- data/spec/factories/test_model_factories.rb +133 -0
- data/spec/factories/user_factories.rb +7 -0
- data/spec/factories/user_factories.rb~ +7 -0
- data/spec/features/grouper_integration_spec.rb~ +21 -0
- data/spec/fixtures/contentMetadata.xml +37 -0
- data/spec/fixtures/image1.tiff +0 -0
- data/spec/fixtures/image2.tiff +0 -0
- data/spec/fixtures/image3.tiff +0 -0
- data/spec/fixtures/library-devil.tiff +0 -0
- data/spec/fixtures/sample.docx +0 -0
- data/spec/fixtures/sample.pdf +0 -0
- data/spec/fixtures/target.png +0 -0
- data/spec/models/ability_spec.rb +248 -0
- data/spec/models/ability_spec.rb~ +245 -0
- data/spec/models/active_fedora_base_spec.rb +107 -0
- data/spec/models/active_fedora_datastream_spec.rb +121 -0
- data/spec/models/attachment_spec.rb +13 -0
- data/spec/models/collection_spec.rb +33 -0
- data/spec/models/component_spec.rb +8 -0
- data/spec/models/descriptive_metadata_datastream_spec.rb +102 -0
- data/spec/models/events_spec.rb +64 -0
- data/spec/models/file_management_spec.rb +179 -0
- data/spec/models/has_role_assignments_spec.rb +29 -0
- data/spec/models/has_workflow_spec.rb +54 -0
- data/spec/models/item_spec.rb +8 -0
- data/spec/models/permanent_identification_spec.rb +65 -0
- data/spec/models/role_assignments_datastream_spec.rb +25 -0
- data/spec/models/superuser_spec.rb +13 -0
- data/spec/models/superuser_spec.rb~ +13 -0
- data/spec/models/target_spec.rb +8 -0
- data/spec/models/user_spec.rb +60 -0
- data/spec/models/user_spec.rb~ +56 -0
- data/spec/services/group_service_spec.rb +75 -0
- data/spec/services/group_service_spec.rb~ +71 -0
- data/spec/services/id_service_spec.rb +33 -0
- data/spec/spec_helper.rb +125 -0
- data/spec/support/shared_examples_for_access_controllables.rb +6 -0
- data/spec/support/shared_examples_for_associations.rb +8 -0
- data/spec/support/shared_examples_for_ddr_models.rb +7 -0
- data/spec/support/shared_examples_for_describables.rb +63 -0
- data/spec/support/shared_examples_for_event_loggables.rb +3 -0
- data/spec/support/shared_examples_for_events.rb +179 -0
- data/spec/support/shared_examples_for_governables.rb +17 -0
- data/spec/support/shared_examples_for_has_content.rb +136 -0
- data/spec/support/shared_examples_for_has_content_metadata.rb +74 -0
- data/spec/support/shared_examples_for_has_properties.rb +5 -0
- data/spec/support/shared_examples_for_indexing.rb +36 -0
- metadata +562 -0
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe ActiveFedora::Base do
|
4
|
+
describe "attachments", attachments: true do
|
5
|
+
before do
|
6
|
+
class AttachToable < ActiveFedora::Base
|
7
|
+
include Ddr::Models::HasAttachments
|
8
|
+
end
|
9
|
+
end
|
10
|
+
after do
|
11
|
+
Object.send(:remove_const, :AttachToable)
|
12
|
+
end
|
13
|
+
describe "#can_have_attachments?" do
|
14
|
+
it "#should return true if the object can have attachments, otherwise false" do
|
15
|
+
expect(AttachToable.new.can_have_attachments?).to be_truthy
|
16
|
+
expect(ActiveFedora::Base.new.can_have_attachments?).to be_falsey
|
17
|
+
end
|
18
|
+
end
|
19
|
+
describe "#has_attachments?" do
|
20
|
+
let(:attach_toable) { AttachToable.new }
|
21
|
+
before { attach_toable.attachments << Attachment.new }
|
22
|
+
it "should return true if the object has Attachments, otherwise false" do
|
23
|
+
expect(AttachToable.new).not_to have_attachments
|
24
|
+
expect(ActiveFedora::Base.new).not_to have_attachments
|
25
|
+
expect(attach_toable).to have_attachments
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "children", children: true do
|
31
|
+
before do
|
32
|
+
class Childrenable < ActiveFedora::Base
|
33
|
+
has_many :children, property: :is_member_of, class_name: 'ActiveFedora::Base'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
after do
|
37
|
+
Object.send(:remove_const, :Childrenable)
|
38
|
+
end
|
39
|
+
describe "#can_have_children?" do
|
40
|
+
it "should return true if object can have children, otherwise false" do
|
41
|
+
expect(Childrenable.new.can_have_children?).to be_truthy
|
42
|
+
expect(ActiveFedora::Base.new.can_have_children?).to be_falsey
|
43
|
+
end
|
44
|
+
end
|
45
|
+
describe "#has_children?" do
|
46
|
+
let(:childrenable) { Childrenable.new }
|
47
|
+
before { childrenable.children << ActiveFedora::Base.new }
|
48
|
+
it "should return true if object has children, otherwise false" do
|
49
|
+
expect(Childrenable.new).not_to have_children
|
50
|
+
expect(ActiveFedora::Base.new).not_to have_children
|
51
|
+
expect(childrenable).to have_children
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "thumbnail" do
|
57
|
+
before do
|
58
|
+
class Thumbnailable < ActiveFedora::Base
|
59
|
+
include Ddr::Models::HasThumbnail
|
60
|
+
end
|
61
|
+
end
|
62
|
+
after do
|
63
|
+
Object.send(:remove_const, :Thumbnailable)
|
64
|
+
end
|
65
|
+
describe "#can_have_thumbnail?" do
|
66
|
+
it "should return true if object can have a thumbnail, else false" do
|
67
|
+
expect(Thumbnailable.new.can_have_thumbnail?).to be_truthy
|
68
|
+
expect(ActiveFedora::Base.new.can_have_thumbnail?).to be_falsey
|
69
|
+
end
|
70
|
+
end
|
71
|
+
describe "#has_thumbnail?" do
|
72
|
+
let(:thumbnailable) { Thumbnailable.new }
|
73
|
+
before { allow(thumbnailable.datastreams[Ddr::Datastreams::THUMBNAIL]).to receive(:has_content?).and_return(true) }
|
74
|
+
it "should return true if object has a thumbnail, else false" do
|
75
|
+
expect(thumbnailable).to have_thumbnail
|
76
|
+
expect(Thumbnailable.new).not_to have_thumbnail
|
77
|
+
expect(ActiveFedora::Base.new).not_to have_thumbnail
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "content" do
|
83
|
+
before do
|
84
|
+
class Contentable < ActiveFedora::Base
|
85
|
+
include Ddr::Models::HasContent
|
86
|
+
end
|
87
|
+
end
|
88
|
+
after do
|
89
|
+
Object.send(:remove_const, :Contentable)
|
90
|
+
end
|
91
|
+
describe "#can_have_content?" do
|
92
|
+
it "should return true if object can have content, else false" do
|
93
|
+
expect(Contentable.new.can_have_content?).to be_truthy
|
94
|
+
expect(ActiveFedora::Base.new.can_have_content?).to be_falsey
|
95
|
+
end
|
96
|
+
end
|
97
|
+
describe "#has_content?" do
|
98
|
+
let(:contentable) { Contentable.new }
|
99
|
+
before { allow(contentable.datastreams[Ddr::Datastreams::CONTENT]).to receive(:has_content?).and_return(true) }
|
100
|
+
it "should return true if object has content, else false" do
|
101
|
+
expect(contentable).to have_content
|
102
|
+
expect(Contentable.new).not_to have_content
|
103
|
+
expect(ActiveFedora::Base.new).not_to have_content
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ActiveFedora
|
4
|
+
RSpec.describe Datastream do
|
5
|
+
|
6
|
+
describe "#validate_checksum!" do
|
7
|
+
subject { described_class.new(nil, nil, controlGroup: "M") }
|
8
|
+
let!(:checksum) { "dea56f15b309e47b74fa24797f85245dda0ca3d274644a96804438bbd659555a" }
|
9
|
+
let!(:checksum_type) { "SHA-256" }
|
10
|
+
context "with unpersisted content" do
|
11
|
+
context "the datstream is new" do
|
12
|
+
before { allow(subject).to receive(:new?) { true } }
|
13
|
+
it "should raise an exception" do
|
14
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
context "the datastream content has changed" do
|
18
|
+
before { allow(subject).to receive(:content_changed?) { true } }
|
19
|
+
it "should raise an exception" do
|
20
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
context "with persisted content" do
|
25
|
+
before do
|
26
|
+
allow(subject).to receive(:new?) { false }
|
27
|
+
allow(subject).to receive(:pid) { "foobar:1" }
|
28
|
+
allow(subject).to receive(:dsCreateDate) { DateTime.now }
|
29
|
+
allow(subject).to receive(:checksum) { checksum }
|
30
|
+
allow(subject).to receive(:checksumType) { checksum_type }
|
31
|
+
end
|
32
|
+
context "and the repository internal checksum in invalid" do
|
33
|
+
before { allow(subject).to receive(:dsChecksumValid) { false } }
|
34
|
+
it "should raise an error" do
|
35
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
36
|
+
end
|
37
|
+
end
|
38
|
+
context "and the repository internal checksum is valid" do
|
39
|
+
before { allow(subject).to receive(:dsChecksumValid) { true } }
|
40
|
+
context "and the checksum type is invalid" do
|
41
|
+
it "should raise an exception" do
|
42
|
+
expect { subject.validate_checksum!("0123456789abcdef", "FOO-BAR") }.to raise_error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
context "and the checksum type is nil" do
|
46
|
+
it "should compare the provided checksum with the datastream checksum" do
|
47
|
+
expect { subject.validate_checksum!(checksum) }.not_to raise_error
|
48
|
+
end
|
49
|
+
end
|
50
|
+
context "and the checksum type is the same as the datastream checksum type" do
|
51
|
+
it "should compare the provided checksum with the datastream checksum" do
|
52
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.not_to raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
context "and the checksum type differs from the datastream checksum type" do
|
56
|
+
let!(:md5digest) { "273ae0f4aa60d94e89bc0e0652ae2c8f" }
|
57
|
+
it "should generate a checksum for comparison" do
|
58
|
+
expect(subject).not_to receive(:checksum)
|
59
|
+
allow(subject).to receive(:content_digest).with("MD5") { md5digest }
|
60
|
+
expect { subject.validate_checksum!(md5digest, "MD5") }.not_to raise_error
|
61
|
+
end
|
62
|
+
end
|
63
|
+
context "and the checksum doesn't match" do
|
64
|
+
it "should raise an exception" do
|
65
|
+
expect { subject.validate_checksum!("0123456789abcdef", checksum_type) }.to raise_error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "extensions for external datastreams" do
|
73
|
+
subject { described_class.new(nil, nil, controlGroup: "E") }
|
74
|
+
|
75
|
+
describe "#file_path" do
|
76
|
+
it "should return nil when dsLocation is not set" do
|
77
|
+
expect(subject.file_path).to be_nil
|
78
|
+
end
|
79
|
+
it "should return nil when dsLocation is not a file URI" do
|
80
|
+
subject.dsLocation = "http://library.duke.edu/"
|
81
|
+
expect(subject.file_path).to be_nil
|
82
|
+
end
|
83
|
+
it "should return the file path when dsLocation is a file URI" do
|
84
|
+
subject.dsLocation = "file:/tmp/foo/bar.txt"
|
85
|
+
expect(subject.file_path).to eq "/tmp/foo/bar.txt"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#file_name" do
|
90
|
+
it "should return nil when dsLocation is not set" do
|
91
|
+
expect(subject.file_name).to be_nil
|
92
|
+
end
|
93
|
+
it "should return nil when dsLocation is not a file URI" do
|
94
|
+
subject.dsLocation = "http://library.duke.edu/"
|
95
|
+
expect(subject.file_name).to be_nil
|
96
|
+
end
|
97
|
+
it "should return the file name when dsLocation is a file URI" do
|
98
|
+
subject.dsLocation = "file:/tmp/foo/bar.txt"
|
99
|
+
expect(subject.file_name).to eq "bar.txt"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#file_size" do
|
104
|
+
it "should return nil when dsLocation is not set" do
|
105
|
+
expect(subject.file_size).to be_nil
|
106
|
+
end
|
107
|
+
it "should return nil when dsLocation is not a file URI" do
|
108
|
+
subject.dsLocation = "http://library.duke.edu/"
|
109
|
+
expect(subject.file_size).to be_nil
|
110
|
+
end
|
111
|
+
it "should return the file name when dsLocation is a file URI" do
|
112
|
+
allow(File).to receive(:size).with("/tmp/foo/bar.txt") { 42 }
|
113
|
+
subject.dsLocation = "file:/tmp/foo/bar.txt"
|
114
|
+
expect(subject.file_size).to eq 42
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end # external datastreams
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Attachment, type: :model, attachments: true do
|
4
|
+
it_behaves_like "a DDR model"
|
5
|
+
it_behaves_like "an object that can have content"
|
6
|
+
it_behaves_like "it has an association", :belongs_to, :attached_to, :is_attached_to, "ActiveFedora::Base"
|
7
|
+
context "validations" do
|
8
|
+
before { subject.valid? }
|
9
|
+
it "should have content" do
|
10
|
+
expect(subject.errors.messages).to have_key(:content)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Collection, :type => :model do
|
4
|
+
|
5
|
+
it_behaves_like "a DDR model"
|
6
|
+
|
7
|
+
it_behaves_like "it has an association", :has_many, :children, :is_member_of_collection, "Item"
|
8
|
+
|
9
|
+
it_behaves_like "it has an association", :has_many, :targets, :is_external_target_for, "Target"
|
10
|
+
|
11
|
+
describe "terms delegated to defaultRights" do
|
12
|
+
let(:collection) { Collection.new }
|
13
|
+
before do
|
14
|
+
collection.default_license_title = "License Title"
|
15
|
+
collection.default_license_description = "License Description"
|
16
|
+
collection.default_license_url = "http://library.duke.edu"
|
17
|
+
end
|
18
|
+
it "should set the terms correctly" do
|
19
|
+
expect(collection.defaultRights.license.title.first).to eq("License Title")
|
20
|
+
expect(collection.defaultRights.license.description.first).to eq("License Description")
|
21
|
+
expect(collection.defaultRights.license.url.first).to eq("http://library.duke.edu")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "validation" do
|
26
|
+
let(:collection) { Collection.new }
|
27
|
+
it "should require a title" do
|
28
|
+
expect(collection).to_not be_valid
|
29
|
+
expect(collection.errors.messages).to have_key(:title)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Component, type: :model, components: true do
|
4
|
+
it_behaves_like "a DDR model"
|
5
|
+
it_behaves_like "an object that can have content"
|
6
|
+
it_behaves_like "it has an association", :belongs_to, :parent, :is_part_of, "Item"
|
7
|
+
it_behaves_like "it has an association", :belongs_to, :target, :has_external_target, "Target"
|
8
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rdf/isomorphic'
|
3
|
+
|
4
|
+
include RDF::Isomorphic
|
5
|
+
|
6
|
+
def sample_metadata_triples(subject_string="_:test")
|
7
|
+
triples = <<-EOS
|
8
|
+
#{subject_string} <http://purl.org/dc/terms/title> "Sample title" .
|
9
|
+
#{subject_string} <http://purl.org/dc/terms/creator> "Sample, Example" .
|
10
|
+
#{subject_string} <http://purl.org/dc/terms/type> "Image" .
|
11
|
+
#{subject_string} <http://purl.org/dc/terms/type> "Still Image" .
|
12
|
+
#{subject_string} <http://purl.org/dc/terms/spatial> "Durham County (NC)" .
|
13
|
+
#{subject_string} <http://purl.org/dc/terms/spatial> "Durham (NC)" .
|
14
|
+
#{subject_string} <http://purl.org/dc/terms/date> "1981-01" .
|
15
|
+
#{subject_string} <http://purl.org/dc/terms/rights> "The copyright for these materials is unknown." .
|
16
|
+
#{subject_string} <http://library.duke.edu/metadata/terms/print_number> "12-345-6" .
|
17
|
+
#{subject_string} <http://library.duke.edu/metadata/terms/series> "Photographic Materials Series" .
|
18
|
+
#{subject_string} <http://library.duke.edu/metadata/terms/subseries> "Local Court House" .
|
19
|
+
EOS
|
20
|
+
end
|
21
|
+
|
22
|
+
module Ddr
|
23
|
+
module Datastreams
|
24
|
+
RSpec.describe DescriptiveMetadataDatastream do
|
25
|
+
context "terminology" do
|
26
|
+
subject { described_class.term_names }
|
27
|
+
it "should have a term for each term name in the RDF::DC vocab" do
|
28
|
+
expect(subject).to include(*Ddr::Metadata::Vocabulary.term_names(RDF::DC))
|
29
|
+
end
|
30
|
+
it "should have a term for each term name in the DukeTerms vocab" do
|
31
|
+
expect(subject).to include(*Ddr::Metadata::Vocabulary.term_names(Ddr::Metadata::DukeTerms))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
context "properties" do
|
35
|
+
subject { described_class.properties.map { |prop| prop[1].predicate } }
|
36
|
+
it "should include all the RDF::DC predicates" do
|
37
|
+
expect(subject).to include(*Ddr::Metadata::Vocabulary.property_terms(RDF::DC))
|
38
|
+
end
|
39
|
+
it "should include all the DukeTerms predicates" do
|
40
|
+
expect(subject).to include(*Ddr::Metadata::Vocabulary.property_terms(Ddr::Metadata::DukeTerms))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
context "raw content" do
|
44
|
+
let(:ds) { described_class.new(nil, 'descMetadata') }
|
45
|
+
before do
|
46
|
+
content = sample_metadata_triples(ds.rdf_subject.to_s)
|
47
|
+
ds.content = content
|
48
|
+
ds.resource.set_subject!(ds.rdf_subject)
|
49
|
+
end
|
50
|
+
it "should retrieve the content using the terminology" do
|
51
|
+
expect(ds.title).to eq(["Sample title"])
|
52
|
+
expect(ds.creator).to eq(["Sample, Example"])
|
53
|
+
expect(ds.type).to eq(["Image", "Still Image"])
|
54
|
+
expect(ds.spatial).to eq(["Durham County (NC)", "Durham (NC)"])
|
55
|
+
expect(ds.date).to eq(["1981-01"])
|
56
|
+
expect(ds.rights).to eq(["The copyright for these materials is unknown."])
|
57
|
+
expect(ds.print_number).to eq(["12-345-6"])
|
58
|
+
expect(ds.series).to eq(["Photographic Materials Series"])
|
59
|
+
expect(ds.subseries).to eq(["Local Court House"])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
context "using the terminology setters" do
|
63
|
+
let(:ds) { described_class.new(nil, 'descMetadata') }
|
64
|
+
let(:content) { sample_metadata_triples(ds.rdf_subject.to_s) }
|
65
|
+
before do
|
66
|
+
ds.title = "Sample title"
|
67
|
+
ds.creator = "Sample, Example"
|
68
|
+
ds.type = ["Image", "Still Image"]
|
69
|
+
ds.spatial = ["Durham County (NC)", "Durham (NC)"]
|
70
|
+
ds.date = "1981-01"
|
71
|
+
ds.rights = "The copyright for these materials is unknown."
|
72
|
+
ds.print_number = "12-345-6"
|
73
|
+
ds.series = "Photographic Materials Series"
|
74
|
+
ds.subseries = "Local Court House"
|
75
|
+
end
|
76
|
+
it "should create equivalent RDF graph to that based on the raw version" do
|
77
|
+
expect(ds.resource).to be_isomorphic_with(RDF::Reader.for(:ntriples).new(content))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
context "solrization" do
|
81
|
+
let(:ds) { described_class.new(nil, 'descMetadata') }
|
82
|
+
subject { ds.to_solr }
|
83
|
+
before do
|
84
|
+
content = sample_metadata_triples(ds.rdf_subject.to_s)
|
85
|
+
ds.content = content
|
86
|
+
ds.resource.set_subject!(ds.rdf_subject)
|
87
|
+
end
|
88
|
+
it "should create fields for all the terms that have non-empty values" do
|
89
|
+
expect(subject).to include("title_tesim" => ["Sample title"])
|
90
|
+
expect(subject).to include("creator_tesim" => ["Sample, Example"])
|
91
|
+
expect(subject).to include("type_tesim" => ["Image", "Still Image"])
|
92
|
+
expect(subject).to include("spatial_tesim" => ["Durham County (NC)", "Durham (NC)"])
|
93
|
+
expect(subject).to include("date_tesim" => ["1981-01"])
|
94
|
+
expect(subject).to include("rights_tesim" => ["The copyright for these materials is unknown."])
|
95
|
+
expect(subject).to include("print_number_tesim" => ["12-345-6"])
|
96
|
+
expect(subject).to include("series_tesim" => ["Photographic Materials Series"])
|
97
|
+
expect(subject).to include("subseries_tesim" => ["Local Court House"])
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'support/shared_examples_for_events'
|
3
|
+
|
4
|
+
module Ddr
|
5
|
+
module Events
|
6
|
+
RSpec.describe Event, type: :model, events: true do
|
7
|
+
it_behaves_like "an event"
|
8
|
+
end
|
9
|
+
|
10
|
+
RSpec.describe UpdateEvent, type: :model, events: true do
|
11
|
+
it_behaves_like "an event"
|
12
|
+
it "should have a display type" do
|
13
|
+
expect(subject.display_type).to eq "Update"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.describe CreationEvent, type: :model, events: true do
|
18
|
+
it_behaves_like "an event"
|
19
|
+
it_behaves_like "a preservation-related event"
|
20
|
+
it "should have a display type" do
|
21
|
+
expect(subject.display_type).to eq "Creation"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
RSpec.describe FixityCheckEvent, type: :model, events: true do
|
26
|
+
it_behaves_like "an event"
|
27
|
+
it_behaves_like "a preservation-related event"
|
28
|
+
it_behaves_like "an event that reindexes its object after save"
|
29
|
+
it "should have a display type" do
|
30
|
+
expect(subject.display_type).to eq "Fixity Check"
|
31
|
+
end
|
32
|
+
describe "defaults" do
|
33
|
+
it "should set software to the Fedora repository version" do
|
34
|
+
expect(subject.software).to match /^Fedora Repository \d\.\d\.\d$/
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
RSpec.describe VirusCheckEvent, type: :model, events: true do
|
40
|
+
it_behaves_like "an event"
|
41
|
+
it_behaves_like "a preservation-related event"
|
42
|
+
it_behaves_like "an event that reindexes its object after save"
|
43
|
+
it "should have a display type" do
|
44
|
+
expect(subject.display_type).to eq "Virus Check"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
RSpec.describe IngestionEvent, type: :model, events: true do
|
49
|
+
it_behaves_like "an event"
|
50
|
+
it_behaves_like "a preservation-related event"
|
51
|
+
it "should have a display type" do
|
52
|
+
expect(subject.display_type).to eq "Ingestion"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
RSpec.describe ValidationEvent, type: :model, events: true do
|
57
|
+
it_behaves_like "an event"
|
58
|
+
it_behaves_like "a preservation-related event"
|
59
|
+
it "should have a display type" do
|
60
|
+
expect(subject.display_type).to eq "Validation"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|