active-fedora 7.0.0.rc2 → 7.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -3
- data/CONTRIBUTORS.md +1 -0
- data/Gemfile +2 -3
- data/active-fedora.gemspec +4 -3
- data/gemfiles/rails3.gemfile +1 -7
- data/gemfiles/rails4.1.gemfile +5 -0
- data/gemfiles/rails4.gemfile +1 -6
- data/lib/active_fedora.rb +6 -6
- data/lib/active_fedora/associations/association_scope.rb +1 -1
- data/lib/active_fedora/base.rb +2 -0
- data/lib/active_fedora/datastream.rb +29 -2
- data/lib/active_fedora/datastream_collections.rb +2 -2
- data/lib/active_fedora/datastream_hash.rb +1 -1
- data/lib/active_fedora/datastreams.rb +4 -23
- data/lib/active_fedora/file_configurator.rb +8 -7
- data/lib/active_fedora/om_datastream.rb +1 -1
- data/lib/active_fedora/rdf.rb +9 -0
- data/lib/active_fedora/rdf/configurable.rb +59 -0
- data/lib/active_fedora/rdf/identifiable.rb +59 -0
- data/lib/active_fedora/rdf/indexing.rb +24 -23
- data/lib/active_fedora/rdf/list.rb +154 -0
- data/lib/active_fedora/{ntriples_rdf_datastream.rb → rdf/ntriples_rdf_datastream.rb} +0 -0
- data/lib/active_fedora/rdf/object_resource.rb +20 -0
- data/lib/active_fedora/rdf/properties.rb +108 -0
- data/lib/active_fedora/rdf/rdf_datastream.rb +113 -0
- data/lib/active_fedora/{rdfxml_rdf_datastream.rb → rdf/rdfxml_rdf_datastream.rb} +0 -0
- data/lib/active_fedora/rdf/repositories.rb +36 -0
- data/lib/active_fedora/rdf/resource.rb +324 -0
- data/lib/active_fedora/rdf/term.rb +188 -0
- data/lib/active_fedora/relation.rb +1 -0
- data/lib/active_fedora/relation/finder_methods.rb +16 -17
- data/lib/active_fedora/relation/merger.rb +1 -1
- data/lib/active_fedora/relation/query_methods.rb +13 -5
- data/lib/active_fedora/reload_on_save.rb +16 -0
- data/lib/active_fedora/rubydora_connection.rb +0 -1
- data/lib/active_fedora/sharding.rb +1 -1
- data/lib/active_fedora/version.rb +1 -1
- data/script/console +10 -11
- data/spec/config_helper.rb +1 -1
- data/spec/fixtures/solr_rdf_descMetadata.nt +1 -1
- data/spec/integration/auditable_spec.rb +1 -1
- data/spec/integration/base_spec.rb +21 -3
- data/spec/integration/complex_rdf_datastream_spec.rb +32 -55
- data/spec/integration/field_to_solr_name_spec.rb +6 -8
- data/spec/integration/has_many_associations_spec.rb +10 -3
- data/spec/integration/load_from_solr_spec.rb +15 -17
- data/spec/integration/ntriples_datastream_spec.rb +19 -23
- data/spec/integration/om_datastream_spec.rb +1 -1
- data/spec/integration/rdf_nested_attributes_spec.rb +51 -70
- data/spec/integration/relation_spec.rb +24 -11
- data/spec/integration/scoped_query_spec.rb +5 -1
- data/spec/samples/hydra-mods_article_datastream.rb +4 -0
- data/spec/samples/hydra-rights_metadata_datastream.rb +5 -0
- data/spec/samples/marpa-dc_datastream.rb +6 -1
- data/spec/samples/special_thing.rb +5 -5
- data/spec/spec_helper.rb +0 -3
- data/spec/support/an_active_model.rb +5 -12
- data/spec/unit/active_fedora_spec.rb +2 -2
- data/spec/unit/attributes_spec.rb +4 -8
- data/spec/unit/base_datastream_management_spec.rb +5 -29
- data/spec/unit/base_spec.rb +4 -0
- data/spec/unit/code_configurator_spec.rb +2 -2
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/core_spec.rb +2 -4
- data/spec/unit/datastream_spec.rb +15 -0
- data/spec/unit/datastreams_spec.rb +1 -12
- data/spec/unit/file_configurator_spec.rb +1 -1
- data/spec/unit/ntriples_datastream_spec.rb +52 -57
- data/spec/unit/om_datastream_spec.rb +3 -3
- data/spec/unit/query_spec.rb +3 -4
- data/spec/unit/rdf_configurable_spec.rb +37 -0
- data/spec/unit/rdf_datastream_spec.rb +5 -7
- data/spec/unit/rdf_list_nested_attributes_spec.rb +22 -36
- data/spec/unit/rdf_list_spec.rb +26 -38
- data/spec/unit/rdf_properties_spec.rb +70 -0
- data/spec/unit/rdf_repositories_spec.rb +28 -0
- data/spec/unit/rdf_resource_datastream_spec.rb +287 -0
- data/spec/unit/rdf_resource_spec.rb +341 -0
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +10 -26
- data/spec/unit/reload_on_save_spec.rb +24 -0
- data/spec/unit/solr_service_spec.rb +3 -3
- metadata +45 -16
- data/lib/active_fedora/rdf_datastream.rb +0 -113
- data/lib/active_fedora/rdf_list.rb +0 -162
- data/lib/active_fedora/rdf_node.rb +0 -332
- data/lib/active_fedora/rdf_node/term_proxy.rb +0 -141
- data/lib/active_fedora/rdf_object.rb +0 -24
- data/lib/active_fedora/yaml_adaptor.rb +0 -12
- data/spec/unit/rdf_node_spec.rb +0 -36
data/spec/unit/query_spec.rb
CHANGED
@@ -119,7 +119,6 @@ describe ActiveFedora::Base do
|
|
119
119
|
}.and_return('response'=>{'docs'=>mock_docs})
|
120
120
|
SpecModel::Basic.find({:foo=>'bar', :baz=>['quix','quack']}, :sort=>'title_t desc').should == ["Fake Object1", "Fake Object2"]
|
121
121
|
end
|
122
|
-
|
123
122
|
end
|
124
123
|
end
|
125
124
|
|
@@ -203,7 +202,7 @@ describe ActiveFedora::Base do
|
|
203
202
|
|
204
203
|
it "should count without a class specified" do
|
205
204
|
mock_result = {'response'=>{'numFound'=>7}}
|
206
|
-
ActiveFedora::SolrService.should_receive(:query).with("foo:bar", :rows=>0, :raw=>true).and_return(mock_result)
|
205
|
+
ActiveFedora::SolrService.should_receive(:query).with("(foo:bar)", :rows=>0, :raw=>true).and_return(mock_result)
|
207
206
|
ActiveFedora::Base.count(:conditions=>'foo:bar').should == 7
|
208
207
|
end
|
209
208
|
end
|
@@ -283,9 +282,9 @@ describe ActiveFedora::Base do
|
|
283
282
|
ActiveFedora::SolrService.should_receive(:query).with('baz:quack', {:sort => [@sort_query]}).and_return(mock_result)
|
284
283
|
ActiveFedora::Base.find_with_conditions(:baz=>'quack').should == mock_result
|
285
284
|
end
|
286
|
-
it "should use the query string if it's provided" do
|
285
|
+
it "should use the query string if it's provided and wrap it in parentheses" do
|
287
286
|
mock_result = double('Result')
|
288
|
-
ActiveFedora::SolrService.should_receive(:query).with('chunky:monkey', {:sort => [@sort_query]}).and_return(mock_result)
|
287
|
+
ActiveFedora::SolrService.should_receive(:query).with('(chunky:monkey)', {:sort => [@sort_query]}).and_return(mock_result)
|
289
288
|
ActiveFedora::Base.find_with_conditions('chunky:monkey').should == mock_result
|
290
289
|
end
|
291
290
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe ActiveFedora::Rdf::Configurable do
|
3
|
+
before do
|
4
|
+
class DummyConfigurable
|
5
|
+
extend ActiveFedora::Rdf::Configurable
|
6
|
+
end
|
7
|
+
end
|
8
|
+
after do
|
9
|
+
Object.send(:remove_const, "DummyConfigurable")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#configure' do
|
13
|
+
before do
|
14
|
+
DummyConfigurable.configure :base_uri => "http://example.org/base", :type => RDF.Class, :rdf_label => RDF::DC.title
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should set a base uri' do
|
18
|
+
expect(DummyConfigurable.base_uri).to eq "http://example.org/base"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should set an rdf_label' do
|
22
|
+
expect(DummyConfigurable.rdf_label).to eq RDF::DC.title
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should set a type' do
|
26
|
+
expect(DummyConfigurable.type).to eq RDF.Class
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#rdf_type' do
|
31
|
+
it "should set the type the old way" do
|
32
|
+
DummyConfigurable.should_receive(:configure).with(:type => RDF.Class).and_call_original
|
33
|
+
DummyConfigurable.rdf_type(RDF.Class)
|
34
|
+
expect(DummyConfigurable.type).to eq RDF.Class
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -7,12 +7,10 @@ describe ActiveFedora::RDFDatastream do
|
|
7
7
|
its(:content_changed?) { should be_false}
|
8
8
|
end
|
9
9
|
describe "an instance that exists in the datastore, but hasn't been loaded" do
|
10
|
-
before do
|
10
|
+
before do
|
11
11
|
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
12
|
-
|
13
|
-
|
14
|
-
map.description(in: RDF::DC, multivalue: false)
|
15
|
-
end
|
12
|
+
property :title, :predicate => RDF::DC.title
|
13
|
+
property :description, :predicate => RDF::DC.description, :multivalue => false
|
16
14
|
end
|
17
15
|
class MyObj < ActiveFedora::Base
|
18
16
|
has_metadata 'descMetadata', type: MyDatastream
|
@@ -26,7 +24,7 @@ describe ActiveFedora::RDFDatastream do
|
|
26
24
|
Object.send(:remove_const, :MyDatastream)
|
27
25
|
Object.send(:remove_const, :MyObj)
|
28
26
|
end
|
29
|
-
subject { @obj.reload.descMetadata }
|
27
|
+
subject { @obj.reload.descMetadata }
|
30
28
|
it "should not load the descMetadata datastream when calling content_changed?" do
|
31
29
|
@obj.inner_object.repository.should_not_receive(:datastream_dissemination).with(hash_including(:dsid=>'descMetadata'))
|
32
30
|
subject.should_not be_content_changed
|
@@ -60,7 +58,7 @@ describe ActiveFedora::RDFDatastream do
|
|
60
58
|
# see https://github.com/ruby-rdf/rdf/issues/142
|
61
59
|
ds = ActiveFedora::NtriplesRDFDatastream.new
|
62
60
|
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
63
|
-
|
61
|
+
|
64
62
|
result = ds.deserialize(data)
|
65
63
|
result.dump(:ntriples).should == "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
66
64
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe ActiveFedora::
|
3
|
+
describe ActiveFedora::Rdf::List do
|
4
4
|
before :each do
|
5
5
|
class MADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
|
6
6
|
property :MADSScheme
|
@@ -14,39 +14,27 @@ describe ActiveFedora::RdfList do
|
|
14
14
|
property :hasExactExternalAuthority
|
15
15
|
end
|
16
16
|
|
17
|
-
class TopicElement
|
18
|
-
|
19
|
-
|
20
|
-
map_predicates do |map|
|
21
|
-
map.elementValue(:in=> MADS)
|
22
|
-
end
|
17
|
+
class TopicElement < ActiveFedora::Rdf::Resource
|
18
|
+
configure :type => MADS.TopicElement
|
19
|
+
property :elementValue, :predicate => MADS.elementValue
|
23
20
|
end
|
24
|
-
class TemporalElement
|
25
|
-
|
26
|
-
|
27
|
-
map_predicates do |map|
|
28
|
-
map.elementValue(:in=> MADS)
|
29
|
-
end
|
21
|
+
class TemporalElement < ActiveFedora::Rdf::Resource
|
22
|
+
configure :type => MADS.TemporalElement
|
23
|
+
property :elementValue, :predicate => MADS.elementValue
|
30
24
|
end
|
31
|
-
class ElementList
|
32
|
-
|
33
|
-
|
34
|
-
map_predicates do |map|
|
35
|
-
map.topicElement(:in=> MADS, :to =>"TopicElement", :class_name => "TopicElement")
|
36
|
-
map.temporalElement(:in=> MADS, :to =>"TemporalElement", :class_name => "TemporalElement")
|
37
|
-
end
|
25
|
+
class ElementList < ActiveFedora::Rdf::List
|
26
|
+
property :topicElement, :predicate => MADS.TopicElement, :class_name => 'TopicElement'
|
27
|
+
property :temporalElement, :predicate => MADS.TemporalElement, :class_name => 'TemporalElement'
|
38
28
|
accepts_nested_attributes_for :topicElement, :temporalElement
|
39
29
|
end
|
40
30
|
|
41
|
-
class Topic
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
map.externalAuthority(:in => MADS, :to => 'hasExactExternalAuthority')
|
49
|
-
end
|
31
|
+
class Topic < ActiveFedora::Rdf::Resource
|
32
|
+
configure :type => MADS.Topic
|
33
|
+
configure :base_uri => "http://example.org/id_namespace#"
|
34
|
+
property :name, :predicate => MADS.authoritativeLabel
|
35
|
+
property :elementList, :predicate => MADS.elementList, :class_name => 'ElementList'
|
36
|
+
property :externalAuthority, :predicate => MADS.hasExactExternalAuthority
|
37
|
+
|
50
38
|
accepts_nested_attributes_for :elementList
|
51
39
|
end
|
52
40
|
end
|
@@ -57,7 +45,7 @@ describe ActiveFedora::RdfList do
|
|
57
45
|
Object.send(:remove_const, :TemporalElement)
|
58
46
|
Object.send(:remove_const, :MADS)
|
59
47
|
end
|
60
|
-
|
48
|
+
|
61
49
|
describe "nested_attributes" do
|
62
50
|
it "should insert new nodes into RdfLists (rather than calling .build)" do
|
63
51
|
params = {
|
@@ -70,9 +58,8 @@ describe ActiveFedora::RdfList do
|
|
70
58
|
}
|
71
59
|
}
|
72
60
|
|
73
|
-
topic = Topic.new
|
61
|
+
topic = Topic.new
|
74
62
|
topic.attributes = params[:topic]
|
75
|
-
# puts topic.graph.dump(:ntriples)
|
76
63
|
topic.elementList.first.size.should == 2
|
77
64
|
topic.elementList.first[0].should be_kind_of(TopicElement)
|
78
65
|
topic.elementList.first[0].elementValue.should == ["Baseball"]
|
@@ -80,10 +67,10 @@ describe ActiveFedora::RdfList do
|
|
80
67
|
topic.elementList.first[1].elementValue.should == ["Football"]
|
81
68
|
|
82
69
|
# only one rdf:rest rdf:nil
|
83
|
-
topic.
|
70
|
+
topic.query([nil, RDF.rest, RDF.nil]).size.should == 1
|
84
71
|
end
|
85
72
|
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.
|
73
|
+
# It's Not clear what the syntax should be when an RDF list contains multiple types of sub-nodes.
|
87
74
|
# This is a guess, which currently works.
|
88
75
|
params = {
|
89
76
|
topic: {
|
@@ -96,9 +83,8 @@ describe ActiveFedora::RdfList do
|
|
96
83
|
}
|
97
84
|
}
|
98
85
|
|
99
|
-
topic = Topic.new
|
86
|
+
topic = Topic.new
|
100
87
|
topic.attributes = params[:topic]
|
101
|
-
# puts topic.graph.dump(:ntriples)
|
102
88
|
topic.elementList.first.size.should == 4
|
103
89
|
topic.elementList.first[0].should be_kind_of(TopicElement)
|
104
90
|
topic.elementList.first[0].elementValue.should == ["Baseball"]
|
data/spec/unit/rdf_list_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe ActiveFedora::
|
3
|
+
describe ActiveFedora::Rdf::List do
|
4
4
|
before :each do
|
5
5
|
class MADS < RDF::Vocabulary("http://www.loc.gov/mads/rdf/v1#")
|
6
6
|
property :complexSubject
|
@@ -11,29 +11,18 @@ describe ActiveFedora::RdfList do
|
|
11
11
|
property :TemporalElement
|
12
12
|
end
|
13
13
|
class DemoList < ActiveFedora::RdfxmlRDFDatastream
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
property :elementList, :predicate => MADS.elementList, :class_name => 'DemoList::List'
|
15
|
+
class List < ActiveFedora::Rdf::List
|
16
|
+
property :topicElement, :predicate => MADS.TopicElement, :class_name => 'DemoList::List::TopicElement'
|
17
|
+
property :temporalElement, :predicate => MADS.TemporalElement, :class_name => 'DemoList::List::TemporalElement'
|
18
|
+
|
19
|
+
class TopicElement < ActiveFedora::Rdf::Resource
|
20
|
+
configure :type => MADS.TopicElement
|
21
|
+
property :elementValue, :predicate => MADS.elementValue
|
22
22
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
rdf_type MADS.TopicElement
|
27
|
-
map_predicates do |map|
|
28
|
-
map.elementValue(:in=> MADS)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
class TemporalElement
|
32
|
-
include ActiveFedora::RdfObject
|
33
|
-
rdf_type MADS.TemporalElement
|
34
|
-
map_predicates do |map|
|
35
|
-
map.elementValue(:in=> MADS)
|
36
|
-
end
|
23
|
+
class TemporalElement < ActiveFedora::Rdf::Resource
|
24
|
+
configure :type => MADS.TemporalElement
|
25
|
+
property :elementValue, :predicate => MADS.elementValue
|
37
26
|
end
|
38
27
|
end
|
39
28
|
end
|
@@ -50,24 +39,24 @@ describe ActiveFedora::RdfList do
|
|
50
39
|
it "should insert at the end" do
|
51
40
|
subject.should be_kind_of DemoList::List
|
52
41
|
subject.size.should == 0
|
53
|
-
subject[1] = DemoList::List::TopicElement.new
|
42
|
+
subject[1] = DemoList::List::TopicElement.new
|
54
43
|
subject.size.should == 2
|
55
44
|
end
|
56
45
|
|
57
46
|
it "should insert at the head" do
|
58
47
|
subject.should be_kind_of DemoList::List
|
59
48
|
subject.size.should == 0
|
60
|
-
subject[0] = DemoList::List::TopicElement.new
|
49
|
+
subject[0] = DemoList::List::TopicElement.new
|
61
50
|
subject.size.should == 1
|
62
51
|
end
|
63
52
|
|
64
53
|
describe "that has 4 elements" do
|
65
54
|
before do
|
66
|
-
subject[3] = DemoList::List::TopicElement.new
|
55
|
+
subject[3] = DemoList::List::TopicElement.new
|
67
56
|
subject.size.should == 4
|
68
57
|
end
|
69
58
|
it "should insert in the middle" do
|
70
|
-
subject[1] = DemoList::List::TopicElement.new
|
59
|
+
subject[1] = DemoList::List::TopicElement.new
|
71
60
|
subject.size.should == 4
|
72
61
|
end
|
73
62
|
end
|
@@ -75,11 +64,12 @@ describe ActiveFedora::RdfList do
|
|
75
64
|
describe "return updated xml" do
|
76
65
|
it "should be built" do
|
77
66
|
subject[0] = RDF::URI.new "http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"
|
78
|
-
subject[1] = DemoList::List::TopicElement.new
|
67
|
+
subject[1] = DemoList::List::TopicElement.new
|
79
68
|
subject[1].elementValue = "Relations with Mexican Americans"
|
80
69
|
subject[2] = RDF::URI.new "http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"
|
81
|
-
subject[3] = DemoList::List::TemporalElement.new
|
70
|
+
subject[3] = DemoList::List::TemporalElement.new
|
82
71
|
subject[3].elementValue = "20th century"
|
72
|
+
ds.elementList = subject
|
83
73
|
doc = Nokogiri::XML(ds.content)
|
84
74
|
ns = {rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#", mads: "http://www.loc.gov/mads/rdf/v1#"}
|
85
75
|
expect(doc.xpath('/rdf:RDF/rdf:Description/@rdf:about', ns).map(&:value)).to eq ["info:fedora/foo"]
|
@@ -90,22 +80,20 @@ describe ActiveFedora::RdfList do
|
|
90
80
|
expect(doc.xpath('//rdf:Description/mads:elementList/*[position() = 4]/mads:elementValue', ns).map(&:text)).to eq ["20th century"]
|
91
81
|
end
|
92
82
|
end
|
93
|
-
|
94
|
-
|
95
83
|
end
|
96
84
|
|
97
85
|
describe "an empty list" do
|
98
|
-
subject { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true)).elementList.build }
|
86
|
+
subject { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMd').elementList.build }
|
99
87
|
it "should have to_ary" do
|
100
88
|
subject.to_ary.should == []
|
101
89
|
end
|
102
90
|
end
|
103
91
|
|
104
92
|
describe "a list that has a constructed element" do
|
105
|
-
let(:ds) { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true)) }
|
93
|
+
let(:ds) { DemoList.new(double('inner object', :pid=>'foo', :new_record? =>true), 'descMd') }
|
106
94
|
let(:list) { ds.elementList.build }
|
107
95
|
let!(:topic) { list.topicElement.build }
|
108
|
-
|
96
|
+
|
109
97
|
it "should have to_ary" do
|
110
98
|
list.to_ary.size.should == 1
|
111
99
|
list.to_ary.first.class.should == DemoList::List::TopicElement
|
@@ -127,7 +115,7 @@ describe ActiveFedora::RdfList do
|
|
127
115
|
subject.content =<<END
|
128
116
|
<rdf:RDF
|
129
117
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mads="http://www.loc.gov/mads/rdf/v1#">
|
130
|
-
|
118
|
+
|
131
119
|
<mads:ComplexSubject rdf:about="info:fedora/foo">
|
132
120
|
<mads:elementList rdf:parseType="Collection">
|
133
121
|
<rdf:Description rdf:about="http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"/>
|
@@ -152,10 +140,10 @@ END
|
|
152
140
|
let (:list) { subject.elementList.first }
|
153
141
|
|
154
142
|
it "should have fields" do
|
155
|
-
list.first.should == "http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"
|
143
|
+
list.first.rdf_subject.should == "http://library.ucsd.edu/ark:/20775/bbXXXXXXX6"
|
156
144
|
list[1].should be_kind_of DemoList::List::TopicElement
|
157
145
|
list[1].elementValue.should == ["Relations with Mexican Americans"]
|
158
|
-
list[2].should == "http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"
|
146
|
+
list[2].rdf_subject.should == "http://library.ucsd.edu/ark:/20775/bbXXXXXXX4"
|
159
147
|
list[3].should be_kind_of DemoList::List::TemporalElement
|
160
148
|
list[3].elementValue.should == ["20th century"]
|
161
149
|
end
|
@@ -163,7 +151,7 @@ END
|
|
163
151
|
it "should have each" do
|
164
152
|
foo = []
|
165
153
|
list.each { |n| foo << n.class }
|
166
|
-
foo.should == [
|
154
|
+
foo.should == [ActiveFedora::Rdf::Resource, DemoList::List::TopicElement, ActiveFedora::Rdf::Resource, DemoList::List::TemporalElement]
|
167
155
|
end
|
168
156
|
|
169
157
|
it "should have to_ary" do
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe ActiveFedora::Rdf::Properties do
|
3
|
+
before do
|
4
|
+
class DummyProperties
|
5
|
+
extend ActiveFedora::Rdf::Properties
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
Object.send(:remove_const, "DummyProperties")
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#map_predicates' do
|
14
|
+
before do
|
15
|
+
DummyProperties.map_predicates do |map|
|
16
|
+
map.title(:in => RDF::DC, :class_name => RDF::Literal) do |index|
|
17
|
+
index.as :facetable, :searchable
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should set a property' do
|
23
|
+
expect(DummyProperties.properties).to include :title
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should set index behaviors" do
|
27
|
+
expect(DummyProperties.properties[:title][:behaviors]).to eq [:facetable, :searchable]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should set a class name" do
|
31
|
+
expect(DummyProperties.properties[:title][:class_name]).to eq RDF::Literal
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#property' do
|
36
|
+
it 'should set a property' do
|
37
|
+
DummyProperties.property :title, :predicate => RDF::DC.title
|
38
|
+
expect(DummyProperties.properties).to include :title
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should set index behaviors' do
|
42
|
+
DummyProperties.property :title, :predicate => RDF::DC.title do |index|
|
43
|
+
index.as :facetable, :searchable
|
44
|
+
end
|
45
|
+
expect(DummyProperties.properties[:title][:behaviors]).to eq [:facetable, :searchable]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should set class name' do
|
49
|
+
DummyProperties.property :title, :predicate => RDF::DC.title, :class_name => RDF::Literal
|
50
|
+
expect(DummyProperties.properties[:title][:class_name]).to eq RDF::Literal
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "when using a subclass" do
|
55
|
+
before do
|
56
|
+
DummyProperties.property :title, :predicate => RDF::DC.title
|
57
|
+
class DummySubClass < DummyProperties
|
58
|
+
property :source, :predicate => RDF::DC11[:source]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
after do
|
63
|
+
Object.send(:remove_const, "DummySubClass")
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should carry properties from superclass' do
|
67
|
+
expect(DummySubClass.properties.keys).to eq ["title", "source"]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe ActiveFedora::Rdf::Repositories do
|
3
|
+
subject {ActiveFedora::Rdf::Repositories}
|
4
|
+
|
5
|
+
after(:each) do
|
6
|
+
subject.clear_repositories!
|
7
|
+
subject.add_repository :default, RDF::Repository.new
|
8
|
+
subject.add_repository :vocabs, RDF::Repository.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#add_repositories' do
|
12
|
+
it 'should accept a new repository' do
|
13
|
+
subject.add_repository :name, RDF::Repository.new
|
14
|
+
expect(subject.repositories).to include :name
|
15
|
+
end
|
16
|
+
it 'should throw an error if passed something that is not a repository' do
|
17
|
+
expect{subject.add_repository :name, :not_a_repo}.to raise_error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#clear_repositories!' do
|
22
|
+
it 'should empty the repositories list' do
|
23
|
+
subject.clear_repositories!
|
24
|
+
expect(subject.repositories).to be_empty
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|