ddr-models 2.11.0 → 3.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +7 -6
- data/Gemfile +2 -3
- data/Rakefile +5 -5
- data/app/controllers/users/sessions_controller.rb +5 -0
- data/app/helpers/models_helper.rb +7 -0
- data/app/models/attachment.rb +3 -5
- data/app/models/collection.rb +12 -79
- data/app/models/component.rb +8 -67
- data/app/models/item.rb +8 -73
- data/app/models/target.rb +6 -5
- data/config/initializers/active_fedora_base.rb +11 -30
- data/config/initializers/{active_fedora_datastream.rb → active_fedora_file.rb} +1 -1
- data/config/initializers/devise.rb +2 -3
- data/config/initializers/subscriptions.rb +2 -19
- data/ddr-models.gemspec +10 -14
- data/lib/ddr/actions/fixity_check.rb +1 -1
- data/lib/ddr/actions/virus_check.rb +17 -10
- data/lib/ddr/auth.rb +6 -38
- data/lib/ddr/auth/ability.rb +1 -5
- data/lib/ddr/auth/ability_definitions/collection_ability_definitions.rb +0 -16
- data/lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb +10 -4
- data/lib/ddr/auth/ability_definitions/role_based_ability_definitions.rb +16 -9
- data/lib/ddr/auth/ability_factory.rb +25 -2
- data/lib/ddr/auth/abstract_ability.rb +1 -2
- data/lib/ddr/auth/auth_context.rb +0 -18
- data/lib/ddr/auth/auth_context_factory.rb +2 -0
- data/lib/ddr/auth/group.rb +0 -6
- data/lib/ddr/auth/grouper_gateway.rb +0 -24
- data/lib/ddr/auth/permissions.rb +1 -12
- data/lib/ddr/auth/role_based_access_controls_enforcement.rb +5 -5
- data/lib/ddr/auth/roles.rb +1 -11
- data/lib/ddr/auth/roles/role_set.rb +0 -7
- data/lib/ddr/auth/roles/roles_datastream.rb +9 -0
- data/lib/ddr/contacts.rb +25 -0
- data/lib/ddr/datastreams.rb +10 -28
- data/lib/ddr/datastreams/datastream_behavior.rb +30 -100
- data/lib/ddr/datastreams/descriptive_metadata_datastream.rb +28 -31
- data/lib/ddr/datastreams/fits_datastream.rb +9 -22
- data/lib/ddr/datastreams/metadata_datastream.rb +17 -31
- data/lib/ddr/derivatives.rb +13 -16
- data/lib/ddr/derivatives/derivative.rb +68 -0
- data/lib/ddr/derivatives/{generator.rb → generators/generator.rb} +11 -7
- data/lib/ddr/derivatives/generators/png_generator.rb +23 -0
- data/lib/ddr/derivatives/generators/ptif_generator.rb +56 -0
- data/lib/ddr/derivatives/multires_image.rb +59 -0
- data/lib/ddr/derivatives/thumbnail.rb +36 -0
- data/lib/ddr/events.rb +0 -1
- data/lib/ddr/events/deletion_event.rb +9 -5
- data/lib/ddr/events/event.rb +8 -13
- data/lib/ddr/events/fixity_check_event.rb +0 -6
- data/lib/ddr/events/ingestion_event.rb +9 -5
- data/lib/ddr/events/update_event.rb +4 -17
- data/lib/ddr/index.rb +4 -4
- data/lib/ddr/index/abstract_query_result.rb +4 -3
- data/lib/ddr/index/connection.rb +9 -28
- data/lib/ddr/index/csv_query_result.rb +32 -47
- data/lib/ddr/index/field.rb +1 -11
- data/lib/ddr/index/fields.rb +16 -99
- data/lib/ddr/index/filter.rb +30 -103
- data/lib/ddr/index/filters.rb +19 -0
- data/lib/ddr/index/query.rb +11 -58
- data/lib/ddr/index/query_builder.rb +36 -147
- data/lib/ddr/index/query_clause.rb +19 -79
- data/lib/ddr/index/query_result.rb +4 -36
- data/lib/ddr/index/query_value.rb +18 -0
- data/lib/ddr/index/response.rb +2 -19
- data/lib/ddr/jobs.rb +12 -0
- data/lib/ddr/jobs/fits_file_characterization.rb +51 -0
- data/lib/ddr/jobs/permanent_id.rb +23 -0
- data/lib/ddr/managers.rb +1 -0
- data/lib/ddr/managers/derivatives_manager.rb +53 -93
- data/lib/ddr/managers/permanent_id_manager.rb +91 -0
- data/lib/ddr/managers/technical_metadata_manager.rb +10 -24
- data/lib/ddr/managers/workflow_manager.rb +10 -29
- data/lib/ddr/models.rb +50 -101
- data/lib/ddr/models/access_controllable.rb +12 -0
- data/lib/ddr/models/admin_set.rb +5 -16
- data/lib/ddr/models/base.rb +45 -165
- data/lib/ddr/models/describable.rb +19 -21
- data/lib/ddr/models/engine.rb +11 -39
- data/lib/ddr/models/error.rb +0 -3
- data/lib/ddr/models/file_management.rb +36 -72
- data/lib/ddr/models/finding_aid.rb +2 -35
- data/lib/ddr/models/fixity_checkable.rb +4 -0
- data/lib/ddr/models/governable.rb +3 -1
- data/lib/ddr/models/has_admin_metadata.rb +82 -56
- data/lib/ddr/models/has_attachments.rb +3 -1
- data/lib/ddr/models/has_children.rb +3 -7
- data/lib/ddr/models/has_content.rb +35 -32
- data/lib/ddr/models/has_multires_image.rb +7 -12
- data/lib/ddr/models/has_struct_metadata.rb +44 -6
- data/lib/ddr/models/has_thumbnail.rb +1 -4
- data/lib/ddr/models/indexing.rb +97 -186
- data/lib/ddr/models/licenses/admin_policy_license.rb +11 -0
- data/lib/ddr/models/licenses/effective_license.rb +9 -0
- data/lib/ddr/models/licenses/inherited_license.rb +9 -0
- data/lib/ddr/models/licenses/license.rb +21 -0
- data/lib/ddr/models/licenses/parent_license.rb +11 -0
- data/lib/ddr/models/metadata/descriptive_metadata.rb +50 -0
- data/lib/ddr/models/metadata/metadata.rb +37 -0
- data/lib/ddr/models/metadata/metadata_mapper.rb +32 -0
- data/lib/ddr/models/metadata/metadata_mappers.rb +18 -0
- data/lib/ddr/models/metadata/metadata_term.rb +24 -0
- data/lib/ddr/models/metadata/metadata_vocabularies.rb +18 -0
- data/lib/ddr/models/metadata/metadata_vocabulary.rb +34 -0
- data/lib/ddr/models/solr_document.rb +24 -156
- data/lib/ddr/models/struct_div.rb +63 -0
- data/lib/ddr/models/structure.rb +39 -175
- data/lib/ddr/models/version.rb +1 -1
- data/lib/ddr/models/year_facet.rb +118 -60
- data/lib/ddr/notifications.rb +12 -10
- data/lib/ddr/utils.rb +15 -28
- data/lib/ddr/vocab.rb +17 -15
- data/lib/ddr/vocab/asset.rb +17 -42
- data/lib/ddr/vocab/contact.rb +7 -5
- data/lib/ddr/vocab/display.rb +8 -6
- data/lib/ddr/vocab/duke_terms.rb +10 -8
- data/lib/ddr/vocab/rdf_vocabulary_parser.rb +39 -37
- data/lib/ddr/vocab/roles.rb +19 -17
- data/lib/ddr/vocab/sources/duketerms.rdf +8 -22
- data/lib/ddr/vocab/vocabulary.rb +26 -26
- data/spec/auth/ability_factory_spec.rb +1 -18
- data/spec/auth/ability_spec.rb +15 -119
- data/spec/auth/effective_permissions_spec.rb +1 -1
- data/spec/auth/effective_roles_spec.rb +1 -1
- data/spec/auth/ldap_gateway_spec.rb +9 -0
- data/spec/contacts/contacts_spec.rb +26 -0
- data/spec/controllers/including_role_based_access_controls_enforcement_spec.rb +5 -5
- data/spec/derivatives/multires_image_spec.rb +48 -0
- data/spec/derivatives/png_generator_spec.rb +8 -13
- data/spec/derivatives/ptif_generator_spec.rb +11 -9
- data/spec/derivatives/thumbnail_spec.rb +48 -0
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/db/schema.rb +23 -25
- data/spec/factories/attachment_factories.rb +2 -2
- data/spec/factories/collection_factories.rb +2 -3
- data/spec/factories/component_factories.rb +2 -2
- data/spec/factories/item_factories.rb +2 -2
- data/spec/factories/structure_factories.rb +2 -8
- data/spec/factories/test_model_factories.rb +12 -4
- data/spec/fixtures/fits/document.xml +44 -42
- data/spec/fixtures/fits/image.xml +41 -42
- data/spec/helpers/models_helper_spec.rb +11 -0
- data/spec/index/filter_spec.rb +30 -208
- data/spec/index/filters_spec.rb +17 -0
- data/spec/index/query_spec.rb +10 -82
- data/spec/jobs/fits_file_characterization_spec.rb +52 -0
- data/spec/managers/derivatives_manager_spec.rb +105 -107
- data/spec/managers/technical_metadata_manager_spec.rb +27 -34
- data/spec/models/active_fedora_base_spec.rb +105 -5
- data/spec/models/active_fedora_datastream_spec.rb +39 -106
- data/spec/models/admin_set_spec.rb +10 -43
- data/spec/models/attachment_spec.rb +2 -3
- data/spec/models/collection_spec.rb +11 -225
- data/spec/models/component_spec.rb +4 -106
- data/spec/models/descriptive_metadata_spec.rb +38 -0
- data/spec/models/effective_license_spec.rb +64 -0
- data/spec/models/events_spec.rb +59 -52
- data/spec/models/file_management_spec.rb +13 -113
- data/spec/models/finding_aid_spec.rb +8 -31
- data/spec/models/has_admin_metadata_spec.rb +122 -131
- data/spec/models/has_children_spec.rb +3 -3
- data/spec/models/has_struct_metadata_spec.rb +37 -50
- data/spec/models/indexing_spec.rb +23 -160
- data/spec/models/item_spec.rb +2 -133
- data/spec/models/license_spec.rb +24 -0
- data/spec/models/solr_document_spec.rb +47 -236
- data/spec/models/struct_div_spec.rb +70 -0
- data/spec/models/structure_spec.rb +11 -89
- data/spec/models/target_spec.rb +2 -4
- data/spec/models/year_facet_spec.rb +23 -50
- data/spec/spec_helper.rb +13 -17
- data/spec/support/ezid_mock_identifier.rb +2 -2
- data/spec/support/shared_examples_for_auth_contexts.rb +0 -33
- data/spec/support/shared_examples_for_ddr_models.rb +94 -142
- data/spec/support/shared_examples_for_describables.rb +36 -31
- data/spec/support/shared_examples_for_governables.rb +2 -3
- data/spec/support/shared_examples_for_has_content.rb +46 -101
- data/spec/support/shared_examples_for_indexing.rb +6 -6
- data/spec/support/shared_examples_for_non_collection_models.rb +1 -32
- data/spec/support/structural_metadata_helper.rb +59 -230
- data/spec/utils_spec.rb +2 -0
- metadata +96 -229
- data/.ruby-version +0 -1
- data/config/initializers/rsolr_monkey_patches.rb +0 -7
- data/config/initializers/rubydora_monkey_patch.rb +0 -11
- data/config/locales/ddr-models.en.yml +0 -81
- data/db/migrate/20161021201011_add_permanent_id_to_events.rb +0 -8
- data/lib/ddr/auth/ability_definitions/admin_set_ability_definitions.rb +0 -9
- data/lib/ddr/auth/ability_definitions/lock_ability_definitions.rb +0 -13
- data/lib/ddr/auth/ability_definitions/publication_ability_definitions.rb +0 -16
- data/lib/ddr/datastreams/administrative_metadata_datastream.rb +0 -75
- data/lib/ddr/datastreams/caption_datastream.rb +0 -5
- data/lib/ddr/datastreams/content_datastream.rb +0 -17
- data/lib/ddr/datastreams/delete_external_files.rb +0 -29
- data/lib/ddr/datastreams/external_file_datastream.rb +0 -80
- data/lib/ddr/datastreams/intermediate_file_datastream.rb +0 -5
- data/lib/ddr/datastreams/multires_image_datastream.rb +0 -5
- data/lib/ddr/datastreams/streamable_media_datastream.rb +0 -5
- data/lib/ddr/derivatives/png_generator.rb +0 -17
- data/lib/ddr/derivatives/ptif_generator.rb +0 -55
- data/lib/ddr/derivatives/update_derivatives.rb +0 -25
- data/lib/ddr/events/deaccession_event.rb +0 -8
- data/lib/ddr/index/field_attribute.rb +0 -22
- data/lib/ddr/index/query_params.rb +0 -40
- data/lib/ddr/index/sort_order.rb +0 -28
- data/lib/ddr/models/cache.rb +0 -20
- data/lib/ddr/models/captionable.rb +0 -37
- data/lib/ddr/models/contact.rb +0 -23
- data/lib/ddr/models/file_characterization.rb +0 -37
- data/lib/ddr/models/has_intermediate_file.rb +0 -41
- data/lib/ddr/models/language.rb +0 -31
- data/lib/ddr/models/media_type.rb +0 -22
- data/lib/ddr/models/permanent_id.rb +0 -240
- data/lib/ddr/models/rights_statement.rb +0 -25
- data/lib/ddr/models/streamable.rb +0 -37
- data/lib/ddr/models/structures/agent.rb +0 -49
- data/lib/ddr/models/structures/component_type_term.rb +0 -29
- data/lib/ddr/models/structures/div.rb +0 -64
- data/lib/ddr/models/structures/f_locat.rb +0 -54
- data/lib/ddr/models/structures/file.rb +0 -52
- data/lib/ddr/models/structures/file_grp.rb +0 -35
- data/lib/ddr/models/structures/file_sec.rb +0 -22
- data/lib/ddr/models/structures/fptr.rb +0 -31
- data/lib/ddr/models/structures/mets_hdr.rb +0 -37
- data/lib/ddr/models/structures/mptr.rb +0 -49
- data/lib/ddr/models/structures/struct_map.rb +0 -40
- data/lib/ddr/models/with_content_file.rb +0 -37
- data/spec/datastreams/external_file_datastream_spec.rb +0 -48
- data/spec/dummy/config/structure_component_type.yml +0 -18
- data/spec/fixtures/abcd1234.vtt +0 -38
- data/spec/fixtures/arrow1rightred_e0.gif +0 -0
- data/spec/fixtures/extractedText1.txt +0 -1
- data/spec/fixtures/extractedText2.txt +0 -1
- data/spec/fixtures/extractedText3.txt +0 -3
- data/spec/fixtures/imageA.jpg +0 -0
- data/spec/fixtures/imageB.jpg +0 -0
- data/spec/index/csv_query_result_spec.rb +0 -44
- data/spec/index/fields_spec.rb +0 -380
- data/spec/index/query_builder_spec.rb +0 -140
- data/spec/index/query_clause_spec.rb +0 -68
- data/spec/models/cache_spec.rb +0 -32
- data/spec/models/contact_spec.rb +0 -56
- data/spec/models/descriptive_metadata_datastream_spec.rb +0 -139
- data/spec/models/file_characterization_spec.rb +0 -39
- data/spec/models/language_spec.rb +0 -59
- data/spec/models/media_type_spec.rb +0 -46
- data/spec/models/permanent_id_spec.rb +0 -432
- data/spec/models/rights_statement_spec.rb +0 -55
- data/spec/models/structures/agent_spec.rb +0 -30
- data/spec/models/structures/component_type_term_spec.rb +0 -14
- data/spec/models/structures/div_spec.rb +0 -26
- data/spec/models/structures/f_locat_spec.rb +0 -78
- data/spec/models/structures/file_grp_spec.rb +0 -23
- data/spec/models/structures/file_sec_spec.rb +0 -22
- data/spec/models/structures/file_spec.rb +0 -60
- data/spec/models/structures/fptr_spec.rb +0 -23
- data/spec/models/structures/mets_hdr_spec.rb +0 -26
- data/spec/models/structures/mptr_spec.rb +0 -25
- data/spec/models/structures/struct_map_spec.rb +0 -24
- data/spec/models/with_content_file_spec.rb +0 -37
- data/spec/support/shared_examples_for_associations.rb +0 -8
- data/spec/support/shared_examples_for_captionable.rb +0 -23
- data/spec/support/shared_examples_for_has_intermediate_file.rb +0 -28
- data/spec/support/shared_examples_for_publication.rb +0 -43
- data/spec/support/shared_examples_for_streamable_media.rb +0 -23
@@ -1,119 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
RSpec.describe Component, type: :model, components: true do
|
2
4
|
|
3
5
|
it_behaves_like "a DDR model"
|
4
6
|
it_behaves_like "an object that can have content"
|
5
|
-
it_behaves_like "it has an association", :belongs_to, :parent, :is_part_of, "Item"
|
6
|
-
it_behaves_like "it has an association", :belongs_to, :target, :has_external_target, "Target"
|
7
7
|
it_behaves_like "a non-collection model"
|
8
|
-
it_behaves_like "a potentially publishable object"
|
9
|
-
it_behaves_like "an object that can be captioned"
|
10
|
-
it_behaves_like "an object that can have an intermediate file"
|
11
|
-
it_behaves_like "an object that can be streamable"
|
12
8
|
|
13
9
|
describe "indexing" do
|
14
10
|
subject { FactoryGirl.build(:component) }
|
15
11
|
before do
|
16
|
-
allow(subject).to receive(:collection) { Collection.new(
|
12
|
+
allow(subject).to receive(:collection) { Collection.new(id: "test-1") }
|
17
13
|
end
|
18
|
-
its(:index_fields) { is_expected.to include(Ddr::Index::Fields::COLLECTION_URI => "
|
14
|
+
its(:index_fields) { is_expected.to include(Ddr::Index::Fields::COLLECTION_URI => "test-1") }
|
19
15
|
end
|
20
16
|
|
21
|
-
describe "default structure" do
|
22
|
-
describe "no content" do
|
23
|
-
let(:expected) do
|
24
|
-
xml = <<-EOS
|
25
|
-
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
26
|
-
<metsHdr>
|
27
|
-
<agent ROLE="#{Ddr::Models::Structures::Agent::ROLE_CREATOR}">
|
28
|
-
<name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
|
29
|
-
</agent>
|
30
|
-
</metsHdr>
|
31
|
-
<structMap TYPE="#{Ddr::Models::Structure::TYPE_DEFAULT}" />
|
32
|
-
</mets>
|
33
|
-
EOS
|
34
|
-
xml
|
35
|
-
end
|
36
|
-
it "should be the appropriate structure" do
|
37
|
-
expect(described_class.new.default_structure.to_xml).to be_equivalent_to(expected)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
describe "has content" do
|
41
|
-
before { allow(subject).to receive(:has_content?) { true } }
|
42
|
-
before { allow(subject).to receive(:has_thumbnail?) { true } }
|
43
|
-
let(:struct) { subject.default_structure }
|
44
|
-
it "has the correct original file" do
|
45
|
-
expect(struct.uses[Ddr::Models::Structure::USE_ORIGINAL_FILE].first.href).to eq(Ddr::Datastreams::CONTENT)
|
46
|
-
end
|
47
|
-
it "has the correct preservation master file" do
|
48
|
-
expect(struct.uses[Ddr::Models::Structure::USE_PRESERVATION_MASTER_FILE].first.href)
|
49
|
-
.to eq(Ddr::Datastreams::CONTENT)
|
50
|
-
end
|
51
|
-
describe "intermediate file" do
|
52
|
-
describe "with intermediate file" do
|
53
|
-
before do
|
54
|
-
allow(subject).to receive(:has_intermediate_file?) { true }
|
55
|
-
end
|
56
|
-
it "has the correct structure file" do
|
57
|
-
expect(struct.uses[Ddr::Models::Structure::USE_INTERMEDIATE_FILE].first.href)
|
58
|
-
.to eq(Ddr::Datastreams::INTERMEDIATE_FILE)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
describe "without intermediate image" do
|
62
|
-
it "has the correct structure file" do
|
63
|
-
expect(struct.uses[Ddr::Models::Structure::USE_INTERMEDIATE_FILE]).to be nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
describe "service file" do
|
68
|
-
let(:service_files) { struct.uses[Ddr::Models::Structure::USE_SERVICE_FILE].map(&:href) }
|
69
|
-
describe "with multires image but not streamable media" do
|
70
|
-
before { allow(subject).to receive(:has_multires_image?) { true } }
|
71
|
-
it "has the correct structure file" do
|
72
|
-
expect(service_files).to contain_exactly(Ddr::Datastreams::MULTIRES_IMAGE)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
describe "with streamable media but not multires image" do
|
76
|
-
before { allow(subject).to receive(:streamable?) { true } }
|
77
|
-
it "has the correct structure file" do
|
78
|
-
expect(service_files).to contain_exactly(Ddr::Datastreams::STREAMABLE_MEDIA)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
describe "with both multires image and streamable media" do
|
82
|
-
before do
|
83
|
-
allow(subject).to receive(:has_multires_image?) { true }
|
84
|
-
allow(subject).to receive(:streamable?) { true }
|
85
|
-
end
|
86
|
-
it "has the correct structure file" do
|
87
|
-
expect(service_files).to contain_exactly(Ddr::Datastreams::MULTIRES_IMAGE,
|
88
|
-
Ddr::Datastreams::STREAMABLE_MEDIA)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
describe "with neither multires image nor streamable media" do
|
92
|
-
it "has the correct structure file" do
|
93
|
-
expect(service_files).to contain_exactly(Ddr::Datastreams::CONTENT)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
describe "transcript" do
|
98
|
-
describe "with caption file" do
|
99
|
-
before do
|
100
|
-
allow(subject).to receive(:captioned?) { true }
|
101
|
-
end
|
102
|
-
it "has the correct structure file" do
|
103
|
-
expect(struct.uses[Ddr::Models::Structure::USE_TRANSCRIPT].first.href)
|
104
|
-
.to eq(Ddr::Datastreams::CAPTION)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
describe "without caption file" do
|
108
|
-
it "has the correct structure file" do
|
109
|
-
expect(struct.uses[Ddr::Models::Structure::USE_TRANSCRIPT]).to be nil
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
it "has the correct thumbnail image" do
|
114
|
-
expect(struct.uses[Ddr::Models::Structure::USE_THUMBNAIL_IMAGE].first.href).to eq(Ddr::Datastreams::THUMBNAIL)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
17
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rdf/isomorphic'
|
3
|
+
|
4
|
+
include RDF::Isomorphic
|
5
|
+
|
6
|
+
module Ddr::Models
|
7
|
+
RSpec.describe DescriptiveMetadata do
|
8
|
+
|
9
|
+
let(:obj) { FactoryGirl.build(:item) }
|
10
|
+
|
11
|
+
describe "terminology" do
|
12
|
+
subject { described_class.unqualified_names }
|
13
|
+
it { is_expected.to_not include(:license) }
|
14
|
+
it "should have a term for each term name in the RDF::DC vocab, except :license" do
|
15
|
+
expect(subject).to include(*(Ddr::Vocab::Vocabulary.term_names(RDF::DC) - [:license]))
|
16
|
+
end
|
17
|
+
it "should have a term for each term name in the DukeTerms vocab" do
|
18
|
+
expect(subject).to include(*Ddr::Vocab::Vocabulary.term_names(Ddr::Vocab::DukeTerms))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe "using the set_values and add_value methods" do
|
22
|
+
let(:ds) { described_class.new(obj) }
|
23
|
+
before { ds.type = ["Photograph"] }
|
24
|
+
describe "#set_values" do
|
25
|
+
it "should set the values of the term to those supplied" do
|
26
|
+
ds.set_values :type, [ "Image", "Still Image" ]
|
27
|
+
expect(ds.type).to eq([ "Image", "Still Image" ])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
describe "#add_value" do
|
31
|
+
it "should add the supplied value to those of the term" do
|
32
|
+
ds.add_value :type, "Image"
|
33
|
+
expect(ds.type).to eq([ "Photograph", "Image" ])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Ddr::Models
|
2
|
+
RSpec.describe EffectiveLicense do
|
3
|
+
|
4
|
+
subject { described_class.call(obj) }
|
5
|
+
|
6
|
+
let(:url) { "https://creativecommons.org/licenses/by-nc-nd/4.0/" }
|
7
|
+
|
8
|
+
let(:license) { License.new(url: url) }
|
9
|
+
before { allow(License).to receive(:find).with(url: url) { license } }
|
10
|
+
|
11
|
+
let(:obj) { double(pid: "test:1", id: "test:1", license: nil, parent: nil, admin_policy: nil, admin_policy_id: nil) }
|
12
|
+
|
13
|
+
describe "when the object has a license" do
|
14
|
+
before { allow(obj).to receive(:license) { url } }
|
15
|
+
it { is_expected.to eq(license) }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "when the object does not have a license" do
|
19
|
+
describe "and the object has a parent" do
|
20
|
+
let(:parent) { double(pid: "test:2", license: nil) }
|
21
|
+
before do
|
22
|
+
allow(obj).to receive(:parent) { parent }
|
23
|
+
end
|
24
|
+
describe "and the parent has a license" do
|
25
|
+
before do
|
26
|
+
allow(parent).to receive(:license) { url }
|
27
|
+
end
|
28
|
+
it { is_expected.to eq(license) }
|
29
|
+
end
|
30
|
+
describe "and the parent does not have a license" do
|
31
|
+
it { is_expected.to be_nil }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
describe "and the object does not have a parent" do
|
35
|
+
describe "and the object has an admin policy" do
|
36
|
+
let(:admin_policy) { double(pid: "test:3", id: "test:3", license: nil) }
|
37
|
+
before { allow(obj).to receive(:admin_policy) { admin_policy } }
|
38
|
+
describe "and the admin policy has a different id from the object" do
|
39
|
+
before do
|
40
|
+
allow(obj).to receive(:admin_policy_id) { "test:3" }
|
41
|
+
end
|
42
|
+
describe "and the admin policy has a license" do
|
43
|
+
before do
|
44
|
+
allow(admin_policy).to receive(:license) { url }
|
45
|
+
end
|
46
|
+
it { is_expected.to eq(license) }
|
47
|
+
end
|
48
|
+
describe "and the admin policy does not have a license" do
|
49
|
+
it { is_expected.to be_nil }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
describe "and the admin policy has the same id as the object" do
|
53
|
+
before { allow(obj).to receive(:admin_policy_id) { obj.id } }
|
54
|
+
it { is_expected.to be_nil }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
describe "and the object does not have an admin policy" do
|
58
|
+
it { is_expected.to be_nil }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
data/spec/models/events_spec.rb
CHANGED
@@ -1,66 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
1
2
|
require 'support/shared_examples_for_events'
|
2
3
|
|
3
|
-
module Ddr
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
RSpec.describe UpdateEvent, type: :model, events: true do
|
9
|
-
it_behaves_like "an event"
|
10
|
-
its(:display_type) { is_expected.to eq "Update" }
|
11
|
-
end
|
12
|
-
|
13
|
-
RSpec.describe CreationEvent, type: :model, events: true do
|
14
|
-
it_behaves_like "an event"
|
15
|
-
it_behaves_like "a preservation-related event"
|
16
|
-
its(:display_type) { is_expected.to eq "Creation" }
|
17
|
-
end
|
4
|
+
module Ddr
|
5
|
+
module Events
|
6
|
+
RSpec.describe Event, type: :model, events: true do
|
7
|
+
it_behaves_like "an event"
|
8
|
+
end
|
18
9
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
its(:display_type) { is_expected.to eq "Fixity Check" }
|
24
|
-
describe "defaults" do
|
25
|
-
it "should set software to the Fedora repository version" do
|
26
|
-
expect(subject.software).to match /^Fedora Repository \d\.\d\.\d$/
|
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"
|
27
14
|
end
|
28
15
|
end
|
29
|
-
end
|
30
16
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
37
24
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
+
pending "Fedora 4 API for getting repository version"
|
35
|
+
expect(subject.software).to match /^Fedora Repository \d\.\d\.\d$/
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
RSpec.describe VirusCheckEvent, type: :model, events: true do
|
41
|
+
it_behaves_like "an event"
|
42
|
+
it_behaves_like "a preservation-related event"
|
43
|
+
it_behaves_like "an event that reindexes its object after save"
|
44
|
+
it "should have a display type" do
|
45
|
+
expect(subject.display_type).to eq "Virus Check"
|
46
|
+
end
|
47
|
+
end
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
RSpec.describe IngestionEvent, type: :model, events: true do
|
50
|
+
it_behaves_like "an event"
|
51
|
+
it_behaves_like "a preservation-related event"
|
52
|
+
it "should have a display type" do
|
53
|
+
expect(subject.display_type).to eq "Ingestion"
|
54
|
+
end
|
55
|
+
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
RSpec.describe ValidationEvent, type: :model, events: true do
|
58
|
+
it_behaves_like "an event"
|
59
|
+
it_behaves_like "a preservation-related event"
|
60
|
+
it "should have a display type" do
|
61
|
+
expect(subject.display_type).to eq "Validation"
|
62
|
+
end
|
63
|
+
end
|
60
64
|
|
61
|
-
describe
|
62
|
-
|
63
|
-
|
65
|
+
RSpec.describe DeletionEvent, type: :model, events: true do
|
66
|
+
it_behaves_like "an event"
|
67
|
+
it_behaves_like "a preservation-related event"
|
68
|
+
it "should have a display type" do
|
69
|
+
expect(subject.display_type).to eq "Deletion"
|
70
|
+
end
|
64
71
|
end
|
65
72
|
end
|
66
73
|
end
|
@@ -1,123 +1,23 @@
|
|
1
|
-
|
2
|
-
it "is owned by the effective user" do
|
3
|
-
expect(File.owned?(file_path)).to be true
|
4
|
-
end
|
5
|
-
it "is readable by the effective user" do
|
6
|
-
expect(File.readable?(file_path)).to be true
|
7
|
-
end
|
8
|
-
it "is writable by the effective user" do
|
9
|
-
expect(File.writable?(file_path)).to be true
|
10
|
-
end
|
11
|
-
it "does not have the sticky bit set" do
|
12
|
-
expect(File.sticky?(file_path)).to be false
|
13
|
-
end
|
14
|
-
it "has 644 mode" do
|
15
|
-
expect("%o" % File.world_readable?(file_path)).to eq "644"
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require 'spec_helper'
|
18
2
|
|
19
|
-
module Ddr
|
20
|
-
|
3
|
+
module Ddr
|
4
|
+
module Models
|
5
|
+
RSpec.describe FileManagement, :type => :model do
|
21
6
|
|
22
|
-
|
23
|
-
|
24
|
-
let(:xml_file) { fixture_file_upload("fits/image.xml", "text/xml") }
|
7
|
+
let(:object) { Component.new }
|
8
|
+
let(:file) { fixture_file_upload("imageA.tif", "image/tiff") }
|
25
9
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
it "calls add_file_datastream by default" do
|
32
|
-
expect(object).to receive(:add_file_datastream)
|
33
|
-
object.add_file image_file, "random_ds_1"
|
34
|
-
end
|
35
|
-
it "calls add_file_datastream when dsid spec is managed" do
|
36
|
-
expect(object).to receive(:add_file_datastream)
|
37
|
-
object.add_file xml_file, "fits"
|
38
|
-
end
|
39
|
-
it "calls add_external_file when dsid spec is external" do
|
40
|
-
expect(object).to receive(:add_external_file)
|
41
|
-
.with(image_file, "content", mime_type: "image/tiff")
|
42
|
-
object.add_file image_file, "content"
|
43
|
-
end
|
44
|
-
it "calls add_external_file when :external => true option passed" do
|
45
|
-
expect(object).to receive(:add_external_file)
|
46
|
-
.with(image_file, "random_ds_2", mime_type: "image/tiff")
|
47
|
-
object.add_file image_file, "random_ds_2", external: true
|
48
|
-
end
|
49
|
-
context "original_filename" do
|
50
|
-
context "when dsid == 'content'" do
|
51
|
-
it "sets original_filename" do
|
52
|
-
expect { object.add_file image_file, "content" }
|
53
|
-
.to change(object, :original_filename).to("imageA.tif")
|
54
|
-
expect { object.add_file image_file, "content", original_filename: "foo.tif" }
|
55
|
-
.to change(object, :original_filename).to("foo.tif")
|
56
|
-
end
|
10
|
+
describe "#add_file" do
|
11
|
+
it "should run a virus scan on the file" do
|
12
|
+
expect(object).to receive(:virus_scan)
|
13
|
+
object.add_file file, path: "m_content"
|
57
14
|
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
.not_to change(object, :original_filename)
|
62
|
-
expect { object.add_file xml_file, "fits", original_filename: "foo" }
|
63
|
-
.not_to change(object, :original_filename)
|
64
|
-
end
|
15
|
+
it "should set the mimeType" do
|
16
|
+
object.add_file file, path: "m_content"
|
17
|
+
expect(object.m_content.mime_type).to eq('image/tiff')
|
65
18
|
end
|
66
19
|
end
|
67
|
-
end
|
68
20
|
|
69
|
-
describe "#add_external_file" do
|
70
|
-
it "calls add_external_datastream if no spec for dsid" do
|
71
|
-
expect(object).to receive(:add_external_datastream).with("random_ds_3").and_call_original
|
72
|
-
object.add_external_file(image_file, "random_ds_3")
|
73
|
-
end
|
74
|
-
it "raises an exception if datastream is not external" do
|
75
|
-
expect { object.add_external_file(xml_file, "fits") }.to raise_error(ArgumentError)
|
76
|
-
end
|
77
|
-
it "sets the mimeType" do
|
78
|
-
expect(object.content).to receive(:mimeType=).with("image/tiff")
|
79
|
-
object.add_external_file(image_file, "content", mime_type: "image/tiff")
|
80
|
-
end
|
81
|
-
it "sets dsLocation to URI for generated file path by default" do
|
82
|
-
object.add_external_file(image_file, "content")
|
83
|
-
expect(object.content.dsLocation).not_to eq URI.escape("file:#{image_file.path}")
|
84
|
-
expect(object.content.dsLocation).not_to be_nil
|
85
|
-
expect(File.exists?(object.content.file_path)).to be true
|
86
|
-
end
|
87
|
-
context "external file permissions" do
|
88
|
-
before { object.add_external_file(image_file, "content") }
|
89
|
-
it_should_behave_like "a repository external file" do
|
90
|
-
let(:file_path) { object.content.file_path }
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "#add_external_datastream" do
|
96
|
-
it "returns a new external datastream" do
|
97
|
-
ds = object.add_external_datastream("random_ds_27")
|
98
|
-
expect(ds.controlGroup).to eq "E"
|
99
|
-
expect(object.datastreams["random_ds_27"]).to eq ds
|
100
|
-
expect(object.random_ds_27).to eq ds
|
101
|
-
end
|
102
21
|
end
|
103
|
-
|
104
|
-
describe "#external_datastream_file_paths" do
|
105
|
-
let(:file1) { fixture_file_upload("imageA.tif", "image/tiff") }
|
106
|
-
let(:file2) { fixture_file_upload("imageC.tif", "image/tiff") }
|
107
|
-
before do
|
108
|
-
object.add_file(file1, "content")
|
109
|
-
object.save
|
110
|
-
object.add_file(file2, "e_content_2", external: true)
|
111
|
-
object.save
|
112
|
-
end
|
113
|
-
it "returns a list of file paths for all versions of all external datastreams for the object" do
|
114
|
-
paths = object.external_datastream_file_paths
|
115
|
-
expect(paths.size).to eq 2
|
116
|
-
paths.each do |path|
|
117
|
-
expect(File.exists?(path)).to be true
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
22
|
end
|
123
23
|
end
|