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
@@ -3,14 +3,16 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe ActiveFedora::RDFDatastream do
|
5
5
|
describe "a new instance" do
|
6
|
-
|
7
|
-
|
6
|
+
subject { ActiveFedora::RDFDatastream.new }
|
7
|
+
it { should be_metadata }
|
8
|
+
it { should_not be_content_changed }
|
8
9
|
end
|
10
|
+
|
9
11
|
describe "an instance that exists in the datastore, but hasn't been loaded" do
|
10
12
|
before do
|
11
13
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
12
|
-
property :title, :
|
13
|
-
property :description, :
|
14
|
+
property :title, predicate: ::RDF::DC.title
|
15
|
+
property :description, predicate: ::RDF::DC.description, :multivalue => false
|
14
16
|
end
|
15
17
|
class MyObj < ActiveFedora::Base
|
16
18
|
has_metadata 'descMetadata', type: MyDatastream
|
@@ -18,89 +20,69 @@ describe ActiveFedora::RDFDatastream do
|
|
18
20
|
@obj = MyObj.new
|
19
21
|
@obj.descMetadata.title = 'Foobar'
|
20
22
|
@obj.save
|
21
|
-
@obj.reload
|
22
23
|
end
|
23
24
|
after do
|
24
25
|
@obj.destroy
|
25
26
|
Object.send(:remove_const, :MyDatastream)
|
26
27
|
Object.send(:remove_const, :MyObj)
|
27
28
|
end
|
28
|
-
|
29
|
+
|
30
|
+
subject { @obj.reload.descMetadata }
|
31
|
+
|
29
32
|
it "should not load the descMetadata datastream when calling content_changed?" do
|
30
|
-
expect(
|
31
|
-
expect(subject).
|
33
|
+
expect(subject).to_not receive(:retrieve_content)
|
34
|
+
expect(subject).to_not be_content_changed
|
32
35
|
end
|
33
36
|
|
34
37
|
it "should allow asserting an empty string" do
|
35
38
|
subject.title = ['']
|
36
|
-
expect(subject.title).to eq
|
39
|
+
expect(subject.title).to eq ['']
|
37
40
|
end
|
38
41
|
|
39
42
|
describe "when multivalue: false" do
|
40
43
|
it "should return single values" do
|
41
44
|
subject.description = 'my description'
|
42
|
-
expect(subject.description).to eq
|
45
|
+
expect(subject.description).to eq 'my description'
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
46
49
|
it "should clear stuff" do
|
47
50
|
subject.title = ['one', 'two', 'three']
|
48
51
|
subject.title.clear
|
49
|
-
expect(subject.graph.query([subject.rdf_subject, RDF::DC.title, nil]).first).to be_nil
|
52
|
+
expect(subject.graph.query([subject.rdf_subject, ::RDF::DC.title, nil]).first).to be_nil
|
50
53
|
end
|
51
54
|
|
52
55
|
it "should have a list of fields" do
|
53
|
-
expect(MyDatastream.fields).to eq
|
56
|
+
expect(MyDatastream.fields).to eq [:title, :description]
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
57
60
|
describe "deserialize" do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
context "with non-utf-8 characters" do
|
61
|
+
subject { ActiveFedora::NtriplesRDFDatastream.new }
|
62
|
+
it "should be able to handle non-utf-8 characters" do
|
62
63
|
# see https://github.com/ruby-rdf/rdf/issues/142
|
63
|
-
|
64
|
-
|
65
|
-
it "should be able to handle non-utf-8 characters" do
|
66
|
-
expect(subject.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
67
|
-
end
|
68
|
-
end
|
64
|
+
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
69
65
|
|
70
|
-
|
71
|
-
|
72
|
-
before do
|
73
|
-
allow(ds).to receive(:new?).and_return(false);
|
74
|
-
allow(ds).to receive(:datastream_content).and_return(nil);
|
75
|
-
end
|
76
|
-
it "should return an empty graph" do
|
77
|
-
expect(subject).to be_kind_of RDF::Graph
|
78
|
-
end
|
66
|
+
result = subject.deserialize(data)
|
67
|
+
expect(result.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
79
68
|
end
|
80
69
|
end
|
81
70
|
|
82
71
|
describe 'content=' do
|
83
|
-
let(:ds) {ActiveFedora::NtriplesRDFDatastream.new}
|
72
|
+
let(:ds) {ActiveFedora::NtriplesRDFDatastream.new }
|
84
73
|
it "should be able to handle non-utf-8 characters" do
|
85
74
|
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
86
75
|
ds.content = data
|
87
76
|
expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
88
77
|
end
|
89
|
-
context "when passed an IO-like object" do
|
90
|
-
let(:file) { File.new(File.join(File.dirname(__FILE__), "..", "fixtures", "dublin_core_rdf_descMetadata.nt")) }
|
91
|
-
it "should read it" do
|
92
|
-
ds.content = file
|
93
|
-
expect(ds.resource.dump(:ntriples)).to eq File.read(file.path)
|
94
|
-
end
|
95
|
-
end
|
96
78
|
end
|
97
79
|
|
98
80
|
describe 'legacy non-utf-8 characters' do
|
99
81
|
let(:ds) do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
82
|
+
ActiveFedora::NtriplesRDFDatastream.new.tap do |datastream|
|
83
|
+
allow(datastream).to receive(:new_record?).and_return(false)
|
84
|
+
allow(datastream).to receive(:remote_content).and_return("<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT'))
|
85
|
+
end
|
104
86
|
end
|
105
87
|
it "should not error on access" do
|
106
88
|
expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
@@ -3,18 +3,18 @@ require 'spec_helper'
|
|
3
3
|
describe ActiveFedora::RDFDatastream do
|
4
4
|
before do
|
5
5
|
class DummySubnode < ActiveTriples::Resource
|
6
|
-
property :title, :
|
7
|
-
property :relation, :
|
6
|
+
property :title, predicate: ::RDF::DC[:title], class_name: ::RDF::Literal
|
7
|
+
property :relation, predicate: ::RDF::DC[:relation]
|
8
8
|
end
|
9
9
|
|
10
10
|
class DummyResource < ActiveFedora::RDFDatastream
|
11
|
-
property :title, :
|
11
|
+
property :title, predicate: ::RDF::DC[:title], class_name: ::RDF::Literal do |index|
|
12
12
|
index.as :searchable, :displayable
|
13
13
|
end
|
14
|
-
property :license, :
|
14
|
+
property :license, predicate: ::RDF::DC[:license], class_name: DummySubnode do |index|
|
15
15
|
index.as :searchable, :displayable
|
16
16
|
end
|
17
|
-
property :creator, :
|
17
|
+
property :creator, predicate: ::RDF::DC[:creator], class_name: 'DummyAsset' do |index|
|
18
18
|
index.as :searchable
|
19
19
|
end
|
20
20
|
def serialization_format
|
@@ -23,20 +23,19 @@ describe ActiveFedora::RDFDatastream do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
class DummyAsset < ActiveFedora::Base
|
26
|
-
has_metadata
|
27
|
-
has_attributes :title, datastream: 'descMetadata', multiple: true
|
28
|
-
has_attributes :
|
29
|
-
has_attributes :relation, :datastream => 'descMetadata', :at => [:license, :relation], :multiple => false
|
26
|
+
has_metadata 'descMetadata', type: DummyResource
|
27
|
+
has_attributes :title, :license, datastream: 'descMetadata', multiple: true
|
28
|
+
has_attributes :relation, datastream: 'descMetadata', at: [:license, :relation], multiple: false
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
32
|
after do
|
34
|
-
Object.send(:remove_const, "DummyAsset")
|
35
|
-
Object.send(:remove_const, "DummyResource")
|
36
|
-
Object.send(:remove_const, "DummySubnode")
|
33
|
+
Object.send(:remove_const, "DummyAsset")
|
34
|
+
Object.send(:remove_const, "DummyResource")
|
35
|
+
Object.send(:remove_const, "DummySubnode")
|
37
36
|
end
|
38
37
|
|
39
|
-
subject {DummyAsset.new}
|
38
|
+
subject { DummyAsset.new }
|
40
39
|
|
41
40
|
describe "#to_solr" do
|
42
41
|
before do
|
@@ -67,19 +66,6 @@ describe ActiveFedora::RDFDatastream do
|
|
67
66
|
subject.title = ["blah"]
|
68
67
|
expect(subject.descMetadata.title).to eq ["blah"]
|
69
68
|
end
|
70
|
-
|
71
|
-
context "when the delegation is deep" do
|
72
|
-
before(:each) do
|
73
|
-
dummy = DummySubnode.new
|
74
|
-
dummy.relation = 'subbla'
|
75
|
-
subject.descMetadata.license = dummy
|
76
|
-
end
|
77
|
-
|
78
|
-
# This test is pending. For now we have no use case for deep delegation into an RDF graph.
|
79
|
-
xit "should retrieve values" do
|
80
|
-
expect(subject.relation).to eq ["subbla"]
|
81
|
-
end
|
82
|
-
end
|
83
69
|
end
|
84
70
|
|
85
71
|
describe "attribute setting" do
|
@@ -103,7 +89,7 @@ describe ActiveFedora::RDFDatastream do
|
|
103
89
|
end
|
104
90
|
|
105
91
|
it "should be persisted" do
|
106
|
-
expect(subject.descMetadata.resource
|
92
|
+
expect(subject.descMetadata.resource).to be_persisted
|
107
93
|
end
|
108
94
|
|
109
95
|
context "and it's reloaded" do
|
@@ -122,7 +108,7 @@ describe ActiveFedora::RDFDatastream do
|
|
122
108
|
|
123
109
|
context "and it is found again" do
|
124
110
|
before do
|
125
|
-
@object = DummyAsset.find(subject.
|
111
|
+
@object = DummyAsset.find(subject.id)
|
126
112
|
end
|
127
113
|
|
128
114
|
it "should serialize to content" do
|
@@ -134,7 +120,7 @@ describe ActiveFedora::RDFDatastream do
|
|
134
120
|
end
|
135
121
|
|
136
122
|
it "should have datastream content" do
|
137
|
-
expect(@object.descMetadata.
|
123
|
+
expect(@object.descMetadata.remote_content).not_to be_blank
|
138
124
|
end
|
139
125
|
end
|
140
126
|
end
|
@@ -144,7 +130,7 @@ describe ActiveFedora::RDFDatastream do
|
|
144
130
|
context "persisted to parent" do
|
145
131
|
before do
|
146
132
|
dummy = DummySubnode.new
|
147
|
-
dummy.title =
|
133
|
+
dummy.title = 'subbla'
|
148
134
|
subject.descMetadata.license = dummy
|
149
135
|
end
|
150
136
|
|
@@ -161,7 +147,7 @@ describe ActiveFedora::RDFDatastream do
|
|
161
147
|
DummySubnode.configure :repository => :default
|
162
148
|
allow_any_instance_of(DummySubnode).to receive(:repository).and_return(RDF::Repository.new)
|
163
149
|
dummy = DummySubnode.new(RDF::URI('http://example.org/dummy/blah'))
|
164
|
-
dummy.title =
|
150
|
+
dummy.title = 'subbla'
|
165
151
|
# We want to have to manually persist to the repository.
|
166
152
|
# Parent objects shouldn't be persisting children they share with other parents
|
167
153
|
dummy.persist!
|
@@ -179,18 +165,6 @@ describe ActiveFedora::RDFDatastream do
|
|
179
165
|
end
|
180
166
|
end
|
181
167
|
|
182
|
-
describe "asset.load_instance_from_solr" do
|
183
|
-
before do
|
184
|
-
subject.descMetadata.title = "Monkeys"
|
185
|
-
subject.save
|
186
|
-
@loaded_object = DummyAsset.load_instance_from_solr(subject.pid)
|
187
|
-
end
|
188
|
-
|
189
|
-
it "should load the datastream" do
|
190
|
-
expect(@loaded_object.title).to eq ["Monkeys"]
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
168
|
describe "relationships" do
|
195
169
|
before do
|
196
170
|
@new_object = DummyAsset.new
|
@@ -209,6 +183,7 @@ describe ActiveFedora::RDFDatastream do
|
|
209
183
|
subject.reload
|
210
184
|
expect(subject.descMetadata.creator.first).to be_kind_of(ActiveFedora::Base)
|
211
185
|
end
|
186
|
+
|
212
187
|
context "when the AF:Base object is deleted" do
|
213
188
|
before do
|
214
189
|
subject.save
|
@@ -228,11 +203,15 @@ describe ActiveFedora::RDFDatastream do
|
|
228
203
|
|
229
204
|
context "when the subject is set with base_uri" do
|
230
205
|
before do
|
206
|
+
@old_uri = DummyResource.resource_class.base_uri
|
231
207
|
DummyResource.resource_class.configure :base_uri => 'http://example.org/'
|
232
208
|
new_object = DummyAsset.new
|
233
209
|
new_object.save
|
234
210
|
subject.descMetadata.creator = new_object
|
235
211
|
end
|
212
|
+
after do
|
213
|
+
DummyResource.resource_class.configure :base_uri => @old_uri
|
214
|
+
end
|
236
215
|
|
237
216
|
it "should let me get to an AF:Base object" do
|
238
217
|
subject.save
|
@@ -244,7 +223,7 @@ describe ActiveFedora::RDFDatastream do
|
|
244
223
|
context "when the object with a relationship is saved" do
|
245
224
|
before do
|
246
225
|
subject.save
|
247
|
-
@object = subject.class.find(subject.
|
226
|
+
@object = subject.class.find(subject.id)
|
248
227
|
end
|
249
228
|
|
250
229
|
it "should be retrievable" do
|
@@ -255,7 +234,7 @@ describe ActiveFedora::RDFDatastream do
|
|
255
234
|
context "when the object with a relationship is frozen" do
|
256
235
|
before do
|
257
236
|
subject.save
|
258
|
-
@object = subject.class.find(subject.
|
237
|
+
@object = subject.class.find(subject.id)
|
259
238
|
@object.freeze
|
260
239
|
subject.freeze
|
261
240
|
end
|
@@ -264,83 +243,5 @@ describe ActiveFedora::RDFDatastream do
|
|
264
243
|
expect(subject.descMetadata.creator.first.title).to eq ["subbla"]
|
265
244
|
end
|
266
245
|
end
|
267
|
-
|
268
|
-
context 'when the object has no Rdf::Resource' do
|
269
|
-
before do
|
270
|
-
class DummyOmAsset < ActiveFedora::Base
|
271
|
-
has_metadata :name => 'descMetadata', :type => ActiveFedora::OmDatastream
|
272
|
-
end
|
273
|
-
|
274
|
-
@new_object = DummyOmAsset.new
|
275
|
-
@new_object.save
|
276
|
-
subject.title = ["bla"]
|
277
|
-
subject.descMetadata.creator = @new_object
|
278
|
-
subject.save
|
279
|
-
subject.reload
|
280
|
-
end
|
281
|
-
|
282
|
-
after do
|
283
|
-
Object.send(:remove_const, "DummyOmAsset") if Object
|
284
|
-
end
|
285
|
-
|
286
|
-
it "should let me get to an AF:Base object" do
|
287
|
-
expect(subject.descMetadata.creator.first).to be_kind_of(ActiveFedora::Base)
|
288
|
-
end
|
289
|
-
|
290
|
-
it "should not allow writing to the graph" do
|
291
|
-
expect{@new_object.resource << RDF::Statement.new(RDF::Node.new, RDF::DC.title, 'title')
|
292
|
-
}.to raise_error TypeError
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
context 'with custom resource' do
|
298
|
-
before do
|
299
|
-
|
300
|
-
class DummyATResource < ActiveTriples::Resource
|
301
|
-
configure :base_uri => 'http://example.org/at/obj#', :type => RDF::OWL.Thing
|
302
|
-
property :title, :predicate => RDF::DC.alternative
|
303
|
-
property :my_special_property, :predicate => RDF::DC.spatial
|
304
|
-
end
|
305
|
-
|
306
|
-
DummyResource.resource_class DummyATResource
|
307
|
-
end
|
308
|
-
|
309
|
-
after do
|
310
|
-
Object.send(:remove_const, "DummyATResource")
|
311
|
-
end
|
312
|
-
|
313
|
-
it 'lets me specify a resource class' do
|
314
|
-
expect(DummyResource.resource_class < DummyATResource).to eq true
|
315
|
-
end
|
316
|
-
|
317
|
-
it 'creates underlying resource of type resource_class' do
|
318
|
-
expect(subject.resource).to be_a DummyATResource
|
319
|
-
end
|
320
|
-
|
321
|
-
it 'has properties from resource_class' do
|
322
|
-
expect(subject.resource.class.properties).to include :my_special_property.to_s
|
323
|
-
end
|
324
|
-
|
325
|
-
it 'favors property configuration from datastream' do
|
326
|
-
expect(subject.resource.class.properties['title'].predicate).to eq RDF::DC.title
|
327
|
-
end
|
328
|
-
|
329
|
-
it 'exposes resource propreties to parent object via datastream' do
|
330
|
-
subject.resource.title = 'Wizard of Oz'
|
331
|
-
expect(subject.title).to eq subject.resource.title
|
332
|
-
end
|
333
|
-
|
334
|
-
it 'applies base_uri from resource class' do
|
335
|
-
expect(subject.resource.class.base_uri).to eq DummyATResource.base_uri
|
336
|
-
end
|
337
|
-
|
338
|
-
it 'applies rdf type from resource class' do
|
339
|
-
expect(subject.resource.class.type).to eq DummyATResource.type
|
340
|
-
end
|
341
|
-
|
342
|
-
it 'refuses to change resource_class once set' do
|
343
|
-
expect { DummyResource.resource_class(ActiveTriples::Resource) }.to raise_error ArgumentError
|
344
|
-
end
|
345
246
|
end
|
346
247
|
end
|
@@ -1,20 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe ActiveFedora::
|
3
|
+
describe ActiveFedora::RDFXMLDatastream do
|
4
4
|
describe "a new instance" do
|
5
5
|
before(:each) do
|
6
|
-
class MyRdfxmlDatastream < ActiveFedora::
|
7
|
-
property :publisher, :
|
6
|
+
class MyRdfxmlDatastream < ActiveFedora::RDFXMLDatastream
|
7
|
+
property :publisher, predicate: ::RDF::DC.publisher
|
8
8
|
end
|
9
|
-
@subject = MyRdfxmlDatastream.new
|
10
|
-
allow(@subject).to
|
9
|
+
@subject = MyRdfxmlDatastream.new
|
10
|
+
allow(@subject).to receive(:id).and_return('test:1')
|
11
11
|
end
|
12
|
+
|
12
13
|
after(:each) do
|
13
14
|
Object.send(:remove_const, :MyRdfxmlDatastream)
|
14
15
|
end
|
16
|
+
|
15
17
|
it "should save and reload" do
|
16
18
|
@subject.publisher = ["St. Martin's Press"]
|
17
|
-
expect(@subject.serialize).to match
|
19
|
+
expect(@subject.serialize).to match /<rdf:RDF/
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -49,22 +51,22 @@ describe ActiveFedora::RdfxmlRDFDatastream do
|
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
52
|
-
class MyDatastream < ActiveFedora::
|
53
|
-
property :resource_type, :
|
54
|
-
property :title, :
|
54
|
+
class MyDatastream < ActiveFedora::RDFXMLDatastream
|
55
|
+
property :resource_type, predicate: DAMS.typeOfResource
|
56
|
+
property :title, predicate: DAMS.title, :class_name => 'Description'
|
55
57
|
|
56
58
|
rdf_subject { |ds| RDF::URI.new(ds.about) }
|
57
59
|
|
58
|
-
|
60
|
+
attr_accessor :about
|
59
61
|
|
60
|
-
def initialize(
|
62
|
+
def initialize(options={})
|
61
63
|
@about = options.delete(:about)
|
62
64
|
super
|
63
65
|
end
|
64
66
|
|
65
67
|
class Description < ActiveTriples::Resource
|
66
68
|
configure :type => DAMS.Description
|
67
|
-
property :value, :
|
69
|
+
property :value, predicate: ::RDF.value do |index|
|
68
70
|
index.as :searchable
|
69
71
|
end
|
70
72
|
end
|
@@ -77,34 +79,28 @@ describe ActiveFedora::RdfxmlRDFDatastream do
|
|
77
79
|
end
|
78
80
|
|
79
81
|
describe "a new instance" do
|
80
|
-
subject { MyDatastream.new(
|
82
|
+
subject { MyDatastream.new(about: "http://library.ucsd.edu/ark:/20775/") }
|
81
83
|
it "should have a subject" do
|
82
|
-
expect(subject.rdf_subject.to_s).to eq
|
84
|
+
expect(subject.rdf_subject.to_s).to eq "http://library.ucsd.edu/ark:/20775/"
|
83
85
|
end
|
84
86
|
|
85
87
|
end
|
86
88
|
|
87
89
|
describe "an instance with content" do
|
88
90
|
subject do
|
89
|
-
subject = MyDatastream.new(
|
91
|
+
subject = MyDatastream.new(about: "http://library.ucsd.edu/ark:/20775/")
|
90
92
|
subject.content = File.new('spec/fixtures/damsObjectModel.xml').read
|
91
93
|
subject
|
92
94
|
end
|
93
95
|
it "should have a subject" do
|
94
|
-
expect(subject.rdf_subject.to_s).to eq
|
95
|
-
end
|
96
|
-
it "should have controlGroup" do
|
97
|
-
expect(subject.controlGroup).to eq('M')
|
96
|
+
expect(subject.rdf_subject.to_s).to eq "http://library.ucsd.edu/ark:/20775/"
|
98
97
|
end
|
99
98
|
it "should have mimeType" do
|
100
|
-
expect(subject.
|
101
|
-
end
|
102
|
-
it "should have dsid" do
|
103
|
-
expect(subject.dsid).to eq('descMetadata')
|
99
|
+
expect(subject.mime_type).to eq 'text/xml'
|
104
100
|
end
|
105
101
|
it "should have fields" do
|
106
|
-
expect(subject.resource_type).to eq
|
107
|
-
expect(subject.title.first.value).to eq
|
102
|
+
expect(subject.resource_type).to eq ["image"]
|
103
|
+
expect(subject.title.first.value).to eq ["example title"]
|
108
104
|
end
|
109
105
|
end
|
110
106
|
end
|