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,10 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
RSpec.describe ActiveFedora::Base do
|
2
4
|
|
3
5
|
describe ".find" do
|
4
6
|
let!(:collection) { FactoryGirl.create(:collection) }
|
5
7
|
describe "when called on the wrong class" do
|
6
8
|
it "should raise an exception" do
|
7
|
-
expect { Item.find(collection.pid) }.to raise_error(
|
9
|
+
expect { Item.find(collection.pid) }.to raise_error(ActiveFedora::ActiveFedoraError)
|
8
10
|
end
|
9
11
|
end
|
10
12
|
describe "when called on Ddr::Models::Base" do
|
@@ -24,10 +26,108 @@ RSpec.describe ActiveFedora::Base do
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
+
describe "attachments", attachments: true do
|
30
|
+
before do
|
31
|
+
class AttachToable < ActiveFedora::Base
|
32
|
+
include Ddr::Models::HasAttachments
|
33
|
+
end
|
34
|
+
end
|
35
|
+
after do
|
36
|
+
Object.send(:remove_const, :AttachToable)
|
37
|
+
end
|
38
|
+
describe "#can_have_attachments?" do
|
39
|
+
it "#should return true if the object can have attachments, otherwise false" do
|
40
|
+
expect(AttachToable.new.can_have_attachments?).to be_truthy
|
41
|
+
expect(ActiveFedora::Base.new.can_have_attachments?).to be_falsey
|
42
|
+
end
|
43
|
+
end
|
44
|
+
describe "#has_attachments?" do
|
45
|
+
let(:attach_toable) { AttachToable.new }
|
46
|
+
before { attach_toable.attachments << Attachment.new }
|
47
|
+
it "should return true if the object has Attachments, otherwise false" do
|
48
|
+
expect(AttachToable.new).not_to have_attachments
|
49
|
+
expect(ActiveFedora::Base.new).not_to have_attachments
|
50
|
+
expect(attach_toable).to have_attachments
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "children", children: true do
|
56
|
+
before do
|
57
|
+
class Childrenable < ActiveFedora::Base
|
58
|
+
has_many :children, property: :is_member_of, class_name: 'ActiveFedora::Base'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
after do
|
62
|
+
Object.send(:remove_const, :Childrenable)
|
63
|
+
end
|
64
|
+
describe "#can_have_children?" do
|
65
|
+
it "should return true if object can have children, otherwise false" do
|
66
|
+
expect(Childrenable.new.can_have_children?).to be_truthy
|
67
|
+
expect(ActiveFedora::Base.new.can_have_children?).to be_falsey
|
68
|
+
end
|
69
|
+
end
|
70
|
+
describe "#has_children?" do
|
71
|
+
let(:childrenable) { Childrenable.new }
|
72
|
+
before { childrenable.children << ActiveFedora::Base.new }
|
73
|
+
it "should return true if object has children, otherwise false" do
|
74
|
+
expect(Childrenable.new).not_to have_children
|
75
|
+
expect(ActiveFedora::Base.new).not_to have_children
|
76
|
+
expect(childrenable).to have_children
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
29
80
|
|
30
|
-
|
31
|
-
|
81
|
+
describe "thumbnail" do
|
82
|
+
before do
|
83
|
+
class Thumbnailable < ActiveFedora::Base
|
84
|
+
include Ddr::Models::HasThumbnail
|
85
|
+
end
|
86
|
+
end
|
87
|
+
after do
|
88
|
+
Object.send(:remove_const, :Thumbnailable)
|
89
|
+
end
|
90
|
+
describe "#can_have_thumbnail?" do
|
91
|
+
it "should return true if object can have a thumbnail, else false" do
|
92
|
+
expect(Thumbnailable.new.can_have_thumbnail?).to be_truthy
|
93
|
+
expect(ActiveFedora::Base.new.can_have_thumbnail?).to be_falsey
|
94
|
+
end
|
95
|
+
end
|
96
|
+
describe "#has_thumbnail?" do
|
97
|
+
let(:thumbnailable) { Thumbnailable.new }
|
98
|
+
before { allow(thumbnailable.datastreams[Ddr::Datastreams::THUMBNAIL]).to receive(:has_content?).and_return(true) }
|
99
|
+
it "should return true if object has a thumbnail, else false" do
|
100
|
+
expect(thumbnailable).to have_thumbnail
|
101
|
+
expect(Thumbnailable.new).not_to have_thumbnail
|
102
|
+
expect(ActiveFedora::Base.new).not_to have_thumbnail
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "content" do
|
108
|
+
before do
|
109
|
+
class Contentable < ActiveFedora::Base
|
110
|
+
include Ddr::Models::HasContent
|
111
|
+
end
|
112
|
+
end
|
113
|
+
after do
|
114
|
+
Object.send(:remove_const, :Contentable)
|
115
|
+
end
|
116
|
+
describe "#can_have_content?" do
|
117
|
+
it "should return true if object can have content, else false" do
|
118
|
+
expect(Contentable.new.can_have_content?).to be_truthy
|
119
|
+
expect(ActiveFedora::Base.new.can_have_content?).to be_falsey
|
120
|
+
end
|
121
|
+
end
|
122
|
+
describe "#has_content?" do
|
123
|
+
let(:contentable) { Contentable.new }
|
124
|
+
before { allow(contentable.datastreams[Ddr::Datastreams::CONTENT]).to receive(:has_content?).and_return(true) }
|
125
|
+
it "should return true if object has content, else false" do
|
126
|
+
expect(contentable).to have_content
|
127
|
+
expect(Contentable.new).not_to have_content
|
128
|
+
expect(ActiveFedora::Base.new).not_to have_content
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
32
132
|
|
33
133
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
module ActiveFedora
|
2
4
|
RSpec.describe Datastream do
|
3
5
|
|
4
6
|
describe "#tempfile" do
|
5
|
-
subject { described_class.new(nil, "DS1", controlGroup: "M") }
|
6
7
|
describe "when the datastream has no content" do
|
7
8
|
it "should raise an exception" do
|
8
9
|
expect { subject.tempfile { |f| puts f.path } }.to raise_error(Ddr::Models::Error)
|
@@ -12,7 +13,7 @@ module ActiveFedora
|
|
12
13
|
let(:file) { fixture_file_upload("sample.pdf", "application/pdf") }
|
13
14
|
before do
|
14
15
|
subject.content = file.read
|
15
|
-
subject.
|
16
|
+
subject.mime_type = file.content_type
|
16
17
|
allow(subject).to receive(:pid) { "test:1" }
|
17
18
|
end
|
18
19
|
describe "the yielded file" do
|
@@ -23,7 +24,7 @@ module ActiveFedora
|
|
23
24
|
end
|
24
25
|
it "should use the prefix provided" do
|
25
26
|
subject.tempfile(prefix: "foo") do |f|
|
26
|
-
expect(File.basename(f.path).start_with?("foo")).to be true
|
27
|
+
expect(::File.basename(f.path).start_with?("foo")).to be true
|
27
28
|
end
|
28
29
|
end
|
29
30
|
it "should use the sufffix provided" do
|
@@ -31,9 +32,21 @@ module ActiveFedora
|
|
31
32
|
expect(f.path.end_with?("bar")).to be true
|
32
33
|
end
|
33
34
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
describe "default prefix" do
|
36
|
+
describe "when the file has an id" do
|
37
|
+
it "should start with the id" do
|
38
|
+
allow(subject).to receive(:id) { "4f/78/97/71/4f789771-c663-466a-98a8-fd7c6fa0f452/foo" }
|
39
|
+
subject.tempfile do |f|
|
40
|
+
expect(::File.basename(f.path).start_with?("4f_78_97_71_4f789771-c663-466a-98a8-fd7c6fa0f452_foo--")).to be true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
describe "when the file has no id" do
|
45
|
+
it "should be NEW" do
|
46
|
+
subject.tempfile do |f|
|
47
|
+
expect(::File.basename(f.path).start_with?("NEW--")).to be true
|
48
|
+
end
|
49
|
+
end
|
37
50
|
end
|
38
51
|
end
|
39
52
|
it "should have the same size as the datastream content" do
|
@@ -46,152 +59,72 @@ module ActiveFedora
|
|
46
59
|
end
|
47
60
|
|
48
61
|
describe "#validate_checksum!" do
|
49
|
-
|
50
|
-
let
|
51
|
-
let!(:checksum_type) { "SHA-256" }
|
62
|
+
let(:checksum) { ActiveFedora::Checksum.new(obj) }
|
63
|
+
let(:obj) { double(digest: [::RDF::URI("urn:sha1:bb3200c2ddaee4bd7b9a4dc1ad3e10ed886eaef1")]) }
|
52
64
|
context "with unpersisted content" do
|
53
65
|
context "the datstream is new" do
|
54
|
-
before { allow(subject).to receive(:
|
66
|
+
before { allow(subject).to receive(:new_record?) { true } }
|
55
67
|
it "should raise an exception" do
|
56
|
-
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
68
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
57
69
|
end
|
58
70
|
end
|
59
71
|
context "the datastream content has changed" do
|
60
72
|
before { allow(subject).to receive(:content_changed?) { true } }
|
61
73
|
it "should raise an exception" do
|
62
|
-
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
74
|
+
expect { subject.validate_checksum!(checksum, checksum_type) }.to raise_error
|
63
75
|
end
|
64
76
|
end
|
65
77
|
end
|
66
78
|
context "with persisted content" do
|
67
79
|
before do
|
68
|
-
allow(subject).to receive(:
|
80
|
+
allow(subject).to receive(:new_record?) { false }
|
69
81
|
allow(subject).to receive(:pid) { "foobar:1" }
|
70
|
-
allow(subject).to receive(:dsCreateDate) { DateTime.now }
|
71
82
|
allow(subject).to receive(:checksum) { checksum }
|
72
|
-
allow(subject).to receive(:checksumType) { checksum_type }
|
73
83
|
end
|
74
84
|
context "and the repository internal checksum in invalid" do
|
75
|
-
before { allow(subject).to receive(:
|
85
|
+
before { allow(subject).to receive(:check_fixity) { false } }
|
76
86
|
it "should raise an error" do
|
77
|
-
expect { subject.validate_checksum!(checksum,
|
87
|
+
expect { subject.validate_checksum!(checksum.value, checksum.algorithm) }
|
88
|
+
.to raise_error(Ddr::Models::ChecksumInvalid)
|
78
89
|
end
|
79
90
|
end
|
80
91
|
context "and the repository internal checksum is valid" do
|
81
|
-
before { allow(subject).to receive(:
|
92
|
+
before { allow(subject).to receive(:check_fixity) { true } }
|
82
93
|
context "and the checksum type is invalid" do
|
83
|
-
before { allow(subject).to receive(:content) {
|
94
|
+
before { allow(subject).to receive(:content) { double } }
|
84
95
|
it "should raise an exception" do
|
85
|
-
expect { subject.validate_checksum!("0123456789abcdef", "FOO-BAR") }
|
96
|
+
expect { subject.validate_checksum!("0123456789abcdef", "FOO-BAR") }
|
97
|
+
.to raise_error(ArgumentError)
|
86
98
|
end
|
87
99
|
end
|
88
100
|
context "and the checksum type is nil" do
|
89
101
|
it "should compare the provided checksum with the datastream checksum" do
|
90
|
-
expect { subject.validate_checksum!(checksum) }
|
102
|
+
expect { subject.validate_checksum!(checksum.value) }
|
103
|
+
.not_to raise_error(Ddr::Models::Error)
|
91
104
|
end
|
92
105
|
end
|
93
106
|
context "and the checksum type is the same as the datastream checksum type" do
|
94
107
|
it "should compare the provided checksum with the datastream checksum" do
|
95
|
-
expect { subject.validate_checksum!(checksum,
|
108
|
+
expect { subject.validate_checksum!(checksum.value, checksum.algorithm) }
|
109
|
+
.not_to raise_error(Ddr::Models::Error)
|
96
110
|
end
|
97
111
|
end
|
98
112
|
context "and the checksum type differs from the datastream checksum type" do
|
99
113
|
let!(:md5digest) { "273ae0f4aa60d94e89bc0e0652ae2c8f" }
|
100
114
|
it "should generate a checksum for comparison" do
|
101
|
-
expect(subject).not_to receive(:checksum)
|
102
115
|
allow(subject).to receive(:content_digest).with("MD5") { md5digest }
|
103
|
-
expect { subject.validate_checksum!(md5digest, "MD5") }.not_to raise_error
|
116
|
+
expect { subject.validate_checksum!(md5digest, "MD5") }.not_to raise_error(Ddr::Models::Error)
|
104
117
|
end
|
105
118
|
end
|
106
119
|
context "and the checksum doesn't match" do
|
107
120
|
it "should raise an exception" do
|
108
|
-
expect { subject.validate_checksum!("0123456789abcdef",
|
121
|
+
expect { subject.validate_checksum!("0123456789abcdef", checksum.algorithm) }
|
122
|
+
.to raise_error(Ddr::Models::ChecksumInvalid)
|
109
123
|
end
|
110
124
|
end
|
111
125
|
end
|
112
126
|
end
|
113
127
|
end
|
114
128
|
|
115
|
-
describe "extensions for external datastreams" do
|
116
|
-
subject { described_class.new(nil, nil, controlGroup: "E") }
|
117
|
-
|
118
|
-
describe "#file_path" do
|
119
|
-
it "should return nil when dsLocation is not set" do
|
120
|
-
expect(subject.file_path).to be_nil
|
121
|
-
end
|
122
|
-
it "should return nil when dsLocation is not a file URI" do
|
123
|
-
subject.dsLocation = "http://library.duke.edu/"
|
124
|
-
expect(subject.file_path).to be_nil
|
125
|
-
end
|
126
|
-
it "should return the file path when dsLocation is a file URI" do
|
127
|
-
subject.dsLocation = "file:/tmp/foo/bar.txt"
|
128
|
-
expect(subject.file_path).to eq "/tmp/foo/bar.txt"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe "#file_name" do
|
133
|
-
it "should return nil when dsLocation is not set" do
|
134
|
-
expect(subject.file_name).to be_nil
|
135
|
-
end
|
136
|
-
it "should return nil when dsLocation is not a file URI" do
|
137
|
-
subject.dsLocation = "http://library.duke.edu/"
|
138
|
-
expect(subject.file_name).to be_nil
|
139
|
-
end
|
140
|
-
it "should return the file name when dsLocation is a file URI" do
|
141
|
-
subject.dsLocation = "file:/tmp/foo/bar.txt"
|
142
|
-
expect(subject.file_name).to eq "bar.txt"
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
describe "#file_size" do
|
147
|
-
it "should return nil when dsLocation is not set" do
|
148
|
-
expect(subject.file_size).to be_nil
|
149
|
-
end
|
150
|
-
it "should return nil when dsLocation is not a file URI" do
|
151
|
-
subject.dsLocation = "http://library.duke.edu/"
|
152
|
-
expect(subject.file_size).to be_nil
|
153
|
-
end
|
154
|
-
it "should return the file name when dsLocation is a file URI" do
|
155
|
-
allow(File).to receive(:size).with("/tmp/foo/bar.txt") { 42 }
|
156
|
-
subject.dsLocation = "file:/tmp/foo/bar.txt"
|
157
|
-
expect(subject.file_size).to eq 42
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
end # external datastreams
|
162
|
-
|
163
|
-
describe "notifications" do
|
164
|
-
let(:events) { [] }
|
165
|
-
before {
|
166
|
-
@subscriber = ActiveSupport::Notifications.subscribe(event_name) do |name, start, finish, id, payload|
|
167
|
-
events << payload
|
168
|
-
end
|
169
|
-
}
|
170
|
-
after {
|
171
|
-
ActiveSupport::Notifications.unsubscribe(@subscriber)
|
172
|
-
}
|
173
|
-
describe "on create" do
|
174
|
-
let(:obj) { ActiveFedora::Base.create }
|
175
|
-
let(:event_name) { "save.repo_file" }
|
176
|
-
specify {
|
177
|
-
obj.add_file_datastream("foo", dsid: "DS1", controlGroup: "M")
|
178
|
-
obj.save!
|
179
|
-
expect(events.last[:pid]).to eq obj.pid
|
180
|
-
expect(events.last[:file_id]).to eq "DS1"
|
181
|
-
expect(events.last[:profile]).to be_present
|
182
|
-
}
|
183
|
-
end
|
184
|
-
describe "on destroy" do
|
185
|
-
let(:obj) { FactoryGirl.create(:item) }
|
186
|
-
let(:event_name) { "delete.repo_file" }
|
187
|
-
specify {
|
188
|
-
obj.descMetadata.delete
|
189
|
-
expect(events.first[:pid]).to eq obj.pid
|
190
|
-
expect(events.first[:file_id]).to eq "descMetadata"
|
191
|
-
expect(events.first[:profile]).to be_present
|
192
|
-
}
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
129
|
end
|
197
130
|
end
|
@@ -1,58 +1,25 @@
|
|
1
1
|
module Ddr::Models
|
2
|
-
RSpec.describe AdminSet
|
2
|
+
RSpec.describe AdminSet do
|
3
3
|
|
4
4
|
describe ".call" do
|
5
|
-
|
5
|
+
subject { described_class.call(obj) }
|
6
6
|
|
7
7
|
describe "when the object has an admin set" do
|
8
|
-
|
9
|
-
|
10
|
-
described_class.
|
11
|
-
|
12
|
-
describe "and the admin set code is found" do
|
13
|
-
before {
|
14
|
-
allow(described_class).to receive(:find_by_code).with("dvs") { admin_set }
|
15
|
-
}
|
16
|
-
it "returns an AdminSet instance" do
|
17
|
-
expect(described_class.call(obj)).to eq(admin_set)
|
8
|
+
let(:obj) { double(admin_set: "dvs") }
|
9
|
+
before do
|
10
|
+
allow(described_class).to receive(:find).with(code: "dvs") do
|
11
|
+
described_class.new("id"=>1, "code"=>"dvs", "title"=>"Data and Visualization Services", "created_at"=>"2015-09-15T16:15:58.514Z", "updated_at"=>"2015-09-15T16:15:58.514Z")
|
18
12
|
end
|
19
13
|
end
|
20
|
-
describe "and the admin set is not found" do
|
21
|
-
before {
|
22
|
-
allow(described_class).to receive(:find_by_code).with("dvs")
|
23
|
-
.and_raise(ActiveResource::ResourceNotFound, "404")
|
24
|
-
}
|
25
|
-
it "raises an exception" do
|
26
|
-
expect { described_class.call(obj) }.to raise_error(Ddr::Models::NotFoundError)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
14
|
|
31
|
-
|
32
|
-
it "returns nil" do
|
33
|
-
expect(described_class).to receive(:find_by_code).and_call_original
|
34
|
-
expect(described_class.call(obj)).to be_nil
|
35
|
-
end
|
15
|
+
its(:to_s) { is_expected.to eq("Data and Visualization Services") }
|
36
16
|
end
|
37
|
-
end
|
38
17
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
let(:response_collection) { ActiveResource::Collection.new }
|
43
|
-
before do
|
44
|
-
response_collection.elements = entries
|
45
|
-
allow(described_class).to receive(:all) { response_collection }
|
46
|
-
end
|
47
|
-
it "returns the defined codes" do
|
48
|
-
expect(described_class.keys).to match_array([ entries[0].code, entries[1].code ])
|
18
|
+
describe "when the object does not have an admin set" do
|
19
|
+
let(:obj) { double(admin_set: nil) }
|
20
|
+
it { is_expected.to be_nil }
|
49
21
|
end
|
50
22
|
end
|
51
23
|
|
52
|
-
describe "instance methods" do
|
53
|
-
subject { described_class.new("id"=>1, "code"=>"dvs", "title"=>"Data and Visualization Services", "created_at"=>"2015-09-15T16:15:58.514Z", "updated_at"=>"2015-09-15T16:15:58.514Z") }
|
54
|
-
its(:to_s) { is_expected.to eq("Data and Visualization Services") }
|
55
|
-
end
|
56
|
-
|
57
24
|
end
|
58
25
|
end
|
@@ -1,10 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
RSpec.describe Attachment, type: :model, attachments: 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, :attached_to, :is_attached_to, "ActiveFedora::Base"
|
6
7
|
it_behaves_like "a non-collection model"
|
7
|
-
it_behaves_like "an unpublishable object"
|
8
|
-
it_behaves_like "an object that cannot be streamable"
|
9
8
|
|
10
9
|
end
|
@@ -1,34 +1,15 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
RSpec.describe Collection, type: :model do
|
4
4
|
|
5
5
|
it_behaves_like "a DDR model"
|
6
|
-
it_behaves_like "it has an association", :has_many, :children, :is_member_of_collection, "Item"
|
7
|
-
it_behaves_like "it has an association", :has_many, :targets, :is_external_target_for, "Target"
|
8
|
-
it_behaves_like "a publishable object"
|
9
|
-
it_behaves_like "an object that cannot be streamable"
|
10
|
-
|
11
|
-
describe "admin set" do
|
12
|
-
before do
|
13
|
-
subject.admin_set = "foo"
|
14
|
-
end
|
15
|
-
it "indexes the admin set title" do
|
16
|
-
expect(subject.to_solr[Ddr::Index::Fields::ADMIN_SET_TITLE]).to eq("Foo Admin Set")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "title" do
|
21
|
-
it "indexes the collection title" do
|
22
|
-
expect(subject.to_solr[Ddr::Index::Fields::COLLECTION_TITLE]).to eq("Test Collection")
|
23
|
-
end
|
24
|
-
end
|
25
6
|
|
26
7
|
describe "#components_from_solr" do
|
27
|
-
subject { Collection.new(
|
8
|
+
subject { Collection.new(id: 'test-1') }
|
28
9
|
before do
|
29
|
-
allow_any_instance_of(Component).to receive(:
|
10
|
+
allow_any_instance_of(Component).to receive(:collection_id).and_return(subject.id)
|
30
11
|
end
|
31
|
-
it "
|
12
|
+
it "should return the correct component(s)" do
|
32
13
|
component = Component.create
|
33
14
|
docs = subject.components_from_solr
|
34
15
|
expect(docs.size).to eq(1)
|
@@ -37,18 +18,15 @@ RSpec.describe Collection, type: :model do
|
|
37
18
|
end
|
38
19
|
|
39
20
|
describe "validation" do
|
40
|
-
|
41
|
-
subject.title = nil
|
42
|
-
end
|
43
|
-
it "requires a title" do
|
21
|
+
it "should require a title" do
|
44
22
|
expect(subject).to_not be_valid
|
45
|
-
expect(subject.errors.messages).to have_key(:
|
23
|
+
expect(subject.errors.messages).to have_key(:dc_title)
|
46
24
|
end
|
47
25
|
end
|
48
26
|
|
49
27
|
describe "creation" do
|
50
|
-
|
51
|
-
it "
|
28
|
+
subject { Collection.create(dc_title: [ "Test Collection" ]) }
|
29
|
+
it "should be governed by itself" do
|
52
30
|
expect(subject.admin_policy).to eq(subject)
|
53
31
|
end
|
54
32
|
end
|
@@ -56,200 +34,8 @@ RSpec.describe Collection, type: :model do
|
|
56
34
|
describe "roles granted to creator" do
|
57
35
|
let(:user) { FactoryGirl.build(:user) }
|
58
36
|
before { subject.grant_roles_to_creator(user) }
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
describe "default roles granted" do
|
63
|
-
describe "and the metadata managers group is set" do
|
64
|
-
before do
|
65
|
-
allow(Ddr::Auth).to receive(:metadata_managers_group) { "metadata_managers" }
|
66
|
-
subject.save!
|
67
|
-
end
|
68
|
-
it "includes the MetadataEditor role in policy scope for the Metadata Managers group" do
|
69
|
-
expect(subject.roles.to_a).to eq([Ddr::Auth::Roles::Role.build(type: "MetadataEditor", agent: "metadata_managers", scope: "policy")])
|
70
|
-
end
|
71
|
-
end
|
72
|
-
describe "and the metadata managers group is not set" do
|
73
|
-
before do
|
74
|
-
allow(Ddr::Auth).to receive(:metadata_managers_group) { nil }
|
75
|
-
subject.save!
|
76
|
-
end
|
77
|
-
its(:roles) { is_expected.to be_empty }
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "attachments" do
|
82
|
-
its(:can_have_attachments?) { is_expected.to be true }
|
83
|
-
it { is_expected.not_to have_attachments }
|
84
|
-
specify {
|
85
|
-
subject.attachments << Attachment.new
|
86
|
-
expect(subject).to have_attachments
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "content" do
|
91
|
-
its(:can_have_content?) { is_expected.to be false }
|
92
|
-
it { is_expected.to_not have_content }
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "children" do
|
96
|
-
its(:can_have_children?) { is_expected.to be true }
|
97
|
-
it { is_expected.to_not have_children }
|
98
|
-
specify {
|
99
|
-
subject.children << Item.new
|
100
|
-
expect(subject).to have_children
|
101
|
-
}
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "#default_structure" do
|
105
|
-
before do
|
106
|
-
allow(SecureRandom).to receive(:uuid).and_return("abc-def", "ghi-jkl", "mno-pqr", "stu-vwx", "yza-bcd", "efg-hij")
|
107
|
-
end
|
108
|
-
describe "when the collection has no items" do
|
109
|
-
let(:expected) do
|
110
|
-
xml = <<-EOS
|
111
|
-
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
112
|
-
<metsHdr>
|
113
|
-
<agent ROLE="#{Ddr::Models::Structures::Agent::ROLE_CREATOR}">
|
114
|
-
<name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
|
115
|
-
</agent>
|
116
|
-
</metsHdr>
|
117
|
-
<structMap TYPE="#{Ddr::Models::Structure::TYPE_DEFAULT}" />
|
118
|
-
</mets>
|
119
|
-
EOS
|
120
|
-
xml
|
121
|
-
end
|
122
|
-
it "should be the appropriate structure" do
|
123
|
-
expect(subject.default_structure.to_xml).to be_equivalent_to(expected)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
describe "when the collection has items" do
|
127
|
-
let(:item1) { FactoryGirl.create(:item) }
|
128
|
-
let(:item2) { FactoryGirl.create(:item) }
|
129
|
-
before do
|
130
|
-
item1.local_id = "test002"
|
131
|
-
item1.permanent_id = "ark:/99999/fk4aaa"
|
132
|
-
item1.save!
|
133
|
-
item2.local_id = "test001"
|
134
|
-
item2.permanent_id = "ark:/99999/fk4bbb"
|
135
|
-
item2.save!
|
136
|
-
subject.children << item1
|
137
|
-
subject.children << item2
|
138
|
-
subject.save!
|
139
|
-
end
|
140
|
-
after do
|
141
|
-
item1.destroy
|
142
|
-
item2.destroy
|
143
|
-
end
|
144
|
-
describe "without nested paths" do
|
145
|
-
let(:expected) do
|
146
|
-
xml = <<-EOS
|
147
|
-
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
148
|
-
<metsHdr>
|
149
|
-
<agent ROLE="#{Ddr::Models::Structures::Agent::ROLE_CREATOR}">
|
150
|
-
<name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
|
151
|
-
</agent>
|
152
|
-
</metsHdr>
|
153
|
-
<structMap TYPE="#{Ddr::Models::Structure::TYPE_DEFAULT}">
|
154
|
-
<div ORDER="1">
|
155
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4bbb" />
|
156
|
-
</div>
|
157
|
-
<div ORDER="2">
|
158
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4aaa" />
|
159
|
-
</div>
|
160
|
-
</structMap>
|
161
|
-
</mets>
|
162
|
-
EOS
|
163
|
-
xml
|
164
|
-
end
|
165
|
-
it "should be the appropriate structure" do
|
166
|
-
expect(subject.default_structure.to_xml).to be_equivalent_to(expected)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
describe "with nested paths" do
|
170
|
-
let(:item3) { FactoryGirl.create(:item) }
|
171
|
-
let(:item4) { FactoryGirl.create(:item) }
|
172
|
-
let(:item5) { FactoryGirl.create(:item) }
|
173
|
-
let(:item6) { FactoryGirl.create(:item) }
|
174
|
-
let(:expected) do
|
175
|
-
xml = <<-EOS
|
176
|
-
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
177
|
-
<metsHdr>
|
178
|
-
<agent ROLE="#{Ddr::Models::Structures::Agent::ROLE_CREATOR}">
|
179
|
-
<name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
|
180
|
-
</agent>
|
181
|
-
</metsHdr>
|
182
|
-
<structMap TYPE="#{Ddr::Models::Structure::TYPE_DEFAULT}">
|
183
|
-
<div LABEL="foo" ORDER="1" TYPE="Directory">
|
184
|
-
<div LABEL="b&apos;a&quot;r&quot;" ORDER="1" TYPE="Directory">
|
185
|
-
<div ORDER="1">
|
186
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4aaa" />
|
187
|
-
</div>
|
188
|
-
<div ORDER="2">
|
189
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4bbb" />
|
190
|
-
</div>
|
191
|
-
</div>
|
192
|
-
<div LABEL="baz" ORDER="2" TYPE="Directory">
|
193
|
-
<div ORDER="1">
|
194
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4ddd" />
|
195
|
-
</div>
|
196
|
-
<div ORDER="2">
|
197
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4ccc" />
|
198
|
-
</div>
|
199
|
-
</div>
|
200
|
-
<div ORDER="3">
|
201
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4fff" />
|
202
|
-
</div>
|
203
|
-
<div ORDER="4">
|
204
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4eee" />
|
205
|
-
</div>
|
206
|
-
</div>
|
207
|
-
</structMap>
|
208
|
-
</mets>
|
209
|
-
EOS
|
210
|
-
xml
|
211
|
-
end
|
212
|
-
before do
|
213
|
-
item3.local_id = "test003"
|
214
|
-
item3.permanent_id = "ark:/99999/fk4ccc"
|
215
|
-
item3.save!
|
216
|
-
item4.local_id = "test004"
|
217
|
-
item4.permanent_id = "ark:/99999/fk4ddd"
|
218
|
-
item4.save!
|
219
|
-
item5.local_id = "test005"
|
220
|
-
item5.permanent_id = "ark:/99999/fk4eee"
|
221
|
-
item5.save!
|
222
|
-
item6.local_id = "test006"
|
223
|
-
item6.permanent_id = "ark:/99999/fk4fff"
|
224
|
-
item6.save!
|
225
|
-
subject.children << item3
|
226
|
-
subject.children << item4
|
227
|
-
subject.children << item5
|
228
|
-
subject.children << item6
|
229
|
-
subject.save!
|
230
|
-
item1.nested_path = %Q[foo/b'a"r"/a.doc]
|
231
|
-
item1.save!
|
232
|
-
item2.nested_path = %Q[foo/b'a"r"/b.txt]
|
233
|
-
item2.save!
|
234
|
-
item3.nested_path = %Q[foo/baz/d.pdf]
|
235
|
-
item3.save!
|
236
|
-
item4.nested_path = %Q[foo/baz/c.txt]
|
237
|
-
item4.save!
|
238
|
-
item5.nested_path = %Q[foo/f.doc]
|
239
|
-
item5.save!
|
240
|
-
item6.nested_path = %Q[foo/e.pdf]
|
241
|
-
item6.save!
|
242
|
-
end
|
243
|
-
after do
|
244
|
-
item3.destroy
|
245
|
-
item4.destroy
|
246
|
-
item5.destroy
|
247
|
-
item6.destroy
|
248
|
-
end
|
249
|
-
it "should be the appropriate structure" do
|
250
|
-
expect(subject.default_structure.to_xml).to be_equivalent_to(expected)
|
251
|
-
end
|
252
|
-
end
|
37
|
+
it "should include Curator roles in both resource abd policy scopes" do
|
38
|
+
expect(subject.roles.to_a).to eq([Ddr::Auth::Roles::Role.build(type: "Curator", agent: user.agent, scope: "resource"), Ddr::Auth::Roles::Role.build(type: "Curator", agent: user.agent, scope: "policy")])
|
253
39
|
end
|
254
40
|
end
|
255
41
|
|