active-fedora 6.8.0 → 7.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +15 -5
- data/CONTRIBUTING.md +2 -0
- data/Gemfile +0 -2
- data/History.txt +2 -32
- data/README.md +143 -0
- data/Rakefile +5 -7
- data/active-fedora.gemspec +9 -9
- data/gemfiles/rails3.gemfile +11 -0
- data/gemfiles/rails4.gemfile +10 -0
- data/lib/active_fedora.rb +31 -4
- data/lib/active_fedora/association_relation.rb +18 -0
- data/lib/active_fedora/associations.rb +38 -171
- data/lib/active_fedora/associations/association.rb +163 -0
- data/lib/active_fedora/associations/association_scope.rb +39 -0
- data/lib/active_fedora/associations/belongs_to_association.rb +47 -25
- data/lib/active_fedora/associations/builder/association.rb +55 -0
- data/lib/active_fedora/associations/builder/belongs_to.rb +100 -0
- data/lib/active_fedora/associations/builder/collection_association.rb +56 -0
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +30 -0
- data/lib/active_fedora/associations/builder/has_many.rb +63 -0
- data/lib/active_fedora/associations/builder/singular_association.rb +32 -0
- data/lib/active_fedora/associations/{association_collection.rb → collection_association.rb} +203 -53
- data/lib/active_fedora/associations/collection_proxy.rb +862 -0
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +35 -25
- data/lib/active_fedora/associations/has_many_association.rb +36 -11
- data/lib/active_fedora/associations/singular_association.rb +62 -0
- data/lib/active_fedora/attributes.rb +43 -139
- data/lib/active_fedora/autosave_association.rb +317 -0
- data/lib/active_fedora/base.rb +10 -327
- data/lib/active_fedora/callbacks.rb +1 -3
- data/lib/active_fedora/content_model.rb +16 -0
- data/lib/active_fedora/core.rb +151 -0
- data/lib/active_fedora/datastream_attribute.rb +76 -0
- data/lib/active_fedora/datastream_hash.rb +8 -13
- data/lib/active_fedora/datastreams.rb +39 -26
- data/lib/active_fedora/digital_object.rb +2 -2
- data/lib/active_fedora/fedora_attributes.rb +45 -0
- data/lib/active_fedora/fixture_loader.rb +1 -1
- data/lib/active_fedora/indexing.rb +6 -1
- data/lib/active_fedora/model.rb +0 -17
- data/lib/active_fedora/nested_attributes.rb +2 -2
- data/lib/active_fedora/null_relation.rb +7 -0
- data/lib/active_fedora/om_datastream.rb +3 -4
- data/lib/active_fedora/persistence.rb +41 -29
- data/lib/active_fedora/querying.rb +2 -163
- data/lib/active_fedora/rdf.rb +1 -0
- data/lib/active_fedora/rdf/indexing.rb +67 -0
- data/lib/active_fedora/rdf_datastream.rb +2 -50
- data/lib/active_fedora/rdf_node.rb +12 -7
- data/lib/active_fedora/rdf_node/term_proxy.rb +30 -21
- data/lib/active_fedora/rdfxml_rdf_datastream.rb +1 -1
- data/lib/active_fedora/reflection.rb +163 -20
- data/lib/active_fedora/relation.rb +33 -130
- data/lib/active_fedora/relation/calculations.rb +19 -0
- data/lib/active_fedora/relation/delegation.rb +22 -0
- data/lib/active_fedora/relation/finder_methods.rb +247 -0
- data/lib/active_fedora/relation/merger.rb +22 -0
- data/lib/active_fedora/relation/query_methods.rb +58 -0
- data/lib/active_fedora/relation/spawn_methods.rb +46 -0
- data/lib/active_fedora/relationship_graph.rb +0 -2
- data/lib/active_fedora/rels_ext_datastream.rb +1 -4
- data/lib/active_fedora/rubydora_connection.rb +1 -1
- data/lib/active_fedora/scoping.rb +20 -0
- data/lib/active_fedora/scoping/default.rb +38 -0
- data/lib/active_fedora/scoping/named.rb +32 -0
- data/lib/active_fedora/semantic_node.rb +54 -106
- data/lib/active_fedora/serialization.rb +19 -0
- data/lib/active_fedora/sharding.rb +58 -0
- data/lib/active_fedora/solr_digital_object.rb +15 -5
- data/lib/active_fedora/solr_instance_loader.rb +1 -1
- data/lib/active_fedora/solr_service.rb +1 -1
- data/lib/active_fedora/unsaved_digital_object.rb +6 -4
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora.rake +3 -0
- data/lib/tasks/active_fedora_dev.rake +6 -5
- data/spec/config_helper.rb +14 -14
- data/spec/integration/associations_spec.rb +168 -455
- data/spec/integration/attributes_spec.rb +12 -11
- data/spec/integration/auditable_spec.rb +11 -11
- data/spec/integration/autosave_association_spec.rb +25 -0
- data/spec/integration/base_spec.rb +163 -163
- data/spec/integration/belongs_to_association_spec.rb +166 -0
- data/spec/integration/bug_spec.rb +7 -7
- data/spec/integration/collection_association_spec.rb +58 -0
- data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
- data/spec/integration/datastream_collections_spec.rb +69 -69
- data/spec/integration/datastream_spec.rb +43 -43
- data/spec/integration/datastreams_spec.rb +63 -63
- data/spec/integration/delete_all_spec.rb +46 -39
- data/spec/integration/fedora_solr_sync_spec.rb +5 -5
- data/spec/integration/field_to_solr_name_spec.rb +34 -0
- data/spec/integration/full_featured_model_spec.rb +100 -101
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +341 -0
- data/spec/integration/has_many_associations_spec.rb +172 -24
- data/spec/integration/json_serialization_spec.rb +31 -0
- data/spec/integration/load_from_solr_spec.rb +48 -0
- data/spec/integration/model_spec.rb +35 -40
- data/spec/integration/nested_attribute_spec.rb +42 -43
- data/spec/integration/ntriples_datastream_spec.rb +131 -113
- data/spec/integration/om_datastream_spec.rb +67 -67
- data/spec/integration/persistence_spec.rb +7 -7
- data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
- data/spec/integration/relation_delegation_spec.rb +26 -25
- data/spec/integration/relation_spec.rb +42 -0
- data/spec/integration/rels_ext_datastream_spec.rb +20 -20
- data/spec/integration/scoped_query_spec.rb +61 -51
- data/spec/integration/solr_instance_loader_spec.rb +5 -5
- data/spec/integration/solr_service_spec.rb +46 -46
- data/spec/samples/hydra-mods_article_datastream.rb +334 -334
- data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
- data/spec/samples/marpa-dc_datastream.rb +17 -17
- data/spec/samples/models/audio_record.rb +16 -16
- data/spec/samples/models/image.rb +2 -2
- data/spec/samples/models/mods_article.rb +5 -5
- data/spec/samples/models/oral_history.rb +18 -18
- data/spec/samples/models/seminar.rb +24 -24
- data/spec/samples/models/seminar_audio_file.rb +17 -17
- data/spec/samples/oral_history_sample_model.rb +21 -21
- data/spec/samples/special_thing.rb +14 -14
- data/spec/spec_helper.rb +11 -7
- data/spec/support/an_active_model.rb +2 -8
- data/spec/support/freeze_mocks.rb +12 -0
- data/spec/support/mock_fedora.rb +17 -16
- data/spec/unit/active_fedora_spec.rb +58 -60
- data/spec/unit/attributes_spec.rb +314 -0
- data/spec/unit/base_active_model_spec.rb +28 -27
- data/spec/unit/base_cma_spec.rb +5 -5
- data/spec/unit/base_datastream_management_spec.rb +27 -27
- data/spec/unit/base_extra_spec.rb +76 -48
- data/spec/unit/base_spec.rb +277 -348
- data/spec/unit/callback_spec.rb +18 -19
- data/spec/unit/code_configurator_spec.rb +17 -17
- data/spec/unit/config_spec.rb +8 -16
- data/spec/unit/content_model_spec.rb +79 -60
- data/spec/unit/datastream_collections_spec.rb +229 -229
- data/spec/unit/datastream_spec.rb +51 -63
- data/spec/unit/datastreams_spec.rb +87 -87
- data/spec/unit/file_configurator_spec.rb +217 -217
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +44 -25
- data/spec/unit/has_many_collection_spec.rb +26 -8
- data/spec/unit/inheritance_spec.rb +13 -12
- data/spec/unit/model_spec.rb +39 -45
- data/spec/unit/nom_datastream_spec.rb +15 -15
- data/spec/unit/ntriples_datastream_spec.rb +123 -118
- data/spec/unit/om_datastream_spec.rb +227 -233
- data/spec/unit/persistence_spec.rb +34 -15
- data/spec/unit/predicates_spec.rb +73 -73
- data/spec/unit/property_spec.rb +17 -9
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
- data/spec/unit/query_spec.rb +222 -198
- data/spec/unit/rdf_datastream_spec.rb +21 -28
- data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
- data/spec/unit/rdf_list_spec.rb +65 -64
- data/spec/unit/rdf_node_spec.rb +7 -7
- data/spec/unit/rdf_xml_writer_spec.rb +10 -10
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
- data/spec/unit/relationship_graph_spec.rb +51 -51
- data/spec/unit/rels_ext_datastream_spec.rb +68 -74
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
- data/spec/unit/rubydora_connection_spec.rb +5 -5
- data/spec/unit/semantic_node_spec.rb +48 -107
- data/spec/unit/serializers_spec.rb +4 -4
- data/spec/unit/service_definitions_spec.rb +26 -26
- data/spec/unit/simple_datastream_spec.rb +17 -17
- data/spec/unit/solr_config_options_spec.rb +29 -28
- data/spec/unit/solr_digital_object_spec.rb +17 -25
- data/spec/unit/solr_service_spec.rb +95 -82
- data/spec/unit/unsaved_digital_object_spec.rb +24 -23
- data/spec/unit/validations_spec.rb +21 -21
- metadata +110 -159
- data/.rspec +0 -1
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -938
- data/CONSOLE_GETTING_STARTED.textile +0 -1
- data/NOKOGIRI_DATASTREAMS.textile +0 -1
- data/README.textile +0 -116
- data/lib/active_fedora/associations/association_proxy.rb +0 -178
- data/lib/active_fedora/delegating.rb +0 -72
- data/lib/active_fedora/nokogiri_datastream.rb +0 -11
- data/spec/integration/delegating_spec.rb +0 -59
- data/spec/rails3_test_app/.gitignore +0 -4
- data/spec/rails3_test_app/.rspec +0 -1
- data/spec/rails3_test_app/Gemfile +0 -40
- data/spec/rails3_test_app/Rakefile +0 -7
- data/spec/rails3_test_app/app/controllers/application_controller.rb +0 -3
- data/spec/rails3_test_app/app/helpers/application_helper.rb +0 -2
- data/spec/rails3_test_app/app/views/layouts/application.html.erb +0 -14
- data/spec/rails3_test_app/config.ru +0 -4
- data/spec/rails3_test_app/config/application.rb +0 -42
- data/spec/rails3_test_app/config/boot.rb +0 -6
- data/spec/rails3_test_app/config/database.yml +0 -22
- data/spec/rails3_test_app/config/environment.rb +0 -5
- data/spec/rails3_test_app/config/environments/development.rb +0 -25
- data/spec/rails3_test_app/config/environments/production.rb +0 -49
- data/spec/rails3_test_app/config/environments/test.rb +0 -35
- data/spec/rails3_test_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails3_test_app/config/initializers/inflections.rb +0 -10
- data/spec/rails3_test_app/config/initializers/mime_types.rb +0 -5
- data/spec/rails3_test_app/config/initializers/secret_token.rb +0 -7
- data/spec/rails3_test_app/config/initializers/session_store.rb +0 -8
- data/spec/rails3_test_app/config/locales/en.yml +0 -5
- data/spec/rails3_test_app/config/routes.rb +0 -58
- data/spec/rails3_test_app/db/seeds.rb +0 -7
- data/spec/rails3_test_app/run_tests +0 -3
- data/spec/rails3_test_app/script/rails +0 -6
- data/spec/rails3_test_app/spec/spec_helper.rb +0 -27
- data/spec/rails3_test_app/spec/unit/rails_3_init.rb +0 -15
- data/spec/unit/association_proxy_spec.rb +0 -12
- data/spec/unit/base_delegate_spec.rb +0 -197
- data/spec/unit/base_delegate_to_spec.rb +0 -73
@@ -2,19 +2,12 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe ActiveFedora::RDFDatastream do
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
8
|
-
it { is_expected.to be_truthy}
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '#content_changed?' do
|
12
|
-
subject { super().content_changed? }
|
13
|
-
it { is_expected.to be_falsey}
|
14
|
-
end
|
5
|
+
describe "a new instance" do
|
6
|
+
its(:metadata?) { should be_true}
|
7
|
+
its(:content_changed?) { should be_false}
|
15
8
|
end
|
16
9
|
describe "an instance that exists in the datastore, but hasn't been loaded" do
|
17
|
-
before do
|
10
|
+
before do
|
18
11
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
19
12
|
map_predicates do |map|
|
20
13
|
map.title(in: RDF::DC)
|
@@ -33,43 +26,43 @@ describe ActiveFedora::RDFDatastream do
|
|
33
26
|
Object.send(:remove_const, :MyDatastream)
|
34
27
|
Object.send(:remove_const, :MyObj)
|
35
28
|
end
|
36
|
-
subject { @obj.reload.descMetadata }
|
37
|
-
it
|
38
|
-
|
39
|
-
|
29
|
+
subject { @obj.reload.descMetadata }
|
30
|
+
it "should not load the descMetadata datastream when calling content_changed?" do
|
31
|
+
@obj.inner_object.repository.should_not_receive(:datastream_dissemination).with(hash_including(:dsid=>'descMetadata'))
|
32
|
+
subject.should_not be_content_changed
|
40
33
|
end
|
41
34
|
|
42
|
-
it
|
35
|
+
it "should allow asserting an empty string" do
|
43
36
|
subject.title = ['']
|
44
|
-
|
37
|
+
subject.title.should == ['']
|
45
38
|
end
|
46
39
|
|
47
|
-
describe
|
48
|
-
it
|
40
|
+
describe "when multivalue: false" do
|
41
|
+
it "should return single values" do
|
49
42
|
subject.description = 'my description'
|
50
|
-
|
43
|
+
subject.description.should == 'my description'
|
51
44
|
end
|
52
45
|
end
|
53
46
|
|
54
|
-
it
|
47
|
+
it "should clear stuff" do
|
55
48
|
subject.title = ['one', 'two', 'three']
|
56
49
|
subject.title.clear
|
57
|
-
|
50
|
+
subject.graph.query([subject.rdf_subject, RDF::DC.title, nil]).first.should be_nil
|
58
51
|
end
|
59
52
|
|
60
|
-
it
|
61
|
-
|
53
|
+
it "should have a list of fields" do
|
54
|
+
MyDatastream.fields.should == [:title, :description]
|
62
55
|
end
|
63
56
|
end
|
64
57
|
|
65
|
-
describe
|
66
|
-
it
|
58
|
+
describe "deserialize" do
|
59
|
+
it "should be able to handle non-utf-8 characters" do
|
67
60
|
# see https://github.com/ruby-rdf/rdf/issues/142
|
68
61
|
ds = ActiveFedora::NtriplesRDFDatastream.new
|
69
62
|
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
70
|
-
|
63
|
+
|
71
64
|
result = ds.deserialize(data)
|
72
|
-
|
65
|
+
result.dump(:ntriples).should == "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
73
66
|
end
|
74
67
|
end
|
75
68
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::RdfList do
|
4
4
|
before :each do
|
5
|
-
class MADS < RDF::Vocabulary(
|
5
|
+
class MADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
|
6
6
|
property :MADSScheme
|
7
7
|
property :isMemberOfMADSScheme
|
8
8
|
property :authoritativeLabel
|
@@ -18,22 +18,22 @@ describe ActiveFedora::RdfList do
|
|
18
18
|
include ActiveFedora::RdfObject
|
19
19
|
rdf_type MADS.TopicElement
|
20
20
|
map_predicates do |map|
|
21
|
-
map.elementValue(:in
|
21
|
+
map.elementValue(:in=> MADS)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
class TemporalElement
|
25
25
|
include ActiveFedora::RdfObject
|
26
26
|
rdf_type MADS.TemporalElement
|
27
27
|
map_predicates do |map|
|
28
|
-
map.elementValue(:in
|
28
|
+
map.elementValue(:in=> MADS)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
class ElementList
|
32
32
|
include ActiveFedora::RdfList
|
33
|
-
|
33
|
+
|
34
34
|
map_predicates do |map|
|
35
|
-
map.topicElement(:in
|
36
|
-
map.temporalElement(:in
|
35
|
+
map.topicElement(:in=> MADS, :to =>"TopicElement", :class_name => "TopicElement")
|
36
|
+
map.temporalElement(:in=> MADS, :to =>"TemporalElement", :class_name => "TemporalElement")
|
37
37
|
end
|
38
38
|
accepts_nested_attributes_for :topicElement, :temporalElement
|
39
39
|
end
|
@@ -44,7 +44,7 @@ describe ActiveFedora::RdfList do
|
|
44
44
|
rdf_subject { |ds| RDF::URI.new(Rails.configuration.id_namespace + ds.pid)}
|
45
45
|
map_predicates do |map|
|
46
46
|
map.name(:in => MADS, :to => 'authoritativeLabel')
|
47
|
-
map.elementList(:in => MADS, :class_name
|
47
|
+
map.elementList(:in => MADS, :class_name=>'ElementList')
|
48
48
|
map.externalAuthority(:in => MADS, :to => 'hasExactExternalAuthority')
|
49
49
|
end
|
50
50
|
accepts_nested_attributes_for :elementList
|
@@ -57,15 +57,15 @@ describe ActiveFedora::RdfList do
|
|
57
57
|
Object.send(:remove_const, :TemporalElement)
|
58
58
|
Object.send(:remove_const, :MADS)
|
59
59
|
end
|
60
|
-
|
61
|
-
describe
|
62
|
-
it
|
60
|
+
|
61
|
+
describe "nested_attributes" do
|
62
|
+
it "should insert new nodes into RdfLists (rather than calling .build)" do
|
63
63
|
params = {
|
64
64
|
topic: {
|
65
|
-
name:
|
66
|
-
externalAuthority:
|
65
|
+
name: "Baseball",
|
66
|
+
externalAuthority: "http://id.loc.gov/authorities/subjects/sh85012026",
|
67
67
|
elementList_attributes: [
|
68
|
-
topicElement_attributes: [{ elementValue:
|
68
|
+
topicElement_attributes: [{ elementValue: "Baseball" }, elementValue: "Football"],
|
69
69
|
]
|
70
70
|
}
|
71
71
|
}
|
@@ -73,25 +73,25 @@ describe ActiveFedora::RdfList do
|
|
73
73
|
topic = Topic.new(RDF::Graph.new)
|
74
74
|
topic.attributes = params[:topic]
|
75
75
|
# puts topic.graph.dump(:ntriples)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
topic.elementList.first.size.should == 2
|
77
|
+
topic.elementList.first[0].should be_kind_of(TopicElement)
|
78
|
+
topic.elementList.first[0].elementValue.should == ["Baseball"]
|
79
|
+
topic.elementList.first[1].should be_kind_of(TopicElement)
|
80
|
+
topic.elementList.first[1].elementValue.should == ["Football"]
|
81
81
|
|
82
82
|
# only one rdf:rest rdf:nil
|
83
|
-
|
83
|
+
topic.graph.query([nil, RDF.rest, RDF.nil]).size.should == 1
|
84
84
|
end
|
85
|
-
it
|
86
|
-
# It's Not clear what the syntax should be when an RDF list contains multiple types of sub-nodes.
|
85
|
+
it "should insert new nodes of varying types into RdfLists (rather than calling .build)" do
|
86
|
+
# It's Not clear what the syntax should be when an RDF list contains multiple types of sub-nodes.
|
87
87
|
# This is a guess, which currently works.
|
88
88
|
params = {
|
89
89
|
topic: {
|
90
|
-
name:
|
91
|
-
externalAuthority:
|
90
|
+
name: "Baseball",
|
91
|
+
externalAuthority: "http://id.loc.gov/authorities/subjects/sh85012026",
|
92
92
|
elementList_attributes: [
|
93
|
-
topicElement_attributes: [{ elementValue:
|
94
|
-
temporalElement_attributes: [{elementValue:
|
93
|
+
topicElement_attributes: [{ elementValue: "Baseball" }, elementValue: "Football"],
|
94
|
+
temporalElement_attributes: [{elementValue: "1960"}, {elementValue:"Twentieth Century"}],
|
95
95
|
]
|
96
96
|
}
|
97
97
|
}
|
@@ -99,15 +99,15 @@ describe ActiveFedora::RdfList do
|
|
99
99
|
topic = Topic.new(RDF::Graph.new)
|
100
100
|
topic.attributes = params[:topic]
|
101
101
|
# puts topic.graph.dump(:ntriples)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
102
|
+
topic.elementList.first.size.should == 4
|
103
|
+
topic.elementList.first[0].should be_kind_of(TopicElement)
|
104
|
+
topic.elementList.first[0].elementValue.should == ["Baseball"]
|
105
|
+
topic.elementList.first[1].should be_kind_of(TopicElement)
|
106
|
+
topic.elementList.first[1].elementValue.should == ["Football"]
|
107
|
+
topic.elementList.first[2].should be_kind_of(TemporalElement)
|
108
|
+
topic.elementList.first[2].elementValue.should == ["1960"]
|
109
|
+
topic.elementList.first[3].should be_kind_of(TemporalElement)
|
110
|
+
topic.elementList.first[3].elementValue.should == ["Twentieth Century"]
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
data/spec/unit/rdf_list_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::RdfList do
|
4
4
|
before :each do
|
5
|
-
class MADS < RDF::Vocabulary(
|
5
|
+
class MADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
|
6
6
|
property :complexSubject
|
7
7
|
property :authoritativeLabel
|
8
8
|
property :elementList
|
@@ -12,27 +12,27 @@ describe ActiveFedora::RdfList do
|
|
12
12
|
end
|
13
13
|
class DemoList < ActiveFedora::RdfxmlRDFDatastream
|
14
14
|
map_predicates do |map|
|
15
|
-
map.elementList(:in => MADS, :to => 'elementList', :class_name
|
16
|
-
end
|
17
|
-
class List
|
15
|
+
map.elementList(:in => MADS, :to => 'elementList', :class_name=>'List')
|
16
|
+
end
|
17
|
+
class List
|
18
18
|
include ActiveFedora::RdfList
|
19
19
|
map_predicates do |map|
|
20
|
-
map.topicElement(:in
|
21
|
-
map.temporalElement(:in
|
20
|
+
map.topicElement(:in=> MADS, :to =>"TopicElement", :class_name => "TopicElement")
|
21
|
+
map.temporalElement(:in=> MADS, :to =>"TemporalElement", :class_name => "TemporalElement")
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
class TopicElement
|
25
25
|
include ActiveFedora::RdfObject
|
26
26
|
rdf_type MADS.TopicElement
|
27
|
-
map_predicates do |map|
|
28
|
-
map.elementValue(:in
|
27
|
+
map_predicates do |map|
|
28
|
+
map.elementValue(:in=> MADS)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
class TemporalElement
|
32
32
|
include ActiveFedora::RdfObject
|
33
33
|
rdf_type MADS.TemporalElement
|
34
|
-
map_predicates do |map|
|
35
|
-
map.elementValue(:in
|
34
|
+
map_predicates do |map|
|
35
|
+
map.elementValue(:in=> MADS)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -43,41 +43,41 @@ describe ActiveFedora::RdfList do
|
|
43
43
|
Object.send(:remove_const, :MADS)
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
47
|
-
let (:ds) { DemoList.new(double('inner object', :pid
|
46
|
+
describe "a new list" do
|
47
|
+
let (:ds) { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata')}
|
48
48
|
subject { ds.elementList.build}
|
49
49
|
|
50
|
-
it
|
51
|
-
|
52
|
-
|
50
|
+
it "should insert at the end" do
|
51
|
+
subject.should be_kind_of DemoList::List
|
52
|
+
subject.size.should == 0
|
53
53
|
subject[1] = DemoList::List::TopicElement.new(subject.graph)
|
54
|
-
|
54
|
+
subject.size.should == 2
|
55
55
|
end
|
56
56
|
|
57
|
-
it
|
58
|
-
|
59
|
-
|
57
|
+
it "should insert at the head" do
|
58
|
+
subject.should be_kind_of DemoList::List
|
59
|
+
subject.size.should == 0
|
60
60
|
subject[0] = DemoList::List::TopicElement.new(subject.graph)
|
61
|
-
|
61
|
+
subject.size.should == 1
|
62
62
|
end
|
63
63
|
|
64
|
-
describe
|
64
|
+
describe "that has 4 elements" do
|
65
65
|
before do
|
66
66
|
subject[3] = DemoList::List::TopicElement.new(subject.graph)
|
67
|
-
|
67
|
+
subject.size.should == 4
|
68
68
|
end
|
69
|
-
it
|
69
|
+
it "should insert in the middle" do
|
70
70
|
subject[1] = DemoList::List::TopicElement.new(subject.graph)
|
71
|
-
|
71
|
+
subject.size.should == 4
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe
|
76
|
-
it
|
77
|
-
subject[0] = RDF::URI.new
|
75
|
+
describe "return updated xml" do
|
76
|
+
it "should be built" do
|
77
|
+
subject[0] = RDF::URI.new "http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"
|
78
78
|
subject[1] = DemoList::List::TopicElement.new(ds.graph)
|
79
|
-
subject[1].elementValue =
|
80
|
-
subject[2] = RDF::URI.new
|
79
|
+
subject[1].elementValue = "Relations with Mexican Americans"
|
80
|
+
subject[2] = RDF::URI.new "http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"
|
81
81
|
subject[3] = DemoList::List::TemporalElement.new(ds.graph)
|
82
82
|
subject[3].elementValue = "20th century"
|
83
83
|
doc = Nokogiri::XML(ds.content)
|
@@ -94,40 +94,40 @@ describe ActiveFedora::RdfList do
|
|
94
94
|
|
95
95
|
end
|
96
96
|
|
97
|
-
describe
|
98
|
-
subject { DemoList.new(double('inner object', :pid
|
99
|
-
it
|
100
|
-
|
97
|
+
describe "an empty list" do
|
98
|
+
subject { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true)).elementList.build }
|
99
|
+
it "should have to_ary" do
|
100
|
+
subject.to_ary.should == []
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
describe
|
105
|
-
let(:ds) { DemoList.new(double('inner object', :pid
|
106
|
-
let(:list) { ds.elementList.build }
|
104
|
+
describe "a list that has a constructed element" do
|
105
|
+
let(:ds) { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true)) }
|
106
|
+
let(:list) { ds.elementList.build }
|
107
107
|
let!(:topic) { list.topicElement.build }
|
108
|
-
|
109
|
-
it
|
110
|
-
|
111
|
-
|
108
|
+
|
109
|
+
it "should have to_ary" do
|
110
|
+
list.to_ary.size.should == 1
|
111
|
+
list.to_ary.first.class.should == DemoList::List::TopicElement
|
112
112
|
end
|
113
113
|
|
114
|
-
it
|
114
|
+
it "should be able to be cleared" do
|
115
115
|
list.topicElement.build
|
116
116
|
list.topicElement.build
|
117
117
|
list.topicElement.build
|
118
|
-
|
118
|
+
list.size.should == 4
|
119
119
|
list.clear
|
120
|
-
|
120
|
+
list.size.should == 0
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
describe
|
124
|
+
describe "a list with content" do
|
125
125
|
subject do
|
126
|
-
subject = DemoList.new(double('inner object', :pid
|
127
|
-
subject.content
|
126
|
+
subject = DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMetadata')
|
127
|
+
subject.content =<<END
|
128
128
|
<rdf:RDF
|
129
129
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mads="http://www.loc.gov/mads/rdf/v1#">
|
130
|
-
|
130
|
+
|
131
131
|
<mads:ComplexSubject rdf:about="info:fedora/foo">
|
132
132
|
<mads:elementList rdf:parseType="Collection">
|
133
133
|
<rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"/>
|
@@ -145,35 +145,35 @@ END
|
|
145
145
|
|
146
146
|
subject
|
147
147
|
end
|
148
|
-
it
|
149
|
-
|
148
|
+
it "should have a subject" do
|
149
|
+
subject.rdf_subject.to_s.should == "info:fedora/foo"
|
150
150
|
end
|
151
151
|
|
152
152
|
let (:list) { subject.elementList.first }
|
153
153
|
|
154
|
-
it
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
154
|
+
it "should have fields" do
|
155
|
+
list.first.should == "http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"
|
156
|
+
list[1].should be_kind_of DemoList::List::TopicElement
|
157
|
+
list[1].elementValue.should == ["Relations with Mexican Americans"]
|
158
|
+
list[2].should == "http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"
|
159
|
+
list[3].should be_kind_of DemoList::List::TemporalElement
|
160
|
+
list[3].elementValue.should == ["20th century"]
|
161
161
|
end
|
162
162
|
|
163
|
-
it
|
163
|
+
it "should have each" do
|
164
164
|
foo = []
|
165
165
|
list.each { |n| foo << n.class }
|
166
|
-
|
166
|
+
foo.should == [RDF::URI, DemoList::List::TopicElement, RDF::URI, DemoList::List::TemporalElement]
|
167
167
|
end
|
168
168
|
|
169
|
-
it
|
169
|
+
it "should have to_ary" do
|
170
170
|
ary = list.to_ary
|
171
|
-
|
172
|
-
|
171
|
+
ary.size.should == 4
|
172
|
+
ary[1].elementValue.should == ['Relations with Mexican Americans']
|
173
173
|
end
|
174
174
|
|
175
|
-
it
|
176
|
-
|
175
|
+
it "should have size" do
|
176
|
+
list.size.should == 4
|
177
177
|
end
|
178
178
|
|
179
179
|
it "should update fields" do
|
@@ -189,3 +189,4 @@ END
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
end
|
192
|
+
|
data/spec/unit/rdf_node_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::RdfNode do
|
4
|
-
describe
|
4
|
+
describe "inheritance" do
|
5
5
|
before do
|
6
6
|
class Parent
|
7
7
|
include ActiveFedora::RdfObject
|
@@ -22,14 +22,14 @@ describe ActiveFedora::RdfNode do
|
|
22
22
|
Object.send(:remove_const, :Parent)
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
26
|
-
it
|
27
|
-
|
25
|
+
describe "child class" do
|
26
|
+
it "should inherit the terms" do
|
27
|
+
Child.config.keys.should == ['title', 'description']
|
28
28
|
end
|
29
29
|
end
|
30
|
-
describe
|
31
|
-
it
|
32
|
-
|
30
|
+
describe "parent class" do
|
31
|
+
it "should not be infected with the child terms" do
|
32
|
+
Parent.config.keys.should == ['title']
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|