active-fedora 8.2.1 → 8.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/active-fedora.gemspec +1 -2
- data/lib/active_fedora/datastream_collections.rb +4 -8
- data/lib/active_fedora/datastreams.rb +7 -9
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +3 -3
- data/spec/integration/associations_spec.rb +76 -76
- data/spec/integration/auditable_spec.rb +7 -7
- data/spec/integration/autosave_association_spec.rb +3 -3
- data/spec/integration/base_spec.rb +51 -51
- data/spec/integration/belongs_to_association_spec.rb +27 -27
- data/spec/integration/bug_spec.rb +1 -1
- data/spec/integration/collection_association_spec.rb +2 -2
- data/spec/integration/complex_rdf_datastream_spec.rb +32 -32
- data/spec/integration/datastream_collections_spec.rb +42 -42
- data/spec/integration/datastream_spec.rb +19 -19
- data/spec/integration/datastreams_spec.rb +25 -25
- data/spec/integration/delete_all_spec.rb +5 -5
- data/spec/integration/fedora_solr_sync_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +9 -9
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +46 -47
- data/spec/integration/has_many_associations_spec.rb +17 -17
- data/spec/integration/json_serialization_spec.rb +2 -2
- data/spec/integration/load_from_solr_spec.rb +1 -1
- data/spec/integration/model_spec.rb +9 -9
- data/spec/integration/nested_attribute_spec.rb +17 -17
- data/spec/integration/ntriples_datastream_spec.rb +43 -43
- data/spec/integration/om_datastream_spec.rb +37 -37
- data/spec/integration/persistence_spec.rb +1 -1
- data/spec/integration/rdf_nested_attributes_spec.rb +9 -9
- data/spec/integration/relation_delegation_spec.rb +7 -7
- data/spec/integration/relation_spec.rb +2 -2
- data/spec/integration/rels_ext_datastream_spec.rb +3 -3
- data/spec/integration/scoped_query_spec.rb +14 -14
- data/spec/integration/solr_service_spec.rb +24 -24
- data/spec/support/mock_fedora.rb +9 -10
- data/spec/unit/active_fedora_spec.rb +20 -20
- data/spec/unit/attributes_spec.rb +24 -24
- data/spec/unit/base_active_model_spec.rb +6 -6
- data/spec/unit/base_cma_spec.rb +2 -2
- data/spec/unit/base_datastream_management_spec.rb +7 -7
- data/spec/unit/base_extra_spec.rb +20 -20
- data/spec/unit/base_spec.rb +141 -141
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
- data/spec/unit/callback_spec.rb +12 -12
- data/spec/unit/code_configurator_spec.rb +7 -7
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/content_model_spec.rb +19 -20
- data/spec/unit/core_spec.rb +1 -1
- data/spec/unit/datastream_collections_spec.rb +101 -101
- data/spec/unit/datastream_spec.rb +12 -12
- data/spec/unit/datastreams_spec.rb +39 -39
- data/spec/unit/file_configurator_spec.rb +117 -117
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +16 -16
- data/spec/unit/has_many_collection_spec.rb +5 -5
- data/spec/unit/inheritance_spec.rb +5 -5
- data/spec/unit/model_spec.rb +5 -5
- data/spec/unit/nom_datastream_spec.rb +5 -5
- data/spec/unit/ntriples_datastream_spec.rb +56 -56
- data/spec/unit/om_datastream_spec.rb +99 -99
- data/spec/unit/persistence_spec.rb +2 -2
- data/spec/unit/predicates_spec.rb +28 -28
- data/spec/unit/property_spec.rb +5 -5
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +10 -10
- data/spec/unit/query_spec.rb +66 -66
- data/spec/unit/rdf_datastream_spec.rb +10 -10
- data/spec/unit/rdf_resource_datastream_spec.rb +2 -2
- data/spec/unit/rdf_xml_writer_spec.rb +3 -3
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +9 -9
- data/spec/unit/relationship_graph_spec.rb +31 -31
- data/spec/unit/reload_on_save_spec.rb +3 -3
- data/spec/unit/rels_ext_datastream_spec.rb +28 -28
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +7 -7
- data/spec/unit/rubydora_connection_spec.rb +3 -3
- data/spec/unit/semantic_node_spec.rb +17 -17
- data/spec/unit/serializers_spec.rb +1 -1
- data/spec/unit/service_definitions_spec.rb +11 -11
- data/spec/unit/simple_datastream_spec.rb +6 -6
- data/spec/unit/solr_config_options_spec.rb +10 -10
- data/spec/unit/solr_digital_object_spec.rb +4 -4
- data/spec/unit/solr_service_spec.rb +41 -41
- data/spec/unit/unsaved_digital_object_spec.rb +8 -8
- data/spec/unit/validations_spec.rb +6 -6
- metadata +4 -4
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe ActiveFedora::RDFDatastream do
|
5
5
|
describe "a new instance" do
|
6
|
-
its(:metadata?) { should
|
7
|
-
its(:content_changed?) { should
|
6
|
+
its(:metadata?) { should be_truthy}
|
7
|
+
its(:content_changed?) { should be_falsey}
|
8
8
|
end
|
9
9
|
describe "an instance that exists in the datastore, but hasn't been loaded" do
|
10
10
|
before do
|
@@ -27,30 +27,30 @@ describe ActiveFedora::RDFDatastream do
|
|
27
27
|
end
|
28
28
|
subject { @obj.descMetadata }
|
29
29
|
it "should not load the descMetadata datastream when calling content_changed?" do
|
30
|
-
@obj.inner_object.repository.
|
31
|
-
subject.
|
30
|
+
expect(@obj.inner_object.repository).not_to receive(:datastream_dissemination).with(hash_including(:dsid=>'descMetadata'))
|
31
|
+
expect(subject).not_to be_content_changed
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should allow asserting an empty string" do
|
35
35
|
subject.title = ['']
|
36
|
-
subject.title.
|
36
|
+
expect(subject.title).to eq([''])
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "when multivalue: false" do
|
40
40
|
it "should return single values" do
|
41
41
|
subject.description = 'my description'
|
42
|
-
subject.description.
|
42
|
+
expect(subject.description).to eq('my description')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should clear stuff" do
|
47
47
|
subject.title = ['one', 'two', 'three']
|
48
48
|
subject.title.clear
|
49
|
-
subject.graph.query([subject.rdf_subject, RDF::DC.title, nil]).first.
|
49
|
+
expect(subject.graph.query([subject.rdf_subject, RDF::DC.title, nil]).first).to be_nil
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should have a list of fields" do
|
53
|
-
MyDatastream.fields.
|
53
|
+
expect(MyDatastream.fields).to eq([:title, :description])
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -98,8 +98,8 @@ describe ActiveFedora::RDFDatastream do
|
|
98
98
|
describe 'legacy non-utf-8 characters' do
|
99
99
|
let(:ds) do
|
100
100
|
datastream = ActiveFedora::NtriplesRDFDatastream.new
|
101
|
-
datastream.
|
102
|
-
datastream.
|
101
|
+
allow(datastream).to receive(:new?).and_return(false)
|
102
|
+
allow(datastream).to receive(:datastream_content).and_return("<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT'))
|
103
103
|
datastream
|
104
104
|
end
|
105
105
|
it "should not error on access" do
|
@@ -159,7 +159,7 @@ describe ActiveFedora::RDFDatastream do
|
|
159
159
|
context "persisted to repository" do
|
160
160
|
before do
|
161
161
|
DummySubnode.configure :repository => :default
|
162
|
-
DummySubnode.
|
162
|
+
allow_any_instance_of(DummySubnode).to receive(:repository).and_return(RDF::Repository.new)
|
163
163
|
dummy = DummySubnode.new(RDF::URI('http://example.org/dummy/blah'))
|
164
164
|
dummy.title = ['subbla']
|
165
165
|
# We want to have to manually persist to the repository.
|
@@ -311,7 +311,7 @@ describe ActiveFedora::RDFDatastream do
|
|
311
311
|
end
|
312
312
|
|
313
313
|
it 'lets me specify a resource class' do
|
314
|
-
expect(DummyResource.resource_class < DummyATResource).to
|
314
|
+
expect(DummyResource.resource_class < DummyATResource).to eq true
|
315
315
|
end
|
316
316
|
|
317
317
|
it 'creates underlying resource of type resource_class' do
|
@@ -35,7 +35,7 @@ describe ActiveFedora::RDFXMLWriter do
|
|
35
35
|
writer << statement
|
36
36
|
end
|
37
37
|
end
|
38
|
-
content.
|
38
|
+
expect(content).to be_equivalent_to @rdf_xml_with_type
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should serialize graphs without rdf:type equivalently to RDF::RDFXML::Writer' do
|
@@ -57,7 +57,7 @@ describe ActiveFedora::RDFXMLWriter do
|
|
57
57
|
writer << statement
|
58
58
|
end
|
59
59
|
end
|
60
|
-
EquivalentXml.equivalent?(local_content, @rdf_xml).
|
61
|
-
EquivalentXml.equivalent?(local_content, generic_content).
|
60
|
+
expect(EquivalentXml.equivalent?(local_content, @rdf_xml)).to be_truthy
|
61
|
+
expect(EquivalentXml.equivalent?(local_content, generic_content)).to be_truthy
|
62
62
|
end
|
63
63
|
end
|
@@ -7,14 +7,14 @@ describe ActiveFedora::RdfxmlRDFDatastream do
|
|
7
7
|
property :publisher, :predicate => RDF::DC.publisher
|
8
8
|
end
|
9
9
|
@subject = MyRdfxmlDatastream.new(@inner_object, 'mixed_rdf')
|
10
|
-
@subject.
|
10
|
+
allow(@subject).to receive_messages(:pid => 'test:1')
|
11
11
|
end
|
12
12
|
after(:each) do
|
13
13
|
Object.send(:remove_const, :MyRdfxmlDatastream)
|
14
14
|
end
|
15
15
|
it "should save and reload" do
|
16
16
|
@subject.publisher = ["St. Martin's Press"]
|
17
|
-
@subject.serialize.
|
17
|
+
expect(@subject.serialize).to match(/<rdf:RDF/)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -79,7 +79,7 @@ describe ActiveFedora::RdfxmlRDFDatastream do
|
|
79
79
|
describe "a new instance" do
|
80
80
|
subject { MyDatastream.new(double('inner object', :pid=>'test:1', :new_record? =>true), 'descMetadata', about:"http://library.ucsd.edu/ark:/20775/") }
|
81
81
|
it "should have a subject" do
|
82
|
-
subject.rdf_subject.to_s.
|
82
|
+
expect(subject.rdf_subject.to_s).to eq("http://library.ucsd.edu/ark:/20775/")
|
83
83
|
end
|
84
84
|
|
85
85
|
end
|
@@ -91,20 +91,20 @@ describe ActiveFedora::RdfxmlRDFDatastream do
|
|
91
91
|
subject
|
92
92
|
end
|
93
93
|
it "should have a subject" do
|
94
|
-
subject.rdf_subject.to_s.
|
94
|
+
expect(subject.rdf_subject.to_s).to eq("http://library.ucsd.edu/ark:/20775/")
|
95
95
|
end
|
96
96
|
it "should have controlGroup" do
|
97
|
-
subject.controlGroup.
|
97
|
+
expect(subject.controlGroup).to eq('M')
|
98
98
|
end
|
99
99
|
it "should have mimeType" do
|
100
|
-
subject.mimeType.
|
100
|
+
expect(subject.mimeType).to eq('text/xml')
|
101
101
|
end
|
102
102
|
it "should have dsid" do
|
103
|
-
subject.dsid.
|
103
|
+
expect(subject.dsid).to eq('descMetadata')
|
104
104
|
end
|
105
105
|
it "should have fields" do
|
106
|
-
subject.resource_type.
|
107
|
-
subject.title.first.value.
|
106
|
+
expect(subject.resource_type).to eq(["image"])
|
107
|
+
expect(subject.title.first.value).to eq(["example title"])
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -4,17 +4,17 @@ describe ActiveFedora::RelationshipGraph do
|
|
4
4
|
before do
|
5
5
|
@graph = ActiveFedora::RelationshipGraph.new
|
6
6
|
@n1 = ActiveFedora::Base.new()
|
7
|
-
@n1.
|
7
|
+
allow(@n1).to receive_messages(:pid => 'foo:777')
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#relationships" do
|
11
11
|
it "should have hash accessors" do
|
12
|
-
@graph.
|
12
|
+
expect(@graph).to respond_to(:[])
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should initialize new relation keys" do
|
16
|
-
@graph[:has_description].
|
17
|
-
@graph[:has_description].
|
16
|
+
expect(@graph[:has_description]).to be_empty
|
17
|
+
expect(@graph[:has_description]).to respond_to(:<<)
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -22,94 +22,94 @@ describe ActiveFedora::RelationshipGraph do
|
|
22
22
|
it "should add relationships" do
|
23
23
|
@n2 = ActiveFedora::Base.new
|
24
24
|
@graph.add(:has_part, @n1)
|
25
|
-
@graph[:has_part].
|
25
|
+
expect(@graph[:has_part]).to eq([@n1])
|
26
26
|
@graph.add(:has_part, @n2)
|
27
|
-
@graph[:has_part].
|
27
|
+
expect(@graph[:has_part]).to eq([@n1, @n2])
|
28
28
|
@graph.add(:has_part, @n2)
|
29
|
-
@graph[:has_part].
|
30
|
-
@graph.dirty.
|
29
|
+
expect(@graph[:has_part]).to eq([@n1, @n2])
|
30
|
+
expect(@graph.dirty).to be_truthy
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should create a rdf graph" do
|
34
34
|
graph = @graph.to_graph('info:fedora/foo:1')
|
35
|
-
graph.
|
36
|
-
graph.statements.to_a.
|
35
|
+
expect(graph).to be_kind_of RDF::Graph
|
36
|
+
expect(graph.statements.to_a).to eq([])
|
37
37
|
|
38
38
|
@graph.add(:has_part, @n1)
|
39
39
|
graph = @graph.to_graph('info:fedora/foo:1')
|
40
40
|
stmts = graph.statements.to_a
|
41
|
-
stmts.size.
|
41
|
+
expect(stmts.size).to eq(1)
|
42
42
|
stmt = stmts.first
|
43
|
-
stmt.subject.to_s.
|
44
|
-
stmt.predicate.to_s.
|
45
|
-
stmt.object.to_s.
|
43
|
+
expect(stmt.subject.to_s).to eq('info:fedora/foo:1')
|
44
|
+
expect(stmt.predicate.to_s).to eq('info:fedora/fedora-system:def/relations-external#hasPart')
|
45
|
+
expect(stmt.object.to_s).to eq('info:fedora/foo:777')
|
46
46
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should have array accessor" do
|
50
50
|
@graph.add(:has_part, @n1)
|
51
|
-
@graph[:has_part].
|
51
|
+
expect(@graph[:has_part]).to eq([@n1])
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "has_predicate?" do
|
55
55
|
it "should return true when it has it" do
|
56
|
-
@graph.has_predicate?(:has_part).
|
56
|
+
expect(@graph.has_predicate?(:has_part)).to be_falsey
|
57
57
|
@graph.add(:has_part, @n1)
|
58
|
-
@graph.has_predicate?(:has_part).
|
58
|
+
expect(@graph.has_predicate?(:has_part)).to be_truthy
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
describe "delete" do
|
63
63
|
it "should delete an object when an object is passed" do
|
64
64
|
@graph.add(:has_part, @n1)
|
65
|
-
@graph[:has_part].
|
65
|
+
expect(@graph[:has_part]).to eq([@n1])
|
66
66
|
@graph.delete(:has_part, @n1)
|
67
|
-
@graph[:has_part].
|
67
|
+
expect(@graph[:has_part]).to eq([])
|
68
68
|
end
|
69
69
|
it "should delete an pid when an object is passed" do
|
70
70
|
#a reloaded rels-ext is just a list of uris, not inflated.
|
71
71
|
@graph.add(:has_part, 'info:fedora/foo:777')
|
72
|
-
@graph[:has_part].
|
72
|
+
expect(@graph[:has_part]).to eq(['info:fedora/foo:777'])
|
73
73
|
@graph.delete(:has_part, @n1)
|
74
|
-
@graph[:has_part].
|
74
|
+
expect(@graph[:has_part]).to eq([])
|
75
75
|
end
|
76
76
|
it "should delete an pid when a string is passed" do
|
77
77
|
#a reloaded rels-ext is just a list of uris, not inflated.
|
78
78
|
@graph.add(:has_part, 'info:fedora/foo:777')
|
79
|
-
@graph[:has_part].
|
79
|
+
expect(@graph[:has_part]).to eq(['info:fedora/foo:777'])
|
80
80
|
@graph.delete(:has_part, 'info:fedora/foo:777')
|
81
|
-
@graph[:has_part].
|
81
|
+
expect(@graph[:has_part]).to eq([])
|
82
82
|
end
|
83
83
|
it "should delete an object when a pid is passed" do
|
84
84
|
#a reloaded rels-ext is just a list of uris, not inflated.
|
85
85
|
@graph.add(:has_part, @n1)
|
86
|
-
@graph[:has_part].
|
86
|
+
expect(@graph[:has_part]).to eq([@n1])
|
87
87
|
@graph.delete(:has_part, 'info:fedora/foo:777')
|
88
|
-
@graph[:has_part].
|
88
|
+
expect(@graph[:has_part]).to eq([])
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should delete all the predicates if only one arg is passed" do
|
92
92
|
@graph.add(:has_part, @n1)
|
93
|
-
@graph[:has_part].
|
93
|
+
expect(@graph[:has_part]).to eq([@n1])
|
94
94
|
@graph.delete(:has_part)
|
95
|
-
@graph.has_predicate?(:has_part).
|
95
|
+
expect(@graph.has_predicate?(:has_part)).not_to be_truthy
|
96
96
|
end
|
97
97
|
end
|
98
98
|
describe "build_statement" do
|
99
99
|
it "should raise an error when the target is a pid, not a uri" do
|
100
|
-
|
100
|
+
expect { @graph.build_statement('info:fedora/spec:9', :is_part_of, 'spec:7') }.to raise_error ArgumentError
|
101
101
|
end
|
102
102
|
it "should run the happy path" do
|
103
103
|
stm = @graph.build_statement('info:fedora/spec:9', :is_part_of, 'info:fedora/spec:7')
|
104
|
-
stm.object.to_s.
|
104
|
+
expect(stm.object.to_s).to eq("info:fedora/spec:7")
|
105
105
|
end
|
106
106
|
it "should also be happy with non-info URIs" do
|
107
107
|
stm = @graph.build_statement('info:fedora/spec:9', :is_annotation_of, 'http://www.w3.org/standards/techs/rdf')
|
108
|
-
stm.object.to_s.
|
108
|
+
expect(stm.object.to_s).to eq("http://www.w3.org/standards/techs/rdf")
|
109
109
|
end
|
110
110
|
it "should also be happy with targets that are URI::Generics" do
|
111
111
|
stm = @graph.build_statement('info:fedora/spec:9', :is_annotation_of, URI.parse('http://www.w3.org/standards/techs/rdf'))
|
112
|
-
stm.object.to_s.
|
112
|
+
expect(stm.object.to_s).to eq("http://www.w3.org/standards/techs/rdf")
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -4,19 +4,19 @@ describe ActiveFedora::ReloadOnSave do
|
|
4
4
|
let(:file) { ActiveFedora::Base.new }
|
5
5
|
|
6
6
|
it 'defaults to call not reload' do
|
7
|
-
file.
|
7
|
+
expect(file).not_to receive(:reload)
|
8
8
|
file.save
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'reload can be turned on' do
|
12
12
|
file.reload_on_save = true
|
13
|
-
file.
|
13
|
+
expect(file).to receive(:reload)
|
14
14
|
file.save
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'allows reload to be turned off and on' do
|
18
18
|
file.reload_on_save = true
|
19
|
-
file.
|
19
|
+
expect(file).to receive(:reload).once
|
20
20
|
file.save
|
21
21
|
file.reload_on_save = false
|
22
22
|
file.save
|
@@ -10,30 +10,30 @@ describe ActiveFedora::RelsExtDatastream do
|
|
10
10
|
before(:each) do
|
11
11
|
mock_inner = double('inner object')
|
12
12
|
@mock_repo = double('repository')
|
13
|
-
@mock_repo.
|
14
|
-
mock_inner.
|
15
|
-
mock_inner.
|
13
|
+
allow(@mock_repo).to receive_messages(:datastream_dissemination=>'My Content', :config=>{})
|
14
|
+
allow(mock_inner).to receive(:repository).and_return(@mock_repo)
|
15
|
+
allow(mock_inner).to receive(:pid).and_return(@pid)
|
16
16
|
@test_ds = ActiveFedora::RelsExtDatastream.new(mock_inner, "RELS-EXT")
|
17
|
-
@test_ds.
|
17
|
+
allow(@test_ds).to receive(:profile).and_return({})
|
18
18
|
end
|
19
19
|
|
20
|
-
its(:metadata?) { should
|
20
|
+
its(:metadata?) { should be_truthy}
|
21
21
|
its(:controlGroup) { should == "X"}
|
22
22
|
|
23
23
|
describe "#mimeType" do
|
24
24
|
it 'should use the application/rdf+xml mime type' do
|
25
|
-
@test_ds.mimeType.
|
25
|
+
expect(@test_ds.mimeType).to eq('application/rdf+xml')
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "#changed?" do
|
30
30
|
it "should be false when no changes have been made" do
|
31
31
|
subject.model = double(:relationships_are_dirty? => false)
|
32
|
-
subject.changed
|
32
|
+
expect(subject.changed?).to eq(false)
|
33
33
|
end
|
34
34
|
it "should be true when the model has changes" do
|
35
35
|
subject.model = double(:relationships_are_dirty? => true)
|
36
|
-
subject.changed
|
36
|
+
expect(subject.changed?).to eq(true)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -45,9 +45,9 @@ describe ActiveFedora::RelsExtDatastream do
|
|
45
45
|
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
46
46
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('demo:10'))
|
47
47
|
|
48
|
-
@test_ds.
|
48
|
+
allow(@test_ds).to receive_messages(:new? => true, :relationships => graph, :model => double(:relationships_are_dirty? =>true, :relationships_are_not_dirty! => true))
|
49
49
|
@test_ds.serialize!
|
50
|
-
EquivalentXml.equivalent?(@test_ds.content, "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n <rdf:Description rdf:about='info:fedora/test:sample_pid'>\n <isMemberOf rdf:resource='demo:10' xmlns='info:fedora/fedora-system:def/relations-external#'/></rdf:Description>\n </rdf:RDF>").
|
50
|
+
expect(EquivalentXml.equivalent?(@test_ds.content, "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n <rdf:Description rdf:about='info:fedora/test:sample_pid'>\n <isMemberOf rdf:resource='demo:10' xmlns='info:fedora/fedora-system:def/relations-external#'/></rdf:Description>\n </rdf:RDF>")).to be_truthy
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
@@ -78,8 +78,8 @@ describe ActiveFedora::RelsExtDatastream do
|
|
78
78
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
|
79
79
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
|
80
80
|
|
81
|
-
@test_ds.
|
82
|
-
EquivalentXml.equivalent?(@test_ds.to_rels_ext(), @sample_rels_ext_xml).
|
81
|
+
expect(@test_ds).to receive(:model).and_return(double("model", :relationships=>graph, :relationships_are_dirty= => true))
|
82
|
+
expect(EquivalentXml.equivalent?(@test_ds.to_rels_ext(), @sample_rels_ext_xml)).to be_truthy
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'should use mapped namespace prefixes when given' do
|
@@ -91,21 +91,21 @@ describe ActiveFedora::RelsExtDatastream do
|
|
91
91
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
|
92
92
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
|
93
93
|
|
94
|
-
@test_ds.
|
94
|
+
allow(@test_ds).to receive(:model).and_return(double("model", :relationships=>graph, :relationships_are_dirty= => true))
|
95
95
|
rels = @test_ds.to_rels_ext()
|
96
|
-
EquivalentXml.equivalent?(rels, @sample_rels_ext_xml).
|
97
|
-
rels.
|
98
|
-
rels.
|
99
|
-
rels.
|
100
|
-
rels.
|
96
|
+
expect(EquivalentXml.equivalent?(rels, @sample_rels_ext_xml)).to be_truthy
|
97
|
+
expect(rels).not_to match(/fedora:isMemberOf/)
|
98
|
+
expect(rels).not_to match(/fedora-model:hasModel/)
|
99
|
+
expect(rels).to match(/ns\d:isMemberOf/)
|
100
|
+
expect(rels).to match(/ns\d:hasModel/)
|
101
101
|
|
102
102
|
ActiveFedora::Predicates.predicate_config[:predicate_namespaces] = {:"fedora-model"=>"info:fedora/fedora-system:def/model#", :fedora=>"info:fedora/fedora-system:def/relations-external#"}
|
103
103
|
rels = @test_ds.to_rels_ext()
|
104
|
-
EquivalentXml.equivalent?(rels, @sample_rels_ext_xml).
|
105
|
-
rels.
|
106
|
-
rels.
|
107
|
-
rels.
|
108
|
-
rels.
|
104
|
+
expect(EquivalentXml.equivalent?(rels, @sample_rels_ext_xml)).to be_truthy
|
105
|
+
expect(rels).to match(/fedora:isMemberOf/)
|
106
|
+
expect(rels).to match(/fedora-model:hasModel/)
|
107
|
+
expect(rels).not_to match(/ns\d:isMemberOf/)
|
108
|
+
expect(rels).not_to match(/ns\d:hasModel/)
|
109
109
|
ActiveFedora::Predicates.predicate_config[:predicate_namespaces] = nil
|
110
110
|
end
|
111
111
|
|
@@ -125,8 +125,8 @@ describe ActiveFedora::RelsExtDatastream do
|
|
125
125
|
it "should handle un-mapped predicates gracefully" do
|
126
126
|
@test_obj.add_relationship("foo", "info:fedora/foo:bar")
|
127
127
|
@test_obj.save
|
128
|
-
@test_obj.relationships.size.
|
129
|
-
@test_obj.ids_for_outbound("foo").
|
128
|
+
expect(@test_obj.relationships.size).to eq(5)
|
129
|
+
expect(@test_obj.ids_for_outbound("foo")).to eq(["foo:bar"])
|
130
130
|
end
|
131
131
|
it "should automatically map un-mapped predicates" do
|
132
132
|
xml = <<-EOS
|
@@ -144,8 +144,8 @@ describe ActiveFedora::RelsExtDatastream do
|
|
144
144
|
model = ActiveFedora::Base.new
|
145
145
|
new_ds = ActiveFedora::RelsExtDatastream.new
|
146
146
|
new_ds.model = model
|
147
|
-
|
148
|
-
new_ds.to_rels_ext.
|
147
|
+
expect { ActiveFedora::RelsExtDatastream.from_xml(xml, new_ds) }.not_to raise_exception
|
148
|
+
expect(new_ds.to_rels_ext).to match(/missing:hasOtherRelationship/)
|
149
149
|
end
|
150
150
|
it "should handle un-mapped literals" do
|
151
151
|
xml = "
|
@@ -162,7 +162,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
162
162
|
new_ds.model = model
|
163
163
|
ActiveFedora::RelsExtDatastream.from_xml(xml, new_ds)
|
164
164
|
new_ext = new_ds.to_rels_ext()
|
165
|
-
new_ext.
|
165
|
+
expect(new_ext).to match "<ns2:itemID>oai:hull.ac.uk:hull:2708</ns2:itemID>"
|
166
166
|
|
167
167
|
end
|
168
168
|
end
|
@@ -10,17 +10,17 @@ describe RSpec::Matchers, "belong_to_associated_active_fedora_object_matcher" do
|
|
10
10
|
let(:association) { :association }
|
11
11
|
|
12
12
|
it 'should match when association is properly stored in fedora' do
|
13
|
-
subject.class.
|
14
|
-
subject.
|
15
|
-
subject.
|
13
|
+
expect(subject.class).to receive(:find).with(pid).and_return(subject)
|
14
|
+
expect(subject).to receive(association).and_return(object1)
|
15
|
+
expect(subject).to belong_to_associated_active_fedora_object(association).with_object(object1)
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should not match when association is different' do
|
19
|
-
subject.class.
|
20
|
-
subject.
|
21
|
-
|
22
|
-
subject.
|
23
|
-
}.
|
19
|
+
expect(subject.class).to receive(:find).with(pid).and_return(subject)
|
20
|
+
expect(subject).to receive(association).and_return(object1)
|
21
|
+
expect {
|
22
|
+
expect(subject).to belong_to_associated_active_fedora_object(association).with_object(object2)
|
23
|
+
}.to (
|
24
24
|
raise_error(
|
25
25
|
RSpec::Expectations::ExpectationNotMetError,
|
26
26
|
/expected #{subject.class} PID=#{pid} association: #{association.inspect}/
|
@@ -29,9 +29,9 @@ describe RSpec::Matchers, "belong_to_associated_active_fedora_object_matcher" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should require :with_object option' do
|
32
|
-
|
33
|
-
subject.
|
34
|
-
}.
|
32
|
+
expect {
|
33
|
+
expect(subject).to belong_to_associated_active_fedora_object(association)
|
34
|
+
}.to(
|
35
35
|
raise_error(
|
36
36
|
ArgumentError,
|
37
37
|
"subject.should belong_to_associated_active_fedora_object(<association_name>).with_object(<object>)"
|