active-fedora 8.7.0 → 9.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -15
- data/Gemfile +5 -5
- data/History.txt +0 -80
- data/README.md +1 -0
- data/Rakefile +0 -3
- data/active-fedora.gemspec +8 -7
- data/config/fedora.yml +5 -4
- data/config/predicate_mappings.yml +5 -5
- data/gemfiles/rails4.1.gemfile +10 -0
- data/gemfiles/rails4.2.beta.gemfile +10 -0
- data/lib/active_fedora.rb +151 -117
- data/lib/active_fedora/associations.rb +47 -15
- data/lib/active_fedora/associations/association.rb +29 -8
- data/lib/active_fedora/associations/association_scope.rb +5 -5
- data/lib/active_fedora/associations/belongs_to_association.rb +20 -63
- data/lib/active_fedora/associations/builder/association.rb +61 -25
- data/lib/active_fedora/associations/builder/belongs_to.rb +7 -94
- data/lib/active_fedora/associations/builder/collection_association.rb +11 -43
- data/lib/active_fedora/associations/builder/contains.rb +28 -0
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +13 -3
- data/lib/active_fedora/associations/builder/has_many.rb +16 -10
- data/lib/active_fedora/associations/builder/property.rb +14 -0
- data/lib/active_fedora/associations/builder/singular_association.rb +14 -18
- data/lib/active_fedora/associations/builder/singular_property.rb +12 -0
- data/lib/active_fedora/associations/collection_association.rb +57 -80
- data/lib/active_fedora/associations/contains_association.rb +50 -0
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +44 -24
- data/lib/active_fedora/associations/has_many_association.rb +46 -14
- data/lib/active_fedora/associations/rdf.rb +86 -0
- data/lib/active_fedora/associations/singular_association.rb +4 -8
- data/lib/active_fedora/associations/singular_rdf.rb +15 -0
- data/lib/active_fedora/attached_files.rb +195 -0
- data/lib/active_fedora/attribute_methods.rb +122 -0
- data/lib/active_fedora/attribute_methods/dirty.rb +16 -0
- data/lib/active_fedora/attribute_methods/read.rb +61 -0
- data/lib/active_fedora/attribute_methods/write.rb +47 -0
- data/lib/active_fedora/attributes.rb +93 -44
- data/lib/active_fedora/attributes/primary_key.rb +12 -0
- data/lib/active_fedora/autosave_association.rb +2 -2
- data/lib/active_fedora/base.rb +16 -15
- data/lib/active_fedora/callbacks.rb +7 -7
- data/lib/active_fedora/change_set.rb +34 -0
- data/lib/active_fedora/cleaner.rb +62 -0
- data/lib/active_fedora/config.rb +4 -22
- data/lib/active_fedora/core.rb +173 -99
- data/lib/active_fedora/datastream.rb +4 -117
- data/lib/active_fedora/datastreams.rb +2 -263
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +28 -51
- data/lib/active_fedora/{datastream_attribute.rb → delegated_attribute.rb} +57 -26
- data/lib/active_fedora/errors.rb +61 -0
- data/lib/active_fedora/fedora.rb +19 -0
- data/lib/active_fedora/fedora_attributes.rb +58 -26
- data/lib/active_fedora/file.rb +318 -0
- data/lib/active_fedora/file_configurator.rb +32 -32
- data/lib/active_fedora/file_path_builder.rb +24 -0
- data/lib/active_fedora/files_hash.rb +82 -0
- data/lib/active_fedora/fixity_service.rb +40 -0
- data/lib/active_fedora/indexing.rb +55 -82
- data/lib/active_fedora/indexing_service.rb +70 -0
- data/lib/active_fedora/ldp_resource.rb +26 -0
- data/lib/active_fedora/loadable_from_json.rb +112 -0
- data/lib/active_fedora/model.rb +5 -19
- data/lib/active_fedora/nested_attributes.rb +5 -6
- data/lib/active_fedora/nom_datastream.rb +15 -25
- data/lib/active_fedora/om_datastream.rb +26 -197
- data/lib/active_fedora/persistence.rb +95 -71
- data/lib/active_fedora/predicates.rb +4 -4
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +17 -18
- data/lib/active_fedora/querying.rb +3 -4
- data/lib/active_fedora/railtie.rb +3 -6
- data/lib/active_fedora/rdf.rb +3 -1
- data/lib/active_fedora/rdf/datastream_indexing.rb +11 -0
- data/lib/active_fedora/rdf/fcrepo.rb +10 -324
- data/lib/active_fedora/rdf/indexing.rb +20 -16
- data/lib/active_fedora/rdf/ldp.rb +6 -0
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +1 -1
- data/lib/active_fedora/rdf/persistence.rb +5 -6
- data/lib/active_fedora/rdf/rdf_datastream.rb +44 -37
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +13 -0
- data/lib/active_fedora/rdf/rels_ext.rb +26 -0
- data/lib/active_fedora/reflection.rb +256 -199
- data/lib/active_fedora/relation.rb +18 -6
- data/lib/active_fedora/relation/finder_methods.rb +69 -38
- data/lib/active_fedora/relation/query_methods.rb +7 -3
- data/lib/active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher.rb +7 -7
- data/lib/active_fedora/rspec_matchers/have_many_associated_active_fedora_objects_matcher.rb +8 -8
- data/lib/active_fedora/rspec_matchers/have_predicate_matcher.rb +9 -11
- data/lib/active_fedora/simple_datastream.rb +18 -13
- data/lib/active_fedora/solr_instance_loader.rb +18 -38
- data/lib/active_fedora/solr_service.rb +37 -20
- data/lib/active_fedora/sparql_insert.rb +45 -0
- data/lib/active_fedora/test_support.rb +1 -22
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versionable.rb +90 -0
- data/lib/active_fedora/with_metadata.rb +37 -0
- data/lib/active_fedora/with_metadata/metadata_node.rb +70 -0
- data/lib/generators/active_fedora/config/config_generator.rb +0 -1
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -1
- data/lib/generators/active_fedora/model/model_generator.rb +5 -5
- data/lib/generators/active_fedora/model/templates/datastream_spec.rb.erb +1 -1
- data/lib/generators/active_fedora/model/templates/model_spec.rb.erb +2 -2
- data/lib/tasks/active_fedora_dev.rake +21 -27
- data/spec/config_helper.rb +1 -1
- data/spec/fixtures/mixed_rdf_descMetadata.nt +6 -6
- data/spec/fixtures/rails_root/config/predicate_mappings.yml +3 -19
- data/spec/fixtures/solr_rdf_descMetadata.nt +6 -6
- data/spec/integration/associations_spec.rb +133 -153
- data/spec/integration/attached_files_spec.rb +164 -0
- data/spec/integration/attributes_spec.rb +73 -12
- data/spec/integration/autosave_association_spec.rb +3 -3
- data/spec/integration/base_spec.rb +57 -351
- data/spec/integration/belongs_to_association_spec.rb +86 -76
- data/spec/integration/bug_spec.rb +3 -3
- data/spec/integration/collection_association_spec.rb +4 -4
- data/spec/integration/complex_rdf_datastream_spec.rb +54 -56
- data/spec/integration/delete_all_spec.rb +18 -15
- data/spec/integration/eradicate_spec.rb +54 -0
- data/spec/integration/fedora_solr_sync_spec.rb +7 -5
- data/spec/integration/field_to_solr_name_spec.rb +5 -5
- data/spec/integration/file_fixity_spec.rb +40 -0
- data/spec/integration/file_spec.rb +122 -0
- data/spec/integration/full_featured_model_spec.rb +53 -63
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +141 -114
- data/spec/integration/has_many_associations_spec.rb +142 -64
- data/spec/integration/json_serialization_spec.rb +50 -8
- data/spec/integration/model_spec.rb +12 -29
- data/spec/integration/nested_attribute_spec.rb +28 -20
- data/spec/integration/ntriples_datastream_spec.rb +60 -57
- data/spec/integration/om_datastream_spec.rb +51 -140
- data/spec/integration/rdf_nested_attributes_spec.rb +16 -14
- data/spec/integration/relation_delegation_spec.rb +7 -9
- data/spec/integration/relation_spec.rb +9 -7
- data/spec/integration/scoped_query_spec.rb +26 -26
- data/spec/integration/solr_instance_loader_spec.rb +69 -53
- data/spec/integration/solr_service_spec.rb +12 -73
- data/spec/integration/versionable_spec.rb +477 -0
- data/spec/integration/with_metadata_spec.rb +52 -0
- data/spec/samples/hydra-mods_article_datastream.rb +10 -6
- data/spec/samples/models/mods_article.rb +6 -2
- data/spec/samples/oral_history_sample.xml +1 -1
- data/spec/samples/oral_history_xml.xml +1 -1
- data/spec/samples/special_thing.rb +3 -3
- data/spec/spec_helper.rb +22 -12
- data/spec/support/an_active_model.rb +3 -7
- data/spec/unit/active_fedora_spec.rb +20 -17
- data/spec/unit/attached_files_spec.rb +203 -0
- data/spec/unit/attributes_spec.rb +286 -207
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_datastream_management_spec.rb +11 -24
- data/spec/unit/base_extra_spec.rb +17 -67
- data/spec/unit/base_spec.rb +163 -428
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +2 -2
- data/spec/unit/callback_spec.rb +38 -23
- data/spec/unit/change_set_spec.rb +46 -0
- data/spec/unit/code_configurator_spec.rb +5 -5
- data/spec/unit/config_spec.rb +9 -14
- data/spec/unit/core_spec.rb +59 -8
- data/spec/unit/file_configurator_spec.rb +55 -53
- data/spec/unit/file_path_builder_spec.rb +18 -0
- data/spec/unit/file_spec.rb +221 -0
- data/spec/unit/files_hash_spec.rb +53 -0
- data/spec/unit/fixity_service_spec.rb +34 -0
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +134 -0
- data/spec/unit/has_many_association_spec.rb +51 -0
- data/spec/unit/indexing_service_spec.rb +23 -0
- data/spec/unit/indexing_spec.rb +26 -0
- data/spec/unit/inheritance_spec.rb +9 -10
- data/spec/unit/model_spec.rb +15 -33
- data/spec/unit/nom_datastream_spec.rb +13 -10
- data/spec/unit/ntriples_datastream_spec.rb +81 -96
- data/spec/unit/om_datastream_spec.rb +137 -227
- data/spec/unit/persistence_spec.rb +28 -34
- data/spec/unit/predicates_spec.rb +29 -29
- data/spec/unit/property_spec.rb +1 -3
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +27 -32
- data/spec/unit/query_spec.rb +116 -149
- data/spec/unit/rdf_datastream_spec.rb +25 -43
- data/spec/unit/rdf_resource_datastream_spec.rb +24 -123
- data/spec/unit/{rdfxml_rdf_datastream_spec.rb → rdfxml_datastream_spec.rb} +21 -25
- data/spec/unit/readonly_spec.rb +23 -0
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +6 -6
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +6 -6
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +6 -6
- data/spec/unit/serializers_spec.rb +1 -1
- data/spec/unit/simple_datastream_spec.rb +12 -23
- data/spec/unit/solr_config_options_spec.rb +14 -17
- data/spec/unit/solr_service_spec.rb +38 -77
- data/spec/unit/sparql_insert_spec.rb +32 -0
- data/spec/unit/validations_spec.rb +8 -11
- metadata +96 -121
- data/lib/active_fedora/auditable.rb +0 -9
- data/lib/active_fedora/content_model.rb +0 -70
- data/lib/active_fedora/datastream_collections.rb +0 -302
- data/lib/active_fedora/datastream_hash.rb +0 -35
- data/lib/active_fedora/digital_object.rb +0 -55
- data/lib/active_fedora/fixture_exporter.rb +0 -33
- data/lib/active_fedora/fixture_loader.rb +0 -48
- data/lib/active_fedora/rdf/identifiable.rb +0 -66
- data/lib/active_fedora/rdf/project_hydra.rb +0 -12
- data/lib/active_fedora/rdf/rdfxml_rdf_datastream.rb +0 -13
- data/lib/active_fedora/rdf_xml_writer.rb +0 -49
- data/lib/active_fedora/relationship_graph.rb +0 -101
- data/lib/active_fedora/reload_on_save.rb +0 -16
- data/lib/active_fedora/rels_ext_datastream.rb +0 -100
- data/lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher.rb +0 -41
- data/lib/active_fedora/rubydora_connection.rb +0 -35
- data/lib/active_fedora/semantic_node.rb +0 -164
- data/lib/active_fedora/service_definitions.rb +0 -88
- data/lib/active_fedora/sharding.rb +0 -58
- data/lib/active_fedora/solr_digital_object.rb +0 -68
- data/lib/active_fedora/unsaved_digital_object.rb +0 -58
- data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +0 -12
- data/lib/generators/active_fedora/config/fedora/templates/fedora.yml +0 -38
- data/lib/generators/active_fedora/config/fedora/templates/fedora_conf/conf/development/fedora.fcfg +0 -953
- data/lib/generators/active_fedora/config/fedora/templates/fedora_conf/conf/test/fedora.fcfg +0 -953
- data/lib/tasks/active_fedora.rake +0 -83
- data/spec/fixtures/sharded_fedora.yml +0 -11
- data/spec/integration/auditable_spec.rb +0 -29
- data/spec/integration/datastream_collections_spec.rb +0 -127
- data/spec/integration/datastream_spec.rb +0 -90
- data/spec/integration/datastreams_spec.rb +0 -173
- data/spec/integration/load_from_solr_spec.rb +0 -66
- data/spec/integration/rels_ext_datastream_spec.rb +0 -82
- data/spec/support/mock_fedora.rb +0 -44
- data/spec/unit/content_model_spec.rb +0 -86
- data/spec/unit/datastream_collections_spec.rb +0 -420
- data/spec/unit/datastream_spec.rb +0 -83
- data/spec/unit/datastreams_spec.rb +0 -243
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +0 -96
- data/spec/unit/has_many_collection_spec.rb +0 -35
- data/spec/unit/rdf_vocab_spec.rb +0 -30
- data/spec/unit/rdf_xml_writer_spec.rb +0 -63
- data/spec/unit/relationship_graph_spec.rb +0 -115
- data/spec/unit/reload_on_save_spec.rb +0 -24
- data/spec/unit/rels_ext_datastream_spec.rb +0 -170
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +0 -44
- data/spec/unit/rubydora_connection_spec.rb +0 -12
- data/spec/unit/semantic_node_spec.rb +0 -112
- data/spec/unit/service_definitions_spec.rb +0 -63
- data/spec/unit/solr_digital_object_spec.rb +0 -97
- data/spec/unit/unsaved_digital_object_spec.rb +0 -48
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Base do
|
4
|
-
|
4
|
+
|
5
5
|
before(:all) do
|
6
6
|
module SpecModel
|
7
7
|
class Basic < ActiveFedora::Base
|
8
8
|
class_attribute :callback_counter
|
9
|
-
|
9
|
+
|
10
10
|
before_destroy :inc_counter
|
11
11
|
|
12
12
|
def inc_counter
|
@@ -15,7 +15,7 @@ describe ActiveFedora::Base do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
after(:all) do
|
20
20
|
Object.send(:remove_const, :SpecModel)
|
21
21
|
end
|
@@ -29,35 +29,38 @@ describe ActiveFedora::Base do
|
|
29
29
|
|
30
30
|
|
31
31
|
describe ".destroy_all" do
|
32
|
-
it "should remove both and run callbacks" do
|
32
|
+
it "should remove both and run callbacks" do
|
33
33
|
SpecModel::Basic.destroy_all
|
34
|
-
expect(SpecModel::Basic.count).to eq
|
35
|
-
expect(SpecModel::Basic.callback_counter).to eq
|
34
|
+
expect(SpecModel::Basic.count).to eq 0
|
35
|
+
expect(SpecModel::Basic.callback_counter).to eq 2
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "when a model is missing" do
|
39
39
|
let(:model3) { SpecModel::Basic.create! }
|
40
|
-
let!(:
|
41
|
-
|
40
|
+
let!(:id) { model3.id }
|
41
|
+
|
42
|
+
before { Ldp::Resource::RdfSource.new(ActiveFedora.fedora.connection, model3.uri).delete }
|
43
|
+
|
42
44
|
after do
|
43
45
|
ActiveFedora::SolrService.instance.conn.tap do |conn|
|
44
|
-
conn.delete_by_query "id:\"#{
|
46
|
+
conn.delete_by_query "id:\"#{id}\""
|
45
47
|
conn.commit
|
46
48
|
end
|
47
49
|
end
|
48
|
-
|
49
|
-
|
50
|
+
|
51
|
+
it "should be able to skip a missing model" do
|
52
|
+
expect(ActiveFedora::Base.logger).to receive(:error).with("Although #{id} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch.")
|
50
53
|
SpecModel::Basic.destroy_all
|
51
|
-
expect(SpecModel::Basic.count).to eq
|
54
|
+
expect(SpecModel::Basic.count).to eq 1
|
52
55
|
end
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
56
59
|
describe ".delete_all" do
|
57
|
-
it "should remove both and not run callbacks" do
|
60
|
+
it "should remove both and not run callbacks" do
|
58
61
|
SpecModel::Basic.delete_all
|
59
|
-
expect(SpecModel::Basic.count).to eq
|
60
|
-
expect(SpecModel::Basic.callback_counter).to eq
|
62
|
+
expect(SpecModel::Basic.count).to eq 0
|
63
|
+
expect(SpecModel::Basic.callback_counter).to eq 0
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::Base do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
class ResurrectionModel < ActiveFedora::Base
|
7
|
+
after_destroy :eradicate
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
Object.send(:remove_const, :ResurrectionModel)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when an object is has already been deleted" do
|
16
|
+
let(:ghost) do
|
17
|
+
obj = ActiveFedora::Base.create
|
18
|
+
obj.destroy
|
19
|
+
obj.id
|
20
|
+
end
|
21
|
+
context "in a typical sitation" do
|
22
|
+
specify "it cannot be reused" do
|
23
|
+
expect { ActiveFedora::Base.create(ghost) }.to raise_error(Ldp::Gone)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
specify "remove its tombstone" do
|
27
|
+
expect(ActiveFedora::Base.eradicate(ghost)).to be true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "when an object has just been deleted" do
|
32
|
+
let(:zombie) do
|
33
|
+
obj = ActiveFedora::Base.create
|
34
|
+
obj.destroy
|
35
|
+
return obj
|
36
|
+
end
|
37
|
+
specify "remove its tombstone" do
|
38
|
+
expect(zombie.eradicate).to be true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "a model with no tombstones" do
|
43
|
+
let(:lazarus) do
|
44
|
+
body = ResurrectionModel.create
|
45
|
+
soul = body.id
|
46
|
+
body.destroy
|
47
|
+
return soul
|
48
|
+
end
|
49
|
+
it "should allow reusing a uri" do
|
50
|
+
expect(ResurrectionModel.create(id: lazarus)).to be_kind_of(ResurrectionModel)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -4,11 +4,11 @@ require 'timeout'
|
|
4
4
|
describe "fedora_solr_sync_issues" do
|
5
5
|
before :all do
|
6
6
|
class ParentThing < ActiveFedora::Base
|
7
|
-
has_many :things, :class_name=>'ChildThing', :
|
7
|
+
has_many :things, :class_name=>'ChildThing', predicate: ActiveFedora::RDF::RelsExt.isPartOf
|
8
8
|
end
|
9
9
|
|
10
10
|
class ChildThing < ActiveFedora::Base
|
11
|
-
belongs_to :parent, :class_name=>'ParentThing', :
|
11
|
+
belongs_to :parent, :class_name=>'ParentThing', predicate: ActiveFedora::RDF::RelsExt.isPartOf
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -18,11 +18,13 @@ describe "fedora_solr_sync_issues" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
let(:parent) { ParentThing.create }
|
21
|
-
subject { ChildThing.create :
|
21
|
+
subject { ChildThing.create parent: parent }
|
22
|
+
|
23
|
+
before { Ldp::Resource::RdfSource.new(ActiveFedora.fedora.connection, subject.uri).delete }
|
22
24
|
|
23
25
|
it "should not go into an infinite loop" do
|
24
|
-
subject.inner_object.delete
|
25
26
|
parent.reload
|
26
|
-
expect(
|
27
|
+
expect(ActiveFedora::Base.logger).to receive(:error).with("Solr and Fedora may be out of sync:\n")
|
28
|
+
expect(parent.things).to eq []
|
27
29
|
end
|
28
30
|
end
|
@@ -5,10 +5,10 @@ describe "An object with RDF backed attributes" do
|
|
5
5
|
before do
|
6
6
|
class TestOne < ActiveFedora::Base
|
7
7
|
class MyMetadata < ActiveFedora::NtriplesRDFDatastream
|
8
|
-
property :title, predicate: RDF::DC.title do |index|
|
8
|
+
property :title, predicate: ::RDF::DC.title do |index|
|
9
9
|
index.as :stored_searchable
|
10
10
|
end
|
11
|
-
property :date_uploaded, predicate: RDF::DC.dateSubmitted do |index|
|
11
|
+
property :date_uploaded, predicate: ::RDF::DC.dateSubmitted do |index|
|
12
12
|
index.type :date
|
13
13
|
index.as :stored_searchable, :sortable
|
14
14
|
end
|
@@ -18,15 +18,15 @@ describe "An object with RDF backed attributes" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
after do
|
21
|
+
after do
|
22
22
|
Object.send(:remove_const, :TestOne)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should be able to grab the solr name" do
|
26
|
-
expect(TestOne.
|
26
|
+
expect(TestOne.delegated_attributes[:title].primary_solr_name).to eq 'desc_metadata__title_tesim'
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should be able to grab the solr name for a date" do
|
30
|
-
expect(TestOne.
|
30
|
+
expect(TestOne.delegated_attributes[:date_uploaded].primary_solr_name).to eq 'desc_metadata__date_uploaded_dtsim'
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Checking fixity" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
class MockAFBase < ActiveFedora::Base
|
7
|
+
contains "data", autocreate: true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
Object.send(:remove_const, :MockAFBase)
|
13
|
+
end
|
14
|
+
|
15
|
+
subject do
|
16
|
+
obj = MockAFBase.create
|
17
|
+
obj.data.content = "some content"
|
18
|
+
obj.save
|
19
|
+
obj.data
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with a valid resource" do
|
23
|
+
it "should return true for a successful fixity check" do
|
24
|
+
expect(subject.check_fixity).to be true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
context "when no uri has been set" do
|
28
|
+
subject { ActiveFedora::File.new }
|
29
|
+
it "should raise an error" do
|
30
|
+
expect { subject.check_fixity }.to raise_error(ArgumentError, "You must provide a uri")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
context "with missing resource" do
|
34
|
+
subject { ActiveFedora::File.new(ActiveFedora::Base.id_to_uri('123')) }
|
35
|
+
it "should raise an error" do
|
36
|
+
expect { subject.check_fixity }.to raise_error(Ldp::NotFound)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'active_fedora'
|
4
|
+
require "rexml/document"
|
5
|
+
|
6
|
+
describe ActiveFedora::File do
|
7
|
+
context "stand alone operation" do
|
8
|
+
it "should save" do
|
9
|
+
subject.content = "some stuff"
|
10
|
+
subject.save
|
11
|
+
expect(subject).not_to be_new_record
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when autocreate is true" do
|
16
|
+
before(:all) do
|
17
|
+
class MockAFBase < ActiveFedora::Base
|
18
|
+
has_metadata "descMetadata", type: ActiveFedora::QualifiedDublinCoreDatastream, autocreate: true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:all) do
|
23
|
+
Object.send(:remove_const, :MockAFBase)
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:test_object) { MockAFBase.create }
|
27
|
+
|
28
|
+
after do
|
29
|
+
test_object.destroy
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:descMetadata) { test_object.attached_files["descMetadata"] }
|
33
|
+
|
34
|
+
describe "the datastream" do
|
35
|
+
subject { descMetadata }
|
36
|
+
it { should be_a_kind_of(ActiveFedora::File) }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#content" do
|
40
|
+
subject { descMetadata.content }
|
41
|
+
it { should_not be_nil }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#described_by" do
|
45
|
+
subject { descMetadata.described_by }
|
46
|
+
it { should eq descMetadata.uri + '/fcr:metadata' }
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
context "an XML datastream" do
|
51
|
+
let(:xml_content) { Nokogiri::XML::Document.parse(descMetadata.content) }
|
52
|
+
let(:title) { Nokogiri::XML::Element.new "title", xml_content }
|
53
|
+
before do
|
54
|
+
title.content = "Test Title"
|
55
|
+
xml_content.root.add_child title
|
56
|
+
|
57
|
+
allow(descMetadata).to receive(:before_save)
|
58
|
+
descMetadata.content = xml_content.to_s
|
59
|
+
descMetadata.save
|
60
|
+
end
|
61
|
+
|
62
|
+
let(:found) { Nokogiri::XML::Document.parse(test_object.reload.descMetadata.content) }
|
63
|
+
|
64
|
+
subject { found.xpath('//dc/title/text()').first.inner_text }
|
65
|
+
it { should eq title.content }
|
66
|
+
end
|
67
|
+
|
68
|
+
context "a blob datastream" do
|
69
|
+
let(:dsid) { "ds#{Time.now.to_i}" }
|
70
|
+
let(:content) { fixture('dino.jpg') }
|
71
|
+
let(:datastream) { ActiveFedora::File.new.tap { |ds| ds.content = content } }
|
72
|
+
|
73
|
+
before do
|
74
|
+
test_object.attach_file(datastream, dsid)
|
75
|
+
test_object.save
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not be changed" do
|
79
|
+
expect(test_object.attached_files[dsid]).to_not be_changed
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should be able to read the content from fedora" do
|
83
|
+
content.rewind
|
84
|
+
expect(test_object.attached_files[dsid].content).to eq content.read
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "streaming the response" do
|
88
|
+
let(:stream_reader) { double }
|
89
|
+
it "should stream the response" do
|
90
|
+
expect(stream_reader).to receive(:read).at_least(:once)
|
91
|
+
test_object.attached_files[dsid].stream { |buff| stream_reader.read(buff) }
|
92
|
+
end
|
93
|
+
|
94
|
+
context "with a range request" do
|
95
|
+
before do
|
96
|
+
test_object.add_file_datastream('one1two2threfour', dsid: 'webm', mime_type: 'video/webm')
|
97
|
+
test_object.save!
|
98
|
+
end
|
99
|
+
subject { str = ''; test_object.webm.stream(range) {|chunk| str << chunk }; str }
|
100
|
+
context "whole thing" do
|
101
|
+
let(:range) { 'bytes=0-15' }
|
102
|
+
it { should eq 'one1two2threfour'}
|
103
|
+
end
|
104
|
+
context "open ended" do
|
105
|
+
let(:range) { 'bytes=0-' }
|
106
|
+
it "should get a response" do
|
107
|
+
expect(subject).to eq 'one1two2threfour'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
context "not starting at the beginning" do
|
111
|
+
let(:range) { 'bytes=3-15' }
|
112
|
+
it { should eq '1two2threfour'}
|
113
|
+
end
|
114
|
+
context "not ending at the end" do
|
115
|
+
let(:range) { 'bytes=4-11' }
|
116
|
+
it { should eq 'two2thre'}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -22,10 +22,10 @@ describe ActiveFedora::Base do
|
|
22
22
|
m.field "series", :string
|
23
23
|
m.field "location", :string
|
24
24
|
end
|
25
|
-
|
26
|
-
|
27
|
-
has_metadata :name=>"mods_article", :type=> Hydra::ModsArticleDatastream
|
28
|
-
|
25
|
+
|
26
|
+
|
27
|
+
has_metadata :name=>"mods_article", :type=> Hydra::ModsArticleDatastream
|
28
|
+
|
29
29
|
has_metadata :name => "dublin_core", :type => ActiveFedora::QualifiedDublinCoreDatastream do |m|
|
30
30
|
# Default :multiple => true
|
31
31
|
#
|
@@ -34,24 +34,24 @@ describe ActiveFedora::Base do
|
|
34
34
|
#
|
35
35
|
# aimint to use method-missing to support calling methods like
|
36
36
|
# my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible
|
37
|
-
|
37
|
+
|
38
38
|
# Setting new Types for dates and text content
|
39
39
|
#m.field "creation_date", :date, :xml_node => "date"
|
40
40
|
#m.field "abstract", :text, :xml_node => "abstract"
|
41
41
|
#m.field "rights", :text, :xml_node => "rights"
|
42
|
-
|
42
|
+
|
43
43
|
# Setting up special named fields
|
44
|
-
#m.field "subject_heading", :string, :xml_node => "subject", :encoding => "LCSH"
|
44
|
+
#m.field "subject_heading", :string, :xml_node => "subject", :encoding => "LCSH"
|
45
45
|
#m.field "spatial_coverage", :string, :xml_node => "spatial", :encoding => "TGN"
|
46
46
|
#m.field "temporal_coverage", :string, :xml_node => "temporal", :encoding => "Period"
|
47
47
|
#m.field "type", :string, :xml_node => "type", :encoding => "DCMITYPE"
|
48
48
|
#m.field "alt_title", :string, :xml_node => "alternative"
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
has_metadata :name => "significant_passages", :type => ActiveFedora::SimpleDatastream do |m|
|
52
52
|
m.field "significant_passage", :text
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
has_metadata :name => "sensitive_passages", :type => ActiveFedora::SimpleDatastream do |m|
|
56
56
|
m.field "sensitive_passage", :text
|
57
57
|
end
|
@@ -66,19 +66,19 @@ describe ActiveFedora::Base do
|
|
66
66
|
END
|
67
67
|
sample_narrator = 'Addelson, Frances'
|
68
68
|
sample_bio = <<-END
|
69
|
-
Rochelle Ruthchild interviewed Frances Addleson on October 18, November 14, and December 10, 1997. The interview thoroughly examined the trajectory of Frances\' life from birth until the time of the interview. As a young child, Frances\' father died during the influenza
|
69
|
+
Rochelle Ruthchild interviewed Frances Addleson on October 18, November 14, and December 10, 1997. The interview thoroughly examined the trajectory of Frances\' life from birth until the time of the interview. As a young child, Frances\' father died during the influenza eidemic, and her mother was not equipped to care for her and her siblings. Consequently, they were placed in a Jewish foster home. Although her experience was mostly positive, this experience would leave life-long effects. Frances attended Radcliffe upon the urging of a mentor and later obtained her Master\'s degree in social work from Simmons College in 1954. In the 1940\'s, she returned to work while her children were still young; a rather unusual event for that time period. While working as a social worker at Beth Israel Hospital in the early 1970\'s, she helped counsel countless women who came to the hospital seeking abortions before the procedure was officially legalized during the landmark Roe vs. Wade decision in 1973. Frances would later write two articles that were published in medical journals about her experience during this time. Although not a very religious person, Frances felt connected to the Jewish notion of social justice and remained very active until an accident in the late 1990\'s.
|
70
70
|
END
|
71
71
|
sample_interviewer = "Ruthchild, & Rochelle"
|
72
|
-
|
73
|
-
@properties_sample_values2 = Hash[:narrator => "Narrator1 & Narrator2", :interviewer => "Interviewer", :transcript_editor => "Transcript Editor", :bio => "Biographic info",
|
74
|
-
:notes => "My Note\\\'s a good one", :hard_copy_availability => "Yes", :hard_copy_location => "Archives", :other_contributor => "Sally Ride",
|
72
|
+
|
73
|
+
@properties_sample_values2 = Hash[:narrator => "Narrator1 & Narrator2", :interviewer => "Interviewer", :transcript_editor => "Transcript Editor", :bio => "Biographic info",
|
74
|
+
:notes => "My Note\\\'s a good one", :hard_copy_availability => "Yes", :hard_copy_location => "Archives", :other_contributor => "Sally Ride",
|
75
75
|
:restrictions => "None", :series => "My Series", :location => "location"]
|
76
|
-
|
77
|
-
@properties_sample_values = Hash[:narrator => sample_narrator, :interviewer => sample_interviewer, :transcript_editor => sample_transcript_editor, :bio => sample_bio,
|
78
|
-
:notes => sample_notes, :hard_copy_availability => sample_hard_copy_availability, :hard_copy_location => "Archives", :other_contributor => sample_other_contributor,
|
76
|
+
|
77
|
+
@properties_sample_values = Hash[:narrator => sample_narrator, :interviewer => sample_interviewer, :transcript_editor => sample_transcript_editor, :bio => sample_bio,
|
78
|
+
:notes => sample_notes, :hard_copy_availability => sample_hard_copy_availability, :hard_copy_location => "Archives", :other_contributor => sample_other_contributor,
|
79
79
|
:restrictions => "None", :series => "My Series", :location => sample_location]
|
80
80
|
|
81
|
-
@dublin_core_sample_values = Hash[:creator => 'Matt && McClain', :publisher => "Jewish Womens's Archive", :description => "description", :identifier => "jwa:
|
81
|
+
@dublin_core_sample_values = Hash[:creator => 'Matt && McClain', :publisher => "Jewish Womens's Archive", :description => "description", :identifier => "jwa:sample_id",
|
82
82
|
:title => "title",
|
83
83
|
#:alt_title => "alt_title", :subject => "subject",
|
84
84
|
#:subject_heading => "subject heading",
|
@@ -91,89 +91,79 @@ describe ActiveFedora::Base do
|
|
91
91
|
#:extent => "extent",
|
92
92
|
:format => "format", :medium => "medium"]
|
93
93
|
@signigicant_passages_sample_values = {}
|
94
|
-
@sensitive_passages_sample_values = {}
|
95
|
-
@sample_xml = "<xml><fields><system_create_date>REMOVED</system_create_date><system_modified_date>REMOVED</system_modified_date><active_fedora_model_s>OralHistory</active_fedora_model_s><id>changeme:14527</id><subject_heading>subject heading</subject_heading><type>type</type><rights>rights</rights><publisher>publisher</publisher><creation_date>creation date</creation_date><identifier>jwa:
|
96
|
-
|
97
|
-
end
|
98
|
-
|
94
|
+
@sensitive_passages_sample_values = {}
|
95
|
+
@sample_xml = "<xml><fields><system_create_date>REMOVED</system_create_date><system_modified_date>REMOVED</system_modified_date><active_fedora_model_s>OralHistory</active_fedora_model_s><id>changeme:14527</id><subject_heading>subject heading</subject_heading><type>type</type><rights>rights</rights><publisher>publisher</publisher><creation_date>creation date</creation_date><identifier>jwa:sample_id</identifier><format>format</format><extent>extent</extent><language>language</language><description>description</description><title>title</title><medium>medium</medium><spatial_coverage>spatial coverage</spatial_coverage><alt_title>alt_title</alt_title><temporal_coverage>temporal coverage</temporal_coverage><subject>subject</subject><creator>creator</creator><abstract>abstract</abstract><other_contributor>Sally Ride</other_contributor><transcript_editor>Transcript Editor</transcript_editor><restrictions>None</restrictions><bio>Biographic info</bio><series>My Series</series><notes>My Note</notes><location>location</location><hard_copy_availability>Yes</hard_copy_availability><narrator>Narrator</narrator><hard_copy_location>Archives</hard_copy_location><interviewer>Interviewer</interviewer></fields><content/></xml>"
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
99
|
before(:each) do
|
100
100
|
@test_history = OralHistory.new
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
after(:each) do
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
after(:all) do
|
107
107
|
Object.send(:remove_const, :OralHistory)
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
it "should be an instance of ActiveFedora::Base" do
|
111
111
|
expect(@test_history).to be_kind_of(ActiveFedora::Base)
|
112
112
|
end
|
113
|
-
|
114
113
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
|
115
|
+
it "should create proxies to all the attached_files" do
|
116
|
+
properties_ds = @test_history.attached_files["properties"]
|
117
|
+
dublin_core_ds = @test_history.attached_files["dublin_core"]
|
118
|
+
expect(@test_history.properties).to be properties_ds
|
119
119
|
expect(@test_history).to respond_to(:properties)
|
120
120
|
expect(OralHistory.new).to respond_to(:properties)
|
121
|
-
end
|
121
|
+
end
|
122
|
+
|
122
123
|
|
123
|
-
|
124
124
|
it "should push all of the metadata fields into solr" do
|
125
125
|
# TODO: test must test values using solr symbol names (ie. _field, _text and _date)
|
126
|
-
properties_ds = @test_history.
|
127
|
-
dublin_core_ds = @test_history.
|
128
|
-
|
126
|
+
properties_ds = @test_history.attached_files["properties"]
|
127
|
+
dublin_core_ds = @test_history.attached_files["dublin_core"]
|
128
|
+
|
129
129
|
@properties_sample_values.each_pair do |field, value|
|
130
130
|
next if field == :hard_copy_availability #FIXME HYDRA-824
|
131
131
|
properties_ds.send("#{field.to_s}=", [value])
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
@dublin_core_sample_values.each_pair do |field, value|
|
135
135
|
next if [:format, :type].include?(field) #format and type are methods declared on Object
|
136
136
|
dublin_core_ds.send("#{field.to_s}=", [value])
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
@test_history.save
|
140
|
-
|
141
|
-
@solr_result = OralHistory.find_with_conditions(:id=>@test_history.
|
140
|
+
|
141
|
+
@solr_result = OralHistory.find_with_conditions(:id=>@test_history.id)[0]
|
142
142
|
@properties_sample_values.each_pair do |field, value|
|
143
143
|
next if field == :hard_copy_availability #FIXME HYDRA-824
|
144
|
-
next if field == :location #FIXME HYDRA-825
|
145
|
-
expect(@solr_result[ActiveFedora::SolrService.solr_name(field, type: :string)] || @solr_result[ActiveFedora::SolrService.solr_name(field, type: :date)]).to eq
|
144
|
+
next if field == :location #FIXME HYDRA-825
|
145
|
+
expect((@solr_result[ActiveFedora::SolrService.solr_name(field, type: :string)] || @solr_result[ActiveFedora::SolrService.solr_name(field, type: :date)])).to eq [::Solrizer::Extractor.format_node_value(value)]
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
@dublin_core_sample_values.each_pair do |field, value|
|
149
149
|
next if [:format, :type].include?(field) #format and type are methods declared on Object
|
150
|
-
expect(dublin_core_ds.send("#{field.to_s}")).to eq
|
151
|
-
end
|
150
|
+
expect(dublin_core_ds.send("#{field.to_s}")).to eq [value]
|
151
|
+
end
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
it "should have Qualified Dublin core, with custom accessors" do
|
155
|
-
|
156
|
-
dublin_core_ds = @test_history.
|
157
|
-
|
155
|
+
|
156
|
+
dublin_core_ds = @test_history.attached_files["dublin_core"]
|
157
|
+
|
158
158
|
dublin_core_ds.subject = "My Subject Heading"
|
159
159
|
dc_xml = REXML::Document.new(dublin_core_ds.to_xml)
|
160
|
-
|
161
|
-
expect(dc_xml.root.elements["dcterms:subject"].text).to eq
|
162
|
-
|
160
|
+
|
161
|
+
expect(dc_xml.root.elements["dcterms:subject"].text).to eq "My Subject Heading"
|
162
|
+
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
165
|
it "should support #find_with_conditions" do
|
166
166
|
solr_result = OralHistory.find_with_conditions({})
|
167
|
-
expect(solr_result).
|
168
|
-
end
|
169
|
-
|
170
|
-
describe '#new' do
|
171
|
-
it "should support custom pids" do
|
172
|
-
oh = OralHistory.new(:pid=>"uuid:blah-blah-blah")
|
173
|
-
expect(oh.pid).to eq("uuid:blah-blah-blah")
|
174
|
-
end
|
167
|
+
expect(solr_result).to_not be_nil
|
175
168
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
169
|
end
|