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,171 +1,34 @@
|
|
1
1
|
module Ddr::Models
|
2
2
|
RSpec.describe Indexing do
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
describe "general indexing" do
|
7
|
-
let(:obj) { FactoryGirl.build(:item) }
|
8
|
-
|
9
|
-
let(:role1) { FactoryGirl.build(:role, :curator, :person, :resource) }
|
10
|
-
let(:role2) { FactoryGirl.build(:role, :curator, :person, :policy) }
|
11
|
-
let(:role3) { FactoryGirl.build(:role, :editor, :group, :policy) }
|
12
|
-
let(:role4) { FactoryGirl.build(:role, :editor, :person, :policy) }
|
13
|
-
|
14
|
-
before do
|
15
|
-
obj.adminMetadata.doi << "http://doi.org/10.1000/182"
|
16
|
-
obj.affiliation << "Talk to me in the back alley."
|
17
|
-
obj.aleph_id = "lkheajklfwbsef"
|
18
|
-
obj.aspace_id = "aspace_dccea43034e1b8261e14cf999e86449d"
|
19
|
-
obj.display_format = "Image"
|
20
|
-
obj.ingested_by = "foo@bar.com"
|
21
|
-
obj.ingestion_date = "2017-01-13T18:55:29Z"
|
22
|
-
obj.license = "cc-by-nc-nd-40"
|
23
|
-
obj.local_id = "foo"
|
24
|
-
obj.permanent_id = "ark:/99999/fk4zzz"
|
25
|
-
obj.permanent_url = "http://id.library.duke.edu/ark:/99999/fk4zzz"
|
26
|
-
obj.rights_note = ["Public domain"]
|
27
|
-
obj.roles.grant role1, role2, role3, role4
|
28
|
-
obj.set_desc_metadata_values(:arranger, "Arranger Value")
|
29
|
-
obj.set_desc_metadata_values(:biblical_book, "Ecclesiastes")
|
30
|
-
obj.set_desc_metadata_values(:category, "Category Value")
|
31
|
-
obj.set_desc_metadata_values(:chapter_and_verse, "Ecclesiastes 3:19-4:3")
|
32
|
-
obj.set_desc_metadata_values(:company, "Company Value")
|
33
|
-
obj.set_desc_metadata_values(:composer, "Composer Value")
|
34
|
-
obj.set_desc_metadata_values(:engraver, "Engraver Value")
|
35
|
-
obj.set_desc_metadata_values(:folder, "Folder Value")
|
36
|
-
obj.set_desc_metadata_values(:genre, "Genre Value")
|
37
|
-
obj.set_desc_metadata_values(:illustrated, "Illustrated Value")
|
38
|
-
obj.set_desc_metadata_values(:illustrator, "Illustrator Value")
|
39
|
-
obj.set_desc_metadata_values(:instrumentation, "Instrumentation Value")
|
40
|
-
obj.set_desc_metadata_values(:interviewer_name, "Interviewer Name Value")
|
41
|
-
obj.set_desc_metadata_values(:isFormatOf, "ark:/99999/fk4aaa")
|
42
|
-
obj.set_desc_metadata_values(:isPartOf, "RL10059CS1010")
|
43
|
-
obj.set_desc_metadata_values(:lithographer, "Lithographer Value")
|
44
|
-
obj.set_desc_metadata_values(:lyricist, "Lyricist Value")
|
45
|
-
obj.set_desc_metadata_values(:medium, "Medium Value")
|
46
|
-
obj.set_desc_metadata_values(:performer, "Performer Value")
|
47
|
-
obj.set_desc_metadata_values(:placement_company, "Placement Company Value")
|
48
|
-
obj.set_desc_metadata_values(:producer, "Producer Value")
|
49
|
-
obj.set_desc_metadata_values(:product, "Product Value")
|
50
|
-
obj.set_desc_metadata_values(:publication, "Publication Value")
|
51
|
-
obj.set_desc_metadata_values(:roll_number, "10")
|
52
|
-
obj.set_desc_metadata_values(:setting, "Setting Value")
|
53
|
-
obj.set_desc_metadata_values(:subseries, "Subseries Value")
|
54
|
-
obj.set_desc_metadata_values(:temporal, "Temporal Value")
|
55
|
-
obj.set_desc_metadata_values(:tone, "Tone Value")
|
56
|
-
obj.set_desc_metadata_values(:volume, "100")
|
57
|
-
end
|
58
|
-
|
59
|
-
specify {
|
60
|
-
expect(subject[Indexing::ACCESS_ROLE]).to eq(obj.roles.to_json)
|
61
|
-
expect(subject[Indexing::ADMIN_SET_TITLE]).to be_nil
|
62
|
-
expect(subject[Indexing::AFFILIATION]).to eq(["Talk to me in the back alley."])
|
63
|
-
expect(subject[Indexing::AFFILIATION_FACET]).to eq(["Talk to me in the back alley."])
|
64
|
-
expect(subject[Indexing::ALEPH_ID]).to eq "lkheajklfwbsef"
|
65
|
-
expect(subject[Indexing::ARRANGER_FACET]).to eq(["Arranger Value"])
|
66
|
-
expect(subject[Indexing::ASPACE_ID]).to eq("aspace_dccea43034e1b8261e14cf999e86449d")
|
67
|
-
expect(subject[Indexing::BIBLICAL_BOOK_FACET]).to eq(["Ecclesiastes"])
|
68
|
-
expect(subject[Indexing::CATEGORY_FACET]).to eq(["Category Value"])
|
69
|
-
expect(subject[Indexing::CHAPTER_AND_VERSE_FACET]).to eq(["Ecclesiastes 3:19-4:3"])
|
70
|
-
expect(subject[Indexing::COMPANY_FACET]).to eq(["Company Value"])
|
71
|
-
expect(subject[Indexing::COMPOSER_FACET]).to eq(["Composer Value"])
|
72
|
-
expect(subject[Indexing::DC_IS_PART_OF]).to eq(["RL10059CS1010"])
|
73
|
-
expect(subject[Indexing::DISPLAY_FORMAT]).to eq("Image")
|
74
|
-
expect(subject[Indexing::DOI]).to eq(["http://doi.org/10.1000/182"])
|
75
|
-
expect(subject[Indexing::ENGRAVER_FACET]).to eq(["Engraver Value"])
|
76
|
-
expect(subject[Indexing::FOLDER_FACET]).to eq(["Folder Value"])
|
77
|
-
expect(subject[Indexing::GENRE_FACET]).to eq(["Genre Value"])
|
78
|
-
expect(subject[Indexing::ILLUSTRATED_FACET]).to eq(["Illustrated Value"])
|
79
|
-
expect(subject[Indexing::ILLUSTRATOR_FACET]).to eq(["Illustrator Value"])
|
80
|
-
expect(subject[Indexing::INGESTED_BY]).to eq("foo@bar.com")
|
81
|
-
expect(subject[Indexing::INGESTION_DATE]).to eq("2017-01-13T18:55:29Z")
|
82
|
-
expect(subject[Indexing::INSTRUMENTATION_FACET]).to eq(["Instrumentation Value"])
|
83
|
-
expect(subject[Indexing::INTERVIEWER_NAME_FACET]).to eq(["Interviewer Name Value"])
|
84
|
-
expect(subject[Indexing::IS_FORMAT_OF]).to eq(["ark:/99999/fk4aaa"])
|
85
|
-
expect(subject[Indexing::LICENSE]).to eq("cc-by-nc-nd-40")
|
86
|
-
expect(subject[Indexing::LITHOGRAPHER_FACET]).to eq(["Lithographer Value"])
|
87
|
-
expect(subject[Indexing::LOCAL_ID]).to eq("foo")
|
88
|
-
expect(subject[Indexing::LYRICIST_FACET]).to eq(["Lyricist Value"])
|
89
|
-
expect(subject[Indexing::MEDIUM_FACET]).to eq(["Medium Value"])
|
90
|
-
expect(subject[Indexing::PERFORMER_FACET]).to eq(["Performer Value"])
|
91
|
-
expect(subject[Indexing::PERMANENT_ID]).to eq("ark:/99999/fk4zzz")
|
92
|
-
expect(subject[Indexing::PERMANENT_URL]).to eq("http://id.library.duke.edu/ark:/99999/fk4zzz")
|
93
|
-
expect(subject[Indexing::PLACEMENT_COMPANY_FACET]).to eq(["Placement Company Value"])
|
94
|
-
expect(subject[Indexing::POLICY_ROLE]).to contain_exactly(role2.agent.first, role3.agent.first, role4.agent.first)
|
95
|
-
expect(subject[Indexing::PRODUCER_FACET]).to eq(["Producer Value"])
|
96
|
-
expect(subject[Indexing::PRODUCT_FACET]).to eq(["Product Value"])
|
97
|
-
expect(subject[Indexing::PUBLICATION_FACET]).to eq(["Publication Value"])
|
98
|
-
expect(subject[Indexing::RESOURCE_ROLE]).to contain_exactly(role1.agent.first)
|
99
|
-
expect(subject[Indexing::RIGHTS_NOTE]).to eq(["Public domain"])
|
100
|
-
expect(subject[Indexing::ROLL_NUMBER_FACET]).to eq(["10"])
|
101
|
-
expect(subject[Indexing::SETTING_FACET]).to eq(["Setting Value"])
|
102
|
-
expect(subject[Indexing::STREAMABLE_MEDIA_TYPE]).to be_nil
|
103
|
-
expect(subject[Indexing::SUBSERIES_FACET]).to eq(["Subseries Value"])
|
104
|
-
expect(subject[Indexing::TEMPORAL_FACET]).to eq(["Temporal Value"])
|
105
|
-
expect(subject[Indexing::TONE_FACET]).to eq(["Tone Value"])
|
106
|
-
expect(subject[Indexing::VOLUME_FACET]).to eq(["100"])
|
107
|
-
}
|
108
|
-
end
|
4
|
+
let(:obj) { FactoryGirl.build(:item) }
|
109
5
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
allow(obj.content).to receive(:createDate) { create_date }
|
115
|
-
}
|
6
|
+
let(:role1) { FactoryGirl.build(:role, :curator, :person, :resource) }
|
7
|
+
let(:role2) { FactoryGirl.build(:role, :curator, :person, :policy) }
|
8
|
+
let(:role3) { FactoryGirl.build(:role, :editor, :group, :policy) }
|
9
|
+
let(:role4) { FactoryGirl.build(:role, :editor, :person, :policy) }
|
116
10
|
|
117
|
-
|
118
|
-
expect(subject[Indexing::CONTENT_CREATE_DATE]).to eq "2016-01-22T21:50:33Z"
|
119
|
-
expect(subject[Indexing::ATTACHED_FILES_HAVING_CONTENT]).to contain_exactly("content", "RELS-EXT", "descMetadata", "adminMetadata")
|
120
|
-
expect(subject[Indexing::CONTENT_SIZE]).to eq 230714
|
121
|
-
expect(subject[Indexing::CONTENT_SIZE_HUMAN]).to eq "225 KB"
|
122
|
-
expect(subject[Indexing::MEDIA_TYPE]).to eq "image/tiff"
|
123
|
-
expect(subject[Indexing::MEDIA_MAJOR_TYPE]).to eq "image"
|
124
|
-
expect(subject[Indexing::MEDIA_SUB_TYPE]).to eq "tiff"
|
125
|
-
}
|
11
|
+
subject { obj.index_fields }
|
126
12
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
end
|
13
|
+
before do
|
14
|
+
obj.license = "cc-by-nc-nd-40"
|
15
|
+
obj.local_id = "foo"
|
16
|
+
obj.doi << "http://doi.org/10.1000/182"
|
17
|
+
obj.permanent_id = "ark:/99999/fk4zzz"
|
18
|
+
obj.permanent_url = "http://id.library.duke.edu/ark:/99999/fk4zzz"
|
19
|
+
obj.display_format = "Image"
|
20
|
+
obj.roles.grant role1, role2, role3, role4
|
136
21
|
end
|
137
22
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
}
|
148
|
-
end
|
23
|
+
its([Indexing::LICENSE]) { is_expected.to eq("cc-by-nc-nd-40") }
|
24
|
+
its([Indexing::LOCAL_ID]) { is_expected.to eq("foo") }
|
25
|
+
its([Indexing::DOI]) { is_expected.to eq(["http://doi.org/10.1000/182"]) }
|
26
|
+
its([Indexing::PERMANENT_ID]) { is_expected.to eq("ark:/99999/fk4zzz") }
|
27
|
+
its([Indexing::PERMANENT_URL]) { is_expected.to eq("http://id.library.duke.edu/ark:/99999/fk4zzz") }
|
28
|
+
its([Indexing::DISPLAY_FORMAT]) { is_expected.to eq("Image") }
|
29
|
+
its([Indexing::ACCESS_ROLE]) { is_expected.to eq(obj.roles.to_json) }
|
30
|
+
its([Indexing::POLICY_ROLE]) { is_expected.to contain_exactly(role2.agent.first, role3.agent.first, role4.agent.first) }
|
31
|
+
its([Indexing::RESOURCE_ROLE]) { is_expected.to contain_exactly(role1.agent.first) }
|
149
32
|
|
150
|
-
describe "language name" do
|
151
|
-
subject { FactoryGirl.build(:item) }
|
152
|
-
before do
|
153
|
-
subject.language = ["cym", "Not a Code"]
|
154
|
-
subject.save!
|
155
|
-
end
|
156
|
-
specify {
|
157
|
-
expect(subject.index_fields[Indexing::LANGUAGE_FACET]).to eq ["Welsh", "Not a Code"]
|
158
|
-
expect(subject.index_fields[Indexing::LANGUAGE_NAME]).to eq ["Welsh", "Not a Code"]
|
159
|
-
}
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "nested path" do
|
163
|
-
subject { FactoryGirl.build(:item) }
|
164
|
-
before { subject.nested_path = "/foo/bar/baz" }
|
165
|
-
specify {
|
166
|
-
expect(subject.index_fields[Indexing::NESTED_PATH]).to eq "/foo/bar/baz"
|
167
|
-
expect(subject.index_fields[Indexing::NESTED_PATH_TEXT]).to eq "/foo/bar/baz"
|
168
|
-
}
|
169
|
-
end
|
170
33
|
end
|
171
34
|
end
|
data/spec/models/item_spec.rb
CHANGED
@@ -1,139 +1,8 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
1
3
|
RSpec.describe Item, type: :model do
|
2
4
|
|
3
5
|
it_behaves_like "a DDR model"
|
4
|
-
it_behaves_like "it has an association", :belongs_to, :parent, :is_member_of_collection, "Collection"
|
5
|
-
it_behaves_like "it has an association", :has_many, :children, :is_part_of, "Component"
|
6
6
|
it_behaves_like "a non-collection model"
|
7
|
-
it_behaves_like "a potentially publishable object"
|
8
|
-
it_behaves_like "an object that cannot be streamable"
|
9
|
-
|
10
|
-
describe "indexing text" do
|
11
|
-
let(:children) { FactoryGirl.build_list(:component, 5) }
|
12
|
-
|
13
|
-
let(:text1) { fixture_file_upload('extractedText1.txt', 'text/plain') }
|
14
|
-
let(:text2) { fixture_file_upload('extractedText2.txt', 'text/plain') }
|
15
|
-
let(:text3) { fixture_file_upload('extractedText3.txt', 'text/plain') }
|
16
|
-
|
17
|
-
before {
|
18
|
-
children[0].extractedText.content = text1
|
19
|
-
children[0].save!
|
20
|
-
children[1].extractedText.content = text2
|
21
|
-
children[1].save!
|
22
|
-
children[2].extractedText.content = text3
|
23
|
-
children[2].save!
|
24
|
-
children[3].save!
|
25
|
-
children[4].save!
|
26
|
-
subject.children = children
|
27
|
-
subject.save!
|
28
|
-
}
|
29
|
-
|
30
|
-
it "indexes the combined text of its children" do
|
31
|
-
expect(subject.index_fields[Ddr::Index::Fields::ALL_TEXT]).to contain_exactly(File.read(text1.path), File.read(text2.path), File.read(text3.path))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "content" do
|
36
|
-
its(:can_have_content?) { is_expected.to be false }
|
37
|
-
it { is_expected.to_not have_content }
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "children" do
|
41
|
-
its(:can_have_children?) { is_expected.to be true }
|
42
|
-
it { is_expected.to_not have_children }
|
43
|
-
specify {
|
44
|
-
subject.children << Component.new
|
45
|
-
expect(subject).to have_children
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#default_structure" do
|
50
|
-
describe "when the item has no components" do
|
51
|
-
let(:expected) do
|
52
|
-
xml = <<-EOS
|
53
|
-
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
54
|
-
<metsHdr>
|
55
|
-
<agent ROLE="#{Ddr::Models::Structures::Agent::ROLE_CREATOR}">
|
56
|
-
<name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
|
57
|
-
</agent>
|
58
|
-
</metsHdr>
|
59
|
-
<structMap TYPE="#{Ddr::Models::Structure::TYPE_DEFAULT}" />
|
60
|
-
</mets>
|
61
|
-
EOS
|
62
|
-
xml
|
63
|
-
end
|
64
|
-
it "should be the appropriate structure" do
|
65
|
-
expect(subject.default_structure.to_xml).to be_equivalent_to(expected)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
describe "when the item has components" do
|
69
|
-
let(:comp1) { Component.new }
|
70
|
-
let(:comp2) { Component.new }
|
71
|
-
let(:comp3) { Component.new }
|
72
|
-
let(:comp4) { Component.new }
|
73
|
-
let(:expected) do
|
74
|
-
xml = <<-EOS
|
75
|
-
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
|
76
|
-
<metsHdr>
|
77
|
-
<agent ROLE="#{Ddr::Models::Structures::Agent::ROLE_CREATOR}">
|
78
|
-
<name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
|
79
|
-
</agent>
|
80
|
-
</metsHdr>
|
81
|
-
<structMap TYPE="#{Ddr::Models::Structure::TYPE_DEFAULT}">
|
82
|
-
<div TYPE="Documents">
|
83
|
-
<div ORDER="1">
|
84
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4ccc" />
|
85
|
-
</div>
|
86
|
-
</div>
|
87
|
-
<div TYPE="Images">
|
88
|
-
<div ORDER="1">
|
89
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4bbb" />
|
90
|
-
</div>
|
91
|
-
<div ORDER="2">
|
92
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4aaa" />
|
93
|
-
</div>
|
94
|
-
</div>
|
95
|
-
<div TYPE="Other">
|
96
|
-
<div ORDER="1">
|
97
|
-
<mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4ddd" />
|
98
|
-
</div>
|
99
|
-
</div>
|
100
|
-
</structMap>
|
101
|
-
</mets>
|
102
|
-
EOS
|
103
|
-
xml
|
104
|
-
end
|
105
|
-
before do
|
106
|
-
comp1.local_id = "test001002"
|
107
|
-
comp1.permanent_id = "ark:/99999/fk4aaa"
|
108
|
-
comp1.upload fixture_file_upload("imageB.tif", "image/tiff")
|
109
|
-
comp1.save!
|
110
|
-
comp2.local_id = "test001001"
|
111
|
-
comp2.permanent_id = "ark:/99999/fk4bbb"
|
112
|
-
comp2.upload fixture_file_upload("imageA.tif", "image/tiff")
|
113
|
-
comp2.save!
|
114
|
-
comp3.local_id = "test001"
|
115
|
-
comp3.permanent_id = "ark:/99999/fk4ccc"
|
116
|
-
comp3.upload fixture_file_upload("sample.pdf", "application/pdf")
|
117
|
-
comp3.save!
|
118
|
-
comp4.local_id = "test123"
|
119
|
-
comp4.permanent_id = "ark:/99999/fk4ddd"
|
120
|
-
comp4.upload fixture_file_upload("abcd1234.vtt", "application/octet-stream")
|
121
|
-
comp4.save!
|
122
|
-
subject.children << comp1
|
123
|
-
subject.children << comp2
|
124
|
-
subject.children << comp3
|
125
|
-
subject.children << comp4
|
126
|
-
subject.save!
|
127
|
-
end
|
128
|
-
after do
|
129
|
-
comp1.destroy
|
130
|
-
comp2.destroy
|
131
|
-
comp3.destroy
|
132
|
-
end
|
133
|
-
it "should be the appropriate structure" do
|
134
|
-
expect(subject.default_structure.to_xml).to be_equivalent_to(expected)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
7
|
|
139
8
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Ddr::Models
|
2
|
+
RSpec.describe License do
|
3
|
+
|
4
|
+
describe ".call" do
|
5
|
+
subject { described_class.call(obj) }
|
6
|
+
|
7
|
+
describe "when the object has a license URL" do
|
8
|
+
let(:url) { "http://example.com" }
|
9
|
+
let(:obj) { double(pid: "test:1", license: url) }
|
10
|
+
before do
|
11
|
+
allow(described_class).to receive(:find).with(url: url) { described_class.new(url: url, title: "A License") }
|
12
|
+
end
|
13
|
+
its(:pid) { is_expected.to eq("test:1") }
|
14
|
+
its(:to_s) { is_expected.to eq("A License") }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "when the object does not have a license" do
|
18
|
+
let(:obj) { double(pid: "test:1", license: nil) }
|
19
|
+
it { is_expected.to be_nil }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -1,31 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe ".find" do
|
5
|
-
describe "when it exists" do
|
6
|
-
before { Item.create(pid: "test:1") }
|
7
|
-
subject { described_class.find("test:1") }
|
8
|
-
its(:id) { is_expected.to eq("test:1") }
|
9
|
-
end
|
10
|
-
describe "when not found" do
|
11
|
-
it "raises an error" do
|
12
|
-
expect { described_class.find("foo") }.to raise_error(SolrDocument::NotFound)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
describe ".find_by_permanent_id" do
|
17
|
-
describe "when it exists" do
|
18
|
-
before { Item.create(pid: "test:1", permanent_id: "foo") }
|
19
|
-
subject { described_class.find_by_permanent_id("foo") }
|
20
|
-
its(:id) { is_expected.to eq("test:1") }
|
21
|
-
end
|
22
|
-
describe "when not found" do
|
23
|
-
it "raises an error" do
|
24
|
-
expect { described_class.find_by_permanent_id("foo") }.to raise_error(SolrDocument::NotFound)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
3
|
+
RSpec.describe SolrDocument, type: :model, contacts: true do
|
29
4
|
|
30
5
|
describe "index field method access" do
|
31
6
|
describe "when there is an index field" do
|
@@ -68,7 +43,7 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
68
43
|
describe "where there is an admin policy relationship" do
|
69
44
|
let(:admin_policy) { FactoryGirl.create(:collection) }
|
70
45
|
before do
|
71
|
-
subject[Ddr::Index::Fields::IS_GOVERNED_BY] = [ admin_policy.
|
46
|
+
subject[Ddr::Index::Fields::IS_GOVERNED_BY] = [ admin_policy.id ]
|
72
47
|
end
|
73
48
|
it "should get the admin policy document" do
|
74
49
|
expect(subject.admin_policy.id).to eq(admin_policy.id)
|
@@ -116,28 +91,46 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
116
91
|
end
|
117
92
|
end
|
118
93
|
|
119
|
-
describe "#
|
120
|
-
context "no indexed
|
94
|
+
describe "#struct_maps" do
|
95
|
+
context "no indexed struct maps" do
|
96
|
+
it "should return an empty hash" do
|
97
|
+
expect(subject.struct_maps).to be_empty
|
98
|
+
end
|
99
|
+
end
|
100
|
+
context "indexed struct maps" do
|
101
|
+
before { subject[Ddr::Index::Fields::STRUCT_MAPS] = multiple_struct_maps_structure_to_json }
|
102
|
+
it "should return a hash of the struct maps" do
|
103
|
+
expect(subject.struct_maps).to eq(JSON.parse(multiple_struct_maps_structure_to_json))
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#struct_map" do
|
109
|
+
context "no indexed struct maps" do
|
121
110
|
it "should return nil" do
|
122
|
-
expect(subject.
|
111
|
+
expect(subject.struct_map('default')).to be_nil
|
123
112
|
end
|
124
113
|
end
|
125
|
-
context "indexed
|
126
|
-
before { subject[Ddr::Index::Fields::
|
127
|
-
|
128
|
-
|
114
|
+
context "indexed struct maps" do
|
115
|
+
before { subject[Ddr::Index::Fields::STRUCT_MAPS] = multiple_struct_maps_structure_to_json }
|
116
|
+
context "requested struct map is indexed" do
|
117
|
+
it "should return the struct map" do
|
118
|
+
expect(subject.struct_map('default')).to eq(JSON.parse(multiple_struct_maps_structure_to_json)["default"])
|
119
|
+
end
|
120
|
+
end
|
121
|
+
context "requested struct map is not indexed" do
|
122
|
+
it "should raise a KeyError" do
|
123
|
+
expect { subject.struct_map('foo') }.to raise_error(KeyError)
|
124
|
+
end
|
129
125
|
end
|
130
126
|
end
|
131
127
|
end
|
132
128
|
|
133
129
|
describe "contacts" do
|
134
130
|
before do
|
135
|
-
allow(
|
136
|
-
|
137
|
-
|
138
|
-
allow(Ddr::Models::Contact).to receive(:get).with(:find, slug: 'yb') do
|
139
|
-
{'id'=>1, 'slug'=>'yb', 'name'=>'Contact B', 'short_name'=>'B'}
|
140
|
-
end
|
131
|
+
allow(YAML).to receive(:load_file) { { 'xa' => { 'name' => 'Contact A', 'short_name' => 'A' },
|
132
|
+
'yb' => { 'name' => 'Contact B', 'short_name' => 'B' } } }
|
133
|
+
Ddr::Contacts.load_contacts
|
141
134
|
end
|
142
135
|
describe "#research_help" do
|
143
136
|
context "object has research help contact" do
|
@@ -171,214 +164,32 @@ RSpec.describe SolrDocument, type: :model, contacts: true do
|
|
171
164
|
its(:multires_image_file_paths) { is_expected.to match([]) }
|
172
165
|
end
|
173
166
|
context "structural metadata" do
|
174
|
-
|
167
|
+
let(:struct_map) do
|
168
|
+
{"type"=>"default", "divs"=>
|
169
|
+
[{"id"=>"viccb010010010", "label"=>"1", "order"=>"1", "type"=>"Image", "fptrs"=>["test:5"], "divs"=>[]},
|
170
|
+
{"id"=>"viccb010020010", "label"=>"2", "order"=>"2", "type"=>"Image", "fptrs"=>["test:6"], "divs"=>[]},
|
171
|
+
{"id"=>"viccb010030010", "label"=>"3", "order"=>"3", "type"=>"Image", "fptrs"=>["test:7"], "divs"=>[]}]
|
172
|
+
}
|
173
|
+
end
|
174
|
+
before { allow(subject).to receive(:struct_map) { struct_map } }
|
175
175
|
context "no structural objects with multi-res images" do
|
176
176
|
before do
|
177
|
+
allow(SolrDocument).to receive(:find).with('test:5') { double(multires_image_file_path: nil) }
|
178
|
+
allow(SolrDocument).to receive(:find).with('test:6') { double(multires_image_file_path: nil) }
|
177
179
|
allow(SolrDocument).to receive(:find).with('test:7') { double(multires_image_file_path: nil) }
|
178
|
-
allow(SolrDocument).to receive(:find).with('test:8') { double(multires_image_file_path: nil) }
|
179
|
-
allow(SolrDocument).to receive(:find).with('test:9') { double(multires_image_file_path: nil) }
|
180
180
|
end
|
181
181
|
its(:multires_image_file_paths) { is_expected.to match([]) }
|
182
182
|
end
|
183
183
|
context "structural objects with multi-res images" do
|
184
184
|
let(:expected_result) { [ "/path/file1.ptif", "/path/file2.ptif" ] }
|
185
185
|
before do
|
186
|
-
allow(SolrDocument).to receive(:find).with('test:
|
187
|
-
allow(SolrDocument).to receive(:find).with('test:
|
188
|
-
allow(SolrDocument).to receive(:find).with('test:
|
186
|
+
allow(SolrDocument).to receive(:find).with('test:5') { double(multires_image_file_path: "/path/file1.ptif") }
|
187
|
+
allow(SolrDocument).to receive(:find).with('test:6') { double(multires_image_file_path: nil) }
|
188
|
+
allow(SolrDocument).to receive(:find).with('test:7') { double(multires_image_file_path: "/path/file2.ptif") }
|
189
189
|
end
|
190
190
|
its(:multires_image_file_paths) { is_expected.to match(expected_result) }
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end
|
194
194
|
end
|
195
|
-
|
196
|
-
describe "datastreams" do
|
197
|
-
let(:profile) do <<-EOS
|
198
|
-
{"datastreams":{"DC":{"dsLabel":"Dublin Core Record for this object","dsVersionID":"DC1.0","dsCreateDate":"2016-02-09T12:38:56Z","dsState":"A","dsMIME":"text/xml","dsFormatURI":"http://www.openarchives.org/OAI/2.0/oai_dc/","dsControlGroup":"X","dsSize":340,"dsVersionable":true,"dsInfoType":null,"dsLocation":"duke:308221+DC+DC1.0","dsLocationType":null,"dsChecksumType":"SHA-1","dsChecksum":"69880409098d8dec1a5c41240a9daac2dd6832e0"}}}
|
199
|
-
EOS
|
200
|
-
end
|
201
|
-
before {
|
202
|
-
subject[Ddr::Index::Fields::OBJECT_PROFILE] = [ profile ]
|
203
|
-
}
|
204
|
-
specify {
|
205
|
-
expect(subject.has_datastream?("DC")).to be true
|
206
|
-
expect(subject.has_datastream?("foo")).to be false
|
207
|
-
}
|
208
|
-
end
|
209
|
-
|
210
|
-
describe "#intermediate_type" do
|
211
|
-
specify {
|
212
|
-
allow(subject).to receive(:has_intermediate_file?) { false }
|
213
|
-
expect(subject.intermediate_path).to be_nil
|
214
|
-
}
|
215
|
-
specify {
|
216
|
-
allow(subject).to receive(:datastreams) do
|
217
|
-
{"intermediateFile"=>{"dsMIME"=>"audio/wav"}}
|
218
|
-
end
|
219
|
-
expect(subject.intermediate_type).to eq "audio/wav"
|
220
|
-
}
|
221
|
-
end
|
222
|
-
|
223
|
-
describe "#intermediate_path" do
|
224
|
-
specify {
|
225
|
-
allow(subject).to receive(:has_intermediate_file?) { false }
|
226
|
-
expect(subject.intermediate_path).to be_nil
|
227
|
-
}
|
228
|
-
specify {
|
229
|
-
allow(subject).to receive(:datastreams) do
|
230
|
-
{"intermediateFile"=>{"dsLocation"=>"file:/foo/bar/baz.txt"}}
|
231
|
-
end
|
232
|
-
expect(subject.intermediate_path).to eq "/foo/bar/baz.txt"
|
233
|
-
}
|
234
|
-
end
|
235
|
-
|
236
|
-
describe "#intermediate_extension" do
|
237
|
-
let(:extensions) { {'audio/wav' => 'wav', 'video/quicktime' => 'mov'} }
|
238
|
-
before { allow(Ddr::Models).to receive(:preferred_file_extensions) { extensions } }
|
239
|
-
before { allow(subject).to receive(:has_intermediate_file?) { true } }
|
240
|
-
specify {
|
241
|
-
allow(subject).to receive(:has_intermediate_file?) { false }
|
242
|
-
expect(subject.intermediate_extension).to be_nil
|
243
|
-
}
|
244
|
-
specify {
|
245
|
-
allow(subject).to receive(:intermediate_type) { 'audio/wav'}
|
246
|
-
expect(subject.intermediate_extension).to eq "wav"
|
247
|
-
}
|
248
|
-
specify {
|
249
|
-
allow(subject).to receive(:intermediate_type) { 'video/quicktime'}
|
250
|
-
expect(subject.intermediate_extension).to eq "mov"
|
251
|
-
}
|
252
|
-
specify {
|
253
|
-
allow(subject).to receive(:intermediate_type) { 'application/foo'}
|
254
|
-
allow(subject).to receive(:intermediate_extension_default) { "bin" }
|
255
|
-
expect(subject.intermediate_extension).to eq "bin"
|
256
|
-
}
|
257
|
-
end
|
258
|
-
|
259
|
-
|
260
|
-
describe "#captionable?" do
|
261
|
-
specify {
|
262
|
-
allow(subject).to receive(:has_datastream?).with(Ddr::Datastreams::CAPTION) { false }
|
263
|
-
expect(subject).not_to be_captionable
|
264
|
-
}
|
265
|
-
specify {
|
266
|
-
allow(subject).to receive(:has_datastream?).with(Ddr::Datastreams::CAPTION) { true }
|
267
|
-
expect(subject).to be_captionable
|
268
|
-
}
|
269
|
-
end
|
270
|
-
|
271
|
-
describe "#caption_type" do
|
272
|
-
specify {
|
273
|
-
allow(subject).to receive(:captionable?) { false }
|
274
|
-
expect(subject.caption_type).to be_nil
|
275
|
-
}
|
276
|
-
specify {
|
277
|
-
allow(subject).to receive(:datastreams) do
|
278
|
-
{"caption"=>{"dsMIME"=>"text/vtt"}}
|
279
|
-
end
|
280
|
-
expect(subject.caption_type).to eq "text/vtt"
|
281
|
-
}
|
282
|
-
end
|
283
|
-
|
284
|
-
describe "#caption_path" do
|
285
|
-
specify {
|
286
|
-
allow(subject).to receive(:captionable?) { false }
|
287
|
-
expect(subject.caption_path).to be_nil
|
288
|
-
}
|
289
|
-
specify {
|
290
|
-
allow(subject).to receive(:datastreams) do
|
291
|
-
{"caption"=>{"dsLocation"=>"file:/foo/bar/baz.txt"}}
|
292
|
-
end
|
293
|
-
expect(subject.caption_path).to eq "/foo/bar/baz.txt"
|
294
|
-
}
|
295
|
-
end
|
296
|
-
|
297
|
-
describe "#caption_extension" do
|
298
|
-
let(:extensions) { {'text/vtt' => 'vtt', 'application/zip' => 'zip'} }
|
299
|
-
before { allow(Ddr::Models).to receive(:preferred_file_extensions) { extensions } }
|
300
|
-
before { allow(subject).to receive(:captionable?) { true } }
|
301
|
-
specify {
|
302
|
-
allow(subject).to receive(:captionable?) { false }
|
303
|
-
expect(subject.caption_extension).to be_nil
|
304
|
-
}
|
305
|
-
specify {
|
306
|
-
allow(subject).to receive(:caption_type) { 'text/vtt'}
|
307
|
-
expect(subject.caption_extension).to eq "vtt"
|
308
|
-
}
|
309
|
-
specify {
|
310
|
-
allow(subject).to receive(:caption_type) { 'application/zip'}
|
311
|
-
expect(subject.caption_extension).to eq "zip"
|
312
|
-
}
|
313
|
-
specify {
|
314
|
-
allow(subject).to receive(:caption_type) { 'application/foo'}
|
315
|
-
allow(subject).to receive(:caption_extension_default) { "bin" }
|
316
|
-
expect(subject.caption_extension).to eq "bin"
|
317
|
-
}
|
318
|
-
end
|
319
|
-
|
320
|
-
|
321
|
-
describe "#streamable?" do
|
322
|
-
specify {
|
323
|
-
allow(subject).to receive(:has_datastream?).with(Ddr::Datastreams::STREAMABLE_MEDIA) { false }
|
324
|
-
expect(subject).not_to be_streamable
|
325
|
-
}
|
326
|
-
specify {
|
327
|
-
allow(subject).to receive(:has_datastream?).with(Ddr::Datastreams::STREAMABLE_MEDIA) { true }
|
328
|
-
expect(subject).to be_streamable
|
329
|
-
}
|
330
|
-
end
|
331
|
-
|
332
|
-
describe "#streamable_media_path" do
|
333
|
-
specify {
|
334
|
-
allow(subject).to receive(:streamable?) { false }
|
335
|
-
expect(subject.streamable_media_path).to be_nil
|
336
|
-
}
|
337
|
-
specify {
|
338
|
-
allow(subject).to receive(:datastreams) do
|
339
|
-
{"streamableMedia"=>{"dsLocation"=>"file:/foo/bar/baz.txt"}}
|
340
|
-
end
|
341
|
-
expect(subject.streamable_media_path).to eq "/foo/bar/baz.txt"
|
342
|
-
}
|
343
|
-
end
|
344
|
-
|
345
|
-
describe "#streamable_media_extension" do
|
346
|
-
let(:extensions) { {'audio/mpeg' => 'mp3', 'video/mp4' => 'mp4'} }
|
347
|
-
before { allow(Ddr::Models).to receive(:preferred_file_extensions) { extensions } }
|
348
|
-
before { allow(subject).to receive(:streamable?) { true } }
|
349
|
-
specify {
|
350
|
-
allow(subject).to receive(:streamable?) { false }
|
351
|
-
expect(subject.streamable_media_extension).to be_nil
|
352
|
-
}
|
353
|
-
specify {
|
354
|
-
allow(subject).to receive(:streamable_media_type) { 'audio/mpeg'}
|
355
|
-
expect(subject.streamable_media_extension).to eq "mp3"
|
356
|
-
}
|
357
|
-
specify {
|
358
|
-
allow(subject).to receive(:streamable_media_type) { 'application/foo'}
|
359
|
-
allow(subject).to receive(:streamable_media_extension_default) { "bin" }
|
360
|
-
expect(subject.streamable_media_extension).to eq "bin"
|
361
|
-
}
|
362
|
-
end
|
363
|
-
|
364
|
-
|
365
|
-
describe "#rights" do
|
366
|
-
specify {
|
367
|
-
obj = Item.create(rights: ["http://example.com"])
|
368
|
-
doc = described_class.find(obj.id)
|
369
|
-
expect(doc.rights).to eq ["http://example.com"]
|
370
|
-
}
|
371
|
-
end
|
372
|
-
|
373
|
-
describe "#rights_statement" do
|
374
|
-
let(:rights_statement) { Ddr::Models::RightsStatement.new(url: "http://example.com") }
|
375
|
-
before do
|
376
|
-
allow(Ddr::Models::RightsStatement).to receive(:get).with(:find, url: "http://example.com") do
|
377
|
-
{ url: "http://example.com" }
|
378
|
-
end
|
379
|
-
allow(subject).to receive(:rights) { ["http://example.com"] }
|
380
|
-
end
|
381
|
-
its(:rights_statement) { is_expected.to eq rights_statement }
|
382
|
-
end
|
383
|
-
|
384
195
|
end
|