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,140 +0,0 @@
|
|
1
|
-
module Ddr::Index
|
2
|
-
RSpec.describe QueryBuilder do
|
3
|
-
describe "DSL" do
|
4
|
-
describe "id" do
|
5
|
-
subject { described_class.new { id "test:1" } }
|
6
|
-
specify {
|
7
|
-
expect(subject.query.rows).to eq 1
|
8
|
-
expect(subject.query.q).to eq QueryClause.id("test:1")
|
9
|
-
}
|
10
|
-
end
|
11
|
-
describe "q" do
|
12
|
-
subject { described_class.new { q "foo:bar" } }
|
13
|
-
specify { expect(subject.query.q).to eq "foo:bar" }
|
14
|
-
end
|
15
|
-
describe "asc" do
|
16
|
-
subject { described_class.new { asc "foo", "bar" } }
|
17
|
-
specify {
|
18
|
-
expect(subject.query.sort).to eq [SortOrder.asc("foo"), SortOrder.asc("bar")]
|
19
|
-
}
|
20
|
-
end
|
21
|
-
describe "desc" do
|
22
|
-
subject { described_class.new { desc "foo", "bar" } }
|
23
|
-
specify {
|
24
|
-
expect(subject.query.sort).to eq [SortOrder.desc("foo"), SortOrder.desc("bar")]
|
25
|
-
}
|
26
|
-
end
|
27
|
-
describe "filter" do
|
28
|
-
subject { described_class.new { filter Filter.where("foo"=>"bar") } }
|
29
|
-
specify { expect(subject.query.filters).to eq [Filter.where("foo"=>"bar")] }
|
30
|
-
end
|
31
|
-
describe "filters" do
|
32
|
-
subject {
|
33
|
-
described_class.new { filters Filter.where("foo"=>"bar"), Filter.where("bing"=>"bang") }
|
34
|
-
}
|
35
|
-
specify {
|
36
|
-
expect(subject.query.filters).to eq([Filter.where("foo"=>"bar"),
|
37
|
-
Filter.where("bing"=>"bang")
|
38
|
-
])
|
39
|
-
}
|
40
|
-
end
|
41
|
-
describe "field" do
|
42
|
-
subject { described_class.new { field "foo", "bar" } }
|
43
|
-
specify { expect(subject.query.fields).to include("foo", "bar") }
|
44
|
-
end
|
45
|
-
describe "fields" do
|
46
|
-
subject { described_class.new { fields "foo", "bar" } }
|
47
|
-
specify { expect(subject.query.fields).to include("foo", "bar") }
|
48
|
-
end
|
49
|
-
describe "sort" do
|
50
|
-
subject { described_class.new { sort "foo"=>"asc", "bar"=>"desc" } }
|
51
|
-
specify {
|
52
|
-
expect(subject.query.sort).to eq([SortOrder.new(field: "foo", order: "asc"),
|
53
|
-
SortOrder.new(field: "bar", order: "desc")
|
54
|
-
])
|
55
|
-
}
|
56
|
-
end
|
57
|
-
describe "order_by" do
|
58
|
-
subject { described_class.new { order_by "foo"=>"asc", "bar"=>"desc" } }
|
59
|
-
specify { expect(subject.query.sort).to eq [SortOrder.new(field: "foo", order: "asc"), SortOrder.new(field: "bar", order: "desc")] }
|
60
|
-
end
|
61
|
-
describe "limit" do
|
62
|
-
subject { described_class.new { limit 5 } }
|
63
|
-
specify { expect(subject.query.rows).to eq 5 }
|
64
|
-
end
|
65
|
-
describe "rows" do
|
66
|
-
subject { described_class.new { rows 5 } }
|
67
|
-
specify { expect(subject.query.rows).to eq 5 }
|
68
|
-
end
|
69
|
-
describe "raw" do
|
70
|
-
subject { described_class.new { raw "foo:bar" } }
|
71
|
-
specify { expect(subject.query.filters).to eq [Filter.raw("foo:bar")] }
|
72
|
-
end
|
73
|
-
describe "where" do
|
74
|
-
subject { described_class.new { where "foo"=>"bar" } }
|
75
|
-
specify { expect(subject.query.filters).to eq [Filter.where("foo"=>"bar")] }
|
76
|
-
end
|
77
|
-
describe "absent" do
|
78
|
-
subject { described_class.new { absent "foo" } }
|
79
|
-
specify { expect(subject.query.filters).to eq [Filter.absent("foo")] }
|
80
|
-
end
|
81
|
-
describe "present" do
|
82
|
-
subject { described_class.new { present "foo" } }
|
83
|
-
specify { expect(subject.query.filters).to eq [Filter.present("foo")] }
|
84
|
-
end
|
85
|
-
describe "before" do
|
86
|
-
subject {
|
87
|
-
described_class.new { before "foo", DateTime.parse("2015-12-14T20:40:06Z") }
|
88
|
-
}
|
89
|
-
specify {
|
90
|
-
expect(subject.query.filters).to eq [Filter.before("foo", DateTime.parse("2015-12-14T20:40:06Z"))]
|
91
|
-
}
|
92
|
-
end
|
93
|
-
describe "before_days" do
|
94
|
-
subject { described_class.new { before_days "foo", 7 } }
|
95
|
-
specify { expect(subject.query.filters).to eq [Filter.before_days("foo", 7)] }
|
96
|
-
end
|
97
|
-
describe "join" do
|
98
|
-
subject {
|
99
|
-
described_class.new do
|
100
|
-
join from: :id, to: :collection_uri, where: {admin_set: "dvs"}
|
101
|
-
end
|
102
|
-
}
|
103
|
-
specify {
|
104
|
-
expect(subject.query.filters).to eq [Filter.join(from: :id, to: :collection_uri, where: {admin_set: "dvs"})]
|
105
|
-
}
|
106
|
-
end
|
107
|
-
describe "regexp" do
|
108
|
-
subject { described_class.new { regexp "foo", "foo/bar.*" } }
|
109
|
-
specify {
|
110
|
-
expect(subject.query.filters).to eq [Filter.regexp("foo", "foo/bar.*")]
|
111
|
-
}
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "using static filters" do
|
116
|
-
describe "has_content" do
|
117
|
-
before { subject.has_content }
|
118
|
-
specify { expect(subject.query.filters).to eq [Filter.has_content] }
|
119
|
-
end
|
120
|
-
describe "is_governed_by" do
|
121
|
-
before { subject.is_governed_by "test:1" }
|
122
|
-
specify { expect(subject.query.filters).to eq [Filter.is_governed_by("test:1")] }
|
123
|
-
end
|
124
|
-
describe "is_governed_by" do
|
125
|
-
before { subject.is_member_of_collection "test:1" }
|
126
|
-
specify { expect(subject.query.filters).to eq [Filter.is_member_of_collection("test:1")] }
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe "passing local vars" do
|
131
|
-
let(:local_var) { double(bar: "bar") }
|
132
|
-
subject {
|
133
|
-
described_class.new(local_var) { |foo| asc foo.bar }
|
134
|
-
}
|
135
|
-
specify {
|
136
|
-
expect(subject.query.sort).to eq [SortOrder.asc("bar")]
|
137
|
-
}
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
module Ddr::Index
|
2
|
-
RSpec.describe QueryClause do
|
3
|
-
|
4
|
-
describe "class methods" do
|
5
|
-
describe ".unique_key" do
|
6
|
-
subject { described_class.unique_key("test:1") }
|
7
|
-
its(:to_s) { is_expected.to eq "{!term f=id}test:1" }
|
8
|
-
end
|
9
|
-
describe ".id" do
|
10
|
-
subject { described_class.id("test:1") }
|
11
|
-
its(:to_s) { is_expected.to eq "{!term f=id}test:1" }
|
12
|
-
end
|
13
|
-
describe ".negative" do
|
14
|
-
subject { described_class.negative("foo", "Jungle Fever") }
|
15
|
-
its(:to_s) { is_expected.to eq "-foo:\"Jungle Fever\"" }
|
16
|
-
end
|
17
|
-
describe ".present" do
|
18
|
-
subject { described_class.present("foo") }
|
19
|
-
its(:to_s) { is_expected.to eq "foo:[* TO *]" }
|
20
|
-
end
|
21
|
-
describe ".absent" do
|
22
|
-
subject { described_class.absent("foo") }
|
23
|
-
its(:to_s) { is_expected.to eq "-foo:[* TO *]" }
|
24
|
-
end
|
25
|
-
describe ".disjunction" do
|
26
|
-
subject { described_class.disjunction("foo", ["Jungle Fever", "bar"]) }
|
27
|
-
its(:to_s) { is_expected.to eq "{!lucene q.op=OR df=foo}\"Jungle Fever\" bar" }
|
28
|
-
end
|
29
|
-
describe ".before" do
|
30
|
-
subject { described_class.before("foo", DateTime.parse("2015-12-14T20:40:06Z")) }
|
31
|
-
its(:to_s) { is_expected.to eq "foo:[* TO 2015-12-14T20:40:06Z]" }
|
32
|
-
end
|
33
|
-
describe ".before_days" do
|
34
|
-
subject { described_class.before_days("foo", 5) }
|
35
|
-
its(:to_s) { is_expected.to eq "foo:[* TO NOW-5DAYS]" }
|
36
|
-
end
|
37
|
-
describe ".term" do
|
38
|
-
subject { described_class.term("foo", "bar") }
|
39
|
-
its(:to_s) { is_expected.to eq "{!term f=foo}bar" }
|
40
|
-
end
|
41
|
-
describe ".where" do
|
42
|
-
describe "when the value is a string" do
|
43
|
-
subject { described_class.where("foo", "Jungle Fever") }
|
44
|
-
its(:to_s) { is_expected.to eq "foo:\"Jungle Fever\"" }
|
45
|
-
end
|
46
|
-
describe "when the value is an Array with one entry" do
|
47
|
-
subject { described_class.where("foo", ["Jungle Fever"]) }
|
48
|
-
its(:to_s) { is_expected.to eq "foo:\"Jungle Fever\"" }
|
49
|
-
end
|
50
|
-
describe "when the value is an array with multiple entries" do
|
51
|
-
subject { described_class.where("foo", ["Jungle Fever", "bar"]) }
|
52
|
-
its(:to_s) { is_expected.to eq "{!lucene q.op=OR df=foo}\"Jungle Fever\" bar" }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
describe ".join" do
|
56
|
-
subject {
|
57
|
-
described_class.join(from: :id, to: :collection_uri, where: { admin_set: "dvs"})
|
58
|
-
}
|
59
|
-
its(:to_s) { is_expected.to eq "{!join from=id to=collection_uri_ssim}admin_set_ssi:dvs" }
|
60
|
-
end
|
61
|
-
describe ".regexp" do
|
62
|
-
subject { described_class.regexp("foo", "foo/bar.*") }
|
63
|
-
its(:to_s) { is_expected.to eq "foo:/foo\\/bar.*/" }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
data/spec/models/cache_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module Ddr::Models
|
2
|
-
RSpec.describe Cache do
|
3
|
-
|
4
|
-
describe "#get" do
|
5
|
-
it "retrieves a value by key" do
|
6
|
-
expect(subject.get(:foo)).to be_nil
|
7
|
-
subject[:foo] = "bar"
|
8
|
-
expect(subject.get(:foo)).to eq "bar"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#put" do
|
13
|
-
it "inserts a key/value" do
|
14
|
-
expect { subject.put(:foo, "bar") }.to change { subject[:foo] }.from(nil).to("bar")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#with" do
|
19
|
-
it "returns the value of the block" do
|
20
|
-
result = subject.with(foo: "bar") { 1 }
|
21
|
-
expect(result).to eq 1
|
22
|
-
end
|
23
|
-
it "temporarily caches the arguments" do
|
24
|
-
subject.with(foo: "bar") do
|
25
|
-
expect(subject.get(:foo)).to eq "bar"
|
26
|
-
end
|
27
|
-
expect(subject.get(:foo)).to be_nil
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
data/spec/models/contact_spec.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
module Ddr::Models
|
2
|
-
RSpec.describe Contact, ddr_aux: true do
|
3
|
-
|
4
|
-
describe ".call" do
|
5
|
-
describe "when the slug is found" do
|
6
|
-
before {
|
7
|
-
allow(described_class).to receive(:get).with(:find, slug: "abc") {
|
8
|
-
{"id"=>1, "slug"=>"abc", "name"=>"A, B, and C Services", "short_name"=>"ABCS",
|
9
|
-
"url"=>"http://library.inst.edu/abc", "phone"=>"555-1234", "email"=>"abc@library.inst.edu",
|
10
|
-
"ask"=>"http://library.inst.edu/abc-ask", "created_at"=>"2015-09-15T16:15:58.514Z",
|
11
|
-
"updated_at"=>"2015-09-15T16:15:58.514Z"}
|
12
|
-
}
|
13
|
-
}
|
14
|
-
it "returns a Contact instance" do
|
15
|
-
expect(described_class.call("abc")).to be_a(described_class)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
describe "when the slug is not found" do
|
19
|
-
before {
|
20
|
-
allow(described_class).to receive(:get).with(:find, slug: "abc")
|
21
|
-
.and_raise(ActiveResource::ResourceNotFound, "404")
|
22
|
-
}
|
23
|
-
it "raises an exception" do
|
24
|
-
expect { described_class.call("abc") }.to raise_error(Ddr::Models::NotFoundError)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe ".keys" do
|
30
|
-
let(:entries) { [ described_class.new(id: 1, slug: 'abc', name: 'contact ABC'),
|
31
|
-
described_class.new(id: 2, slug: 'def', name: 'contact DEF') ] }
|
32
|
-
let(:response_collection) { ActiveResource::Collection.new }
|
33
|
-
before do
|
34
|
-
response_collection.elements = entries
|
35
|
-
allow(described_class).to receive(:all) { response_collection }
|
36
|
-
end
|
37
|
-
it "returns the defined slugs" do
|
38
|
-
expect(described_class.keys).to match_array([ entries[0].slug, entries[1].slug ])
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
describe "instance methods" do
|
44
|
-
subject {
|
45
|
-
described_class.new(
|
46
|
-
"id"=>1, "slug"=>"abc", "name"=>"A, B, and C Services", "short_name"=>"ABCS",
|
47
|
-
"url"=>"http://library.inst.edu/abc", "phone"=>"555-1234", "email"=>"abc@library.inst.edu",
|
48
|
-
"ask"=>"http://library.inst.edu/abc-ask", "created_at"=>"2015-09-15T16:15:58.514Z",
|
49
|
-
"updated_at"=>"2015-09-15T16:15:58.514Z"
|
50
|
-
)
|
51
|
-
}
|
52
|
-
its(:to_s) { is_expected.to eq("A, B, and C Services") }
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
@@ -1,139 +0,0 @@
|
|
1
|
-
require 'rdf/isomorphic'
|
2
|
-
include RDF::Isomorphic
|
3
|
-
|
4
|
-
def sample_metadata_triples(subject_string="_:test")
|
5
|
-
triples = <<-EOS
|
6
|
-
#{subject_string} <http://purl.org/dc/terms/title> "Sample title" .
|
7
|
-
#{subject_string} <http://purl.org/dc/terms/creator> "Sample, Example" .
|
8
|
-
#{subject_string} <http://purl.org/dc/terms/type> "Image" .
|
9
|
-
#{subject_string} <http://purl.org/dc/terms/type> "Still Image" .
|
10
|
-
#{subject_string} <http://purl.org/dc/terms/spatial> "Durham County (NC)" .
|
11
|
-
#{subject_string} <http://purl.org/dc/terms/spatial> "Durham (NC)" .
|
12
|
-
#{subject_string} <http://purl.org/dc/terms/date> "1981-01" .
|
13
|
-
#{subject_string} <http://purl.org/dc/terms/rights> "The copyright for these materials is unknown." .
|
14
|
-
#{subject_string} <http://library.duke.edu/metadata/terms/print_number> "12-345-6" .
|
15
|
-
#{subject_string} <http://library.duke.edu/metadata/terms/series> "Photographic Materials Series" .
|
16
|
-
#{subject_string} <http://library.duke.edu/metadata/terms/subseries> "Local Court House" .
|
17
|
-
EOS
|
18
|
-
end
|
19
|
-
|
20
|
-
module Ddr::Datastreams
|
21
|
-
RSpec.describe DescriptiveMetadataDatastream do
|
22
|
-
describe "terminology" do
|
23
|
-
it "should have a term for each term name in the RDF::DC vocab except :license" do
|
24
|
-
expect(described_class.term_names).to include(*Ddr::Vocab::Vocabulary.term_names(RDF::DC)-[:license])
|
25
|
-
end
|
26
|
-
it "should have a term for each term name in the DukeTerms vocab" do
|
27
|
-
expect(described_class.term_names).to include(*Ddr::Vocab::Vocabulary.term_names(Ddr::Vocab::DukeTerms))
|
28
|
-
end
|
29
|
-
end
|
30
|
-
describe "properties" do
|
31
|
-
subject { described_class.properties.map { |prop| prop[1].predicate } }
|
32
|
-
it "should include all the RDF::DC predicates except http://purl.org/dc/terms/license" do
|
33
|
-
expected_predicates = Ddr::Vocab::Vocabulary.property_terms(RDF::DC).select { |p| p.to_s != 'http://purl.org/dc/terms/license' }
|
34
|
-
expect(subject).to include(*expected_predicates)
|
35
|
-
end
|
36
|
-
it "should include all the DukeTerms predicates" do
|
37
|
-
expect(subject).to include(*Ddr::Vocab::Vocabulary.property_terms(Ddr::Vocab::DukeTerms))
|
38
|
-
end
|
39
|
-
end
|
40
|
-
describe "raw content" do
|
41
|
-
let(:obj) { Item.new }
|
42
|
-
subject { obj.descMetadata }
|
43
|
-
before do
|
44
|
-
content = sample_metadata_triples(subject.rdf_subject.to_s)
|
45
|
-
subject.content = content
|
46
|
-
subject.resource.set_subject!(subject.rdf_subject)
|
47
|
-
end
|
48
|
-
it "should retrieve the content using the terminology" do
|
49
|
-
expect(subject.title).to eq(["Sample title"])
|
50
|
-
expect(subject.creator).to eq(["Sample, Example"])
|
51
|
-
expect(subject.type).to eq(["Image", "Still Image"])
|
52
|
-
expect(subject.spatial).to eq(["Durham County (NC)", "Durham (NC)"])
|
53
|
-
expect(subject.date).to eq(["1981-01"])
|
54
|
-
expect(subject.rights).to eq(["The copyright for these materials is unknown."])
|
55
|
-
expect(subject.print_number).to eq(["12-345-6"])
|
56
|
-
expect(subject.series).to eq(["Photographic Materials Series"])
|
57
|
-
expect(subject.subseries).to eq(["Local Court House"])
|
58
|
-
end
|
59
|
-
end
|
60
|
-
describe "using the terminology setters" do
|
61
|
-
let(:obj) { Item.new }
|
62
|
-
subject { obj.descMetadata }
|
63
|
-
let(:content) { sample_metadata_triples(subject.rdf_subject.to_s) }
|
64
|
-
before do
|
65
|
-
subject.title = "Sample title"
|
66
|
-
subject.creator = "Sample, Example"
|
67
|
-
subject.type = ["Image", "Still Image"]
|
68
|
-
subject.spatial = ["Durham County (NC)", "Durham (NC)"]
|
69
|
-
subject.date = "1981-01"
|
70
|
-
subject.rights = "The copyright for these materials is unknown."
|
71
|
-
subject.print_number = "12-345-6"
|
72
|
-
subject.series = "Photographic Materials Series"
|
73
|
-
subject.subseries = "Local Court House"
|
74
|
-
end
|
75
|
-
its(:resource) { is_expected.to be_isomorphic_with(RDF::Reader.for(:ntriples).new(content)) }
|
76
|
-
end
|
77
|
-
describe "using the set_values and add_value methods" do
|
78
|
-
let(:obj) { Item.new }
|
79
|
-
subject { obj.descMetadata }
|
80
|
-
before { subject.type = "Photograph" }
|
81
|
-
describe "#set_values" do
|
82
|
-
it "sets the values of the term to those supplied" do
|
83
|
-
subject.set_values :type, [ "Image", "Still Image" ]
|
84
|
-
expect(subject.type).to eq([ "Image", "Still Image" ])
|
85
|
-
end
|
86
|
-
it "does not add blank values" do
|
87
|
-
subject.set_values :type, [ "Image", "", nil, "\t" ]
|
88
|
-
expect(subject.type).to eq([ "Image" ])
|
89
|
-
end
|
90
|
-
it "strips whitespace from values" do
|
91
|
-
subject.set_values :type, [ "Image", "Still Image " ]
|
92
|
-
expect(subject.type).to eq([ "Image", "Still Image" ])
|
93
|
-
end
|
94
|
-
it "strips control characters from values" do
|
95
|
-
subject.set_values :type, [ "Image", "Still\f Image" ]
|
96
|
-
expect(subject.type).to eq([ "Image", "Still Image" ])
|
97
|
-
end
|
98
|
-
it "does not strip CR and LF characters from values" do
|
99
|
-
subject.set_values :type, [ "Image", "Still\nImage" ]
|
100
|
-
expect(subject.type).to eq([ "Image", "Still\nImage" ])
|
101
|
-
end
|
102
|
-
end
|
103
|
-
describe "#add_value" do
|
104
|
-
it "should add the supplied value to those of the term" do
|
105
|
-
subject.add_value :type, "Image"
|
106
|
-
expect(subject.type).to eq([ "Photograph", "Image" ])
|
107
|
-
end
|
108
|
-
it "strips whitespace from the value" do
|
109
|
-
subject.add_value :type, "Image "
|
110
|
-
expect(subject.type).to eq([ "Photograph", "Image" ])
|
111
|
-
end
|
112
|
-
it "does not add blank values" do
|
113
|
-
subject.add_value :type, nil
|
114
|
-
subject.add_value :type, ""
|
115
|
-
subject.add_value :type, "\t"
|
116
|
-
expect(subject.type).to eq(["Photograph"])
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
describe "solrization" do
|
121
|
-
let(:obj) { Item.new }
|
122
|
-
subject { obj.descMetadata }
|
123
|
-
before do
|
124
|
-
content = sample_metadata_triples(subject.rdf_subject.to_s)
|
125
|
-
subject.content = content
|
126
|
-
subject.resource.set_subject!(subject.rdf_subject)
|
127
|
-
end
|
128
|
-
its(:to_solr) { is_expected.to include("title_tesim" => ["Sample title"]) }
|
129
|
-
its(:to_solr) { is_expected.to include("creator_tesim" => ["Sample, Example"]) }
|
130
|
-
its(:to_solr) { is_expected.to include("type_tesim" => ["Image", "Still Image"]) }
|
131
|
-
its(:to_solr) { is_expected.to include("spatial_tesim" => ["Durham County (NC)", "Durham (NC)"]) }
|
132
|
-
its(:to_solr) { is_expected.to include("date_tesim" => ["1981-01"]) }
|
133
|
-
its(:to_solr) { is_expected.to include("rights_tesim" => ["The copyright for these materials is unknown."]) }
|
134
|
-
its(:to_solr) { is_expected.to include("print_number_tesim" => ["12-345-6"]) }
|
135
|
-
its(:to_solr) { is_expected.to include("series_tesim" => ["Photographic Materials Series"]) }
|
136
|
-
its(:to_solr) { is_expected.to include("subseries_tesim" => ["Local Court House"]) }
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Ddr::Models
|
2
|
-
RSpec.describe FileCharacterization do
|
3
|
-
|
4
|
-
subject { described_class.new(obj) }
|
5
|
-
|
6
|
-
before {
|
7
|
-
obj.content.checksumType = "SHA-1"
|
8
|
-
obj.save!
|
9
|
-
}
|
10
|
-
|
11
|
-
let(:obj) { FactoryGirl.create(:component) }
|
12
|
-
let(:fits_output) { "<fits/>" }
|
13
|
-
|
14
|
-
describe "when there is an error running FITS" do
|
15
|
-
before {
|
16
|
-
allow(subject).to receive(:run_fits).and_raise(FileCharacterization::FITSError)
|
17
|
-
}
|
18
|
-
specify {
|
19
|
-
begin
|
20
|
-
subject.call
|
21
|
-
rescue FileCharacterization::FITSError
|
22
|
-
ensure
|
23
|
-
expect(subject.fits).not_to have_content
|
24
|
-
end
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "when FITS runs successfully" do
|
29
|
-
before {
|
30
|
-
allow(subject).to receive(:run_fits) { fits_output }
|
31
|
-
}
|
32
|
-
specify {
|
33
|
-
subject.call
|
34
|
-
expect(subject.fits.content).to eq(fits_output)
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|