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
@@ -13,17 +13,17 @@ describe ActiveFedora::Auditable do
|
|
13
13
|
@test_object.delete
|
14
14
|
end
|
15
15
|
it "should have the correct number of audit records" do
|
16
|
-
@test_object.audit_trail.records.length.
|
16
|
+
expect(@test_object.audit_trail.records.length).to eq(1)
|
17
17
|
end
|
18
18
|
it "should return all the data from each audit record" do
|
19
19
|
record = @test_object.audit_trail.records.last
|
20
|
-
record.id.
|
21
|
-
record.process_type.
|
22
|
-
record.action.
|
23
|
-
record.component_id.
|
24
|
-
record.responsibility.
|
20
|
+
expect(record.id).to eq("AUDREC1")
|
21
|
+
expect(record.process_type).to eq("Fedora API-M")
|
22
|
+
expect(record.action).to eq("addDatastream")
|
23
|
+
expect(record.component_id).to eq("RELS-EXT")
|
24
|
+
expect(record.responsibility).to eq("fedoraAdmin")
|
25
25
|
expect(DateTime.parse(record.date)).to eq DateTime.parse(@test_object.modified_date)
|
26
|
-
record.justification.
|
26
|
+
expect(record.justification).to eq("")
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -14,9 +14,9 @@ describe ActiveFedora::Base do
|
|
14
14
|
|
15
15
|
context '#changed_for_autosave?' do
|
16
16
|
before(:each) do
|
17
|
-
subject.
|
18
|
-
subject.
|
19
|
-
subject.
|
17
|
+
allow(subject).to receive(:new_record?).and_return(false)
|
18
|
+
allow(subject).to receive(:changed?).and_return(false)
|
19
|
+
allow(subject).to receive(:marked_for_destruction?).and_return(false)
|
20
20
|
end
|
21
21
|
it {
|
22
22
|
expect { subject.changed_for_autosave? }.to_not raise_error
|
@@ -18,8 +18,8 @@ describe "A base object with metadata" do
|
|
18
18
|
end
|
19
19
|
it "should save the datastream." do
|
20
20
|
obj = ActiveFedora::Base.find(@obj.pid)
|
21
|
-
obj.foo.
|
22
|
-
obj.foo.person.
|
21
|
+
expect(obj.foo).not_to be_new
|
22
|
+
expect(obj.foo.person).to eq(['bob'])
|
23
23
|
person_field = ActiveFedora::SolrService.solr_name('foo__person', type: :string)
|
24
24
|
solr_result = ActiveFedora::SolrService.query("{!raw f=id}#{@obj.pid}", :fl=>"id #{person_field}").first
|
25
25
|
expect(solr_result).to eq("id"=>@obj.pid, person_field =>['bob'])
|
@@ -32,7 +32,7 @@ describe "A base object with metadata" do
|
|
32
32
|
obj.state='D'
|
33
33
|
obj.save!
|
34
34
|
obj.reload
|
35
|
-
obj.state.
|
35
|
+
expect(obj.state).to eq('D')
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -50,9 +50,9 @@ describe "A base object with metadata" do
|
|
50
50
|
@release.save!
|
51
51
|
end
|
52
52
|
it "should save the datastream." do
|
53
|
-
MockAFBaseRelationship.find(@release.pid).foo.person.
|
53
|
+
expect(MockAFBaseRelationship.find(@release.pid).foo.person).to eq(['frank'])
|
54
54
|
person_field = ActiveFedora::SolrService.solr_name('foo__person', type: :string)
|
55
|
-
ActiveFedora::SolrService.query("id:#{@release.pid.gsub(":", "\\:")}", :fl=>"id #{person_field}").first.
|
55
|
+
expect(ActiveFedora::SolrService.query("id:#{@release.pid.gsub(":", "\\:")}", :fl=>"id #{person_field}").first).to eq({"id"=>@release.pid, person_field =>['frank']})
|
56
56
|
end
|
57
57
|
end
|
58
58
|
describe "clone_into a new object" do
|
@@ -68,7 +68,7 @@ describe "A base object with metadata" do
|
|
68
68
|
@new_object = MockAFBaseRelationship.find('test:999')
|
69
69
|
end
|
70
70
|
it "should have all the assertions" do
|
71
|
-
@new_object.rels_ext.content.
|
71
|
+
expect(@new_object.rels_ext.content).to be_equivalent_to '<rdf:RDF xmlns:ns1="info:fedora/fedora-system:def/model#" xmlns:ns2="info:fedora/fedora-system:def/relations-external#" xmlns:ns0="http://projecthydra.org/ns/relations#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
72
72
|
<rdf:Description rdf:about="info:fedora/test:999">
|
73
73
|
<ns0:isGovernedBy rdf:resource="info:fedora/test:catalog-fixture"/>
|
74
74
|
<ns1:hasModel rdf:resource="info:fedora/afmodel:MockAFBaseRelationship"/>
|
@@ -78,8 +78,8 @@ describe "A base object with metadata" do
|
|
78
78
|
</rdf:RDF>'
|
79
79
|
end
|
80
80
|
it "should have the other datastreams too" do
|
81
|
-
@new_object.datastreams.keys.
|
82
|
-
@new_object.foo.content.
|
81
|
+
expect(@new_object.datastreams.keys).to include "foo"
|
82
|
+
expect(@new_object.foo.content).to be_equivalent_to @release.foo.content
|
83
83
|
end
|
84
84
|
end
|
85
85
|
describe "clone" do
|
@@ -87,7 +87,7 @@ describe "A base object with metadata" do
|
|
87
87
|
@new_object = @release.clone
|
88
88
|
end
|
89
89
|
it "should have all the assertions" do
|
90
|
-
@new_object.rels_ext.content.
|
90
|
+
expect(@new_object.rels_ext.content).to be_equivalent_to '<rdf:RDF xmlns:ns1="info:fedora/fedora-system:def/model#" xmlns:ns2="info:fedora/fedora-system:def/relations-external#" xmlns:ns0="http://projecthydra.org/ns/relations#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
91
91
|
<rdf:Description rdf:about="info:fedora/'+ @new_object.pid+'">
|
92
92
|
<ns0:isGovernedBy rdf:resource="info:fedora/test:catalog-fixture"/>
|
93
93
|
<ns1:hasModel rdf:resource="info:fedora/afmodel:MockAFBaseRelationship"/>
|
@@ -97,8 +97,8 @@ describe "A base object with metadata" do
|
|
97
97
|
</rdf:RDF>'
|
98
98
|
end
|
99
99
|
it "should have the other datastreams too" do
|
100
|
-
@new_object.datastreams.keys.
|
101
|
-
@new_object.foo.content.
|
100
|
+
expect(@new_object.datastreams.keys).to include "foo"
|
101
|
+
expect(@new_object.foo.content).to be_equivalent_to @release.foo.content
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -117,7 +117,7 @@ describe "A base object with metadata" do
|
|
117
117
|
|
118
118
|
it 'should requery Fedora' do
|
119
119
|
@object.reload
|
120
|
-
@object.foo.person.
|
120
|
+
expect(@object.foo.person).to eq(['dave'])
|
121
121
|
end
|
122
122
|
|
123
123
|
it 'should raise an error if not persisted' do
|
@@ -141,12 +141,12 @@ describe "Datastreams synched together" do
|
|
141
141
|
it "Should update datastream" do
|
142
142
|
@nc = DSTest.new
|
143
143
|
@nc.save
|
144
|
-
@nc.test_ds.content.
|
144
|
+
expect(@nc.test_ds.content).to eq('XXX')
|
145
145
|
ds = @nc.datastreams['test_ds']
|
146
146
|
ds.content = "Foobar"
|
147
147
|
@nc.save
|
148
|
-
DSTest.find(@nc.pid).datastreams['test_ds'].content.
|
149
|
-
DSTest.find(@nc.pid).test_ds.content.
|
148
|
+
expect(DSTest.find(@nc.pid).datastreams['test_ds'].content).to eq('Foobar')
|
149
|
+
expect(DSTest.find(@nc.pid).test_ds.content).to eq('Foobar')
|
150
150
|
end
|
151
151
|
|
152
152
|
end
|
@@ -213,8 +213,8 @@ describe ActiveFedora::Base do
|
|
213
213
|
|
214
214
|
describe ".initialize" do
|
215
215
|
it "calling constructor should create a new Fedora Object" do
|
216
|
-
@test_object.
|
217
|
-
@test_object.pid.
|
216
|
+
expect(@test_object.errors).to be_blank
|
217
|
+
expect(@test_object.pid).not_to be_nil
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
@@ -231,20 +231,20 @@ describe ActiveFedora::Base do
|
|
231
231
|
@test_object2 = ActiveFedora::Base.new({:namespace=>"randomNamespace"})
|
232
232
|
# will be nil if match failed, otherwise will equal pid
|
233
233
|
@test_object2.save
|
234
|
-
@test_object2.pid.match('randomNamespace:\d+').to_a.first.
|
234
|
+
expect(@test_object2.pid.match('randomNamespace:\d+').to_a.first).to eq(@test_object2.pid)
|
235
235
|
end
|
236
236
|
|
237
237
|
it "should set the CMA hasModel relationship in the Rels-EXT" do
|
238
238
|
@test_object2.save
|
239
239
|
rexml = REXML::Document.new(@test_object2.datastreams["RELS-EXT"].content)
|
240
240
|
# Purpose: confirm that the isMemberOf entries exist and have real RDF in them
|
241
|
-
rexml.root.elements["rdf:Description/ns0:hasModel"].attributes["rdf:resource"].
|
241
|
+
expect(rexml.root.elements["rdf:Description/ns0:hasModel"].attributes["rdf:resource"]).to eq('info:fedora/afmodel:ActiveFedora_Base')
|
242
242
|
end
|
243
243
|
it "should merge attributes from fedora into attributes hash" do
|
244
244
|
@test_object2.save
|
245
245
|
inner_object = @test_object2.inner_object
|
246
|
-
inner_object.pid.
|
247
|
-
inner_object.
|
246
|
+
expect(inner_object.pid).to eq(@test_object2.pid)
|
247
|
+
expect(inner_object).to respond_to(:lastModifiedDate)
|
248
248
|
end
|
249
249
|
|
250
250
|
it 'when the object is updated, it also updates modification time field in solr' do
|
@@ -262,25 +262,25 @@ describe ActiveFedora::Base do
|
|
262
262
|
|
263
263
|
new_time_fedora = Time.parse(@test_object2.modified_date).to_i
|
264
264
|
new_time_solr = Time.parse(solr_doc.first['system_modified_dtsi']).to_i
|
265
|
-
new_time_solr.
|
265
|
+
expect(new_time_solr).to eq(new_time_fedora)
|
266
266
|
end
|
267
267
|
end
|
268
268
|
|
269
269
|
describe ".datastreams" do
|
270
270
|
it "should return a Hash of datastreams from fedora" do
|
271
271
|
datastreams = @test_object.datastreams
|
272
|
-
datastreams.
|
272
|
+
expect(datastreams).to be_a_kind_of(ActiveFedora::DatastreamHash)
|
273
273
|
datastreams.each_value do |ds|
|
274
|
-
ds.
|
274
|
+
expect(ds).to be_a_kind_of(ActiveFedora::Datastream)
|
275
275
|
end
|
276
|
-
@test_object.datastreams["DC"].
|
277
|
-
datastreams["DC"].
|
278
|
-
datastreams["DC"].
|
276
|
+
expect(@test_object.datastreams["DC"]).to be_an_instance_of(ActiveFedora::Datastream)
|
277
|
+
expect(datastreams["DC"]).not_to be_nil
|
278
|
+
expect(datastreams["DC"]).to be_an_instance_of(ActiveFedora::Datastream)
|
279
279
|
end
|
280
280
|
it "should initialize the datastream pointers with @new_object=false" do
|
281
281
|
datastreams = @test_object.datastreams
|
282
282
|
datastreams.each_value do |ds|
|
283
|
-
ds.
|
283
|
+
expect(ds).not_to be_new
|
284
284
|
end
|
285
285
|
end
|
286
286
|
end
|
@@ -295,23 +295,23 @@ describe ActiveFedora::Base do
|
|
295
295
|
@test_object.add_datastream(fds)
|
296
296
|
|
297
297
|
result = @test_object.metadata_streams
|
298
|
-
result.length.
|
299
|
-
result.
|
300
|
-
result.
|
298
|
+
expect(result.length).to eq(2)
|
299
|
+
expect(result).to include(mds1)
|
300
|
+
expect(result).to include(mds2)
|
301
301
|
end
|
302
302
|
end
|
303
303
|
|
304
304
|
describe '.rels_ext' do
|
305
305
|
it "should retrieve RelsExtDatastream object via rels_ext method" do
|
306
|
-
@test_object.rels_ext.
|
306
|
+
expect(@test_object.rels_ext).to be_instance_of(ActiveFedora::RelsExtDatastream)
|
307
307
|
end
|
308
308
|
|
309
309
|
it 'should create the RELS-EXT datastream if it doesnt exist' do
|
310
310
|
test_object = ActiveFedora::Base.new
|
311
311
|
#test_object.datastreams["RELS-EXT"].should == nil
|
312
312
|
test_object.rels_ext
|
313
|
-
test_object.datastreams["RELS-EXT"].
|
314
|
-
test_object.datastreams["RELS-EXT"].class.
|
313
|
+
expect(test_object.datastreams["RELS-EXT"]).not_to eq(nil)
|
314
|
+
expect(test_object.datastreams["RELS-EXT"].class).to eq(ActiveFedora::RelsExtDatastream)
|
315
315
|
end
|
316
316
|
end
|
317
317
|
|
@@ -323,9 +323,9 @@ describe ActiveFedora::Base do
|
|
323
323
|
@test_object.save
|
324
324
|
rexml = REXML::Document.new(@test_object.datastreams["RELS-EXT"].content)
|
325
325
|
# Purpose: confirm that the isMemberOf entries exist and have real RDF in them
|
326
|
-
rexml.root.attributes["xmlns:ns1"].
|
327
|
-
rexml.root.elements["rdf:Description/ns1:isMemberOf[@rdf:resource='info:fedora/demo:5']"].
|
328
|
-
rexml.root.elements["rdf:Description/ns1:isMemberOf[@rdf:resource='info:fedora/demo:10']"].
|
326
|
+
expect(rexml.root.attributes["xmlns:ns1"]).to eq('info:fedora/fedora-system:def/relations-external#')
|
327
|
+
expect(rexml.root.elements["rdf:Description/ns1:isMemberOf[@rdf:resource='info:fedora/demo:5']"]).not_to be_nil
|
328
|
+
expect(rexml.root.elements["rdf:Description/ns1:isMemberOf[@rdf:resource='info:fedora/demo:10']"]).not_to be_nil
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
@@ -337,25 +337,25 @@ describe ActiveFedora::Base do
|
|
337
337
|
@test_object.save
|
338
338
|
test_obj = ActiveFedora::Base.find(@test_object.pid)
|
339
339
|
#check case where nothing passed in does not have correct mime type
|
340
|
-
test_obj.datastreams["DS1"].mimeType.
|
340
|
+
expect(test_obj.datastreams["DS1"].mimeType).to eq("application/octet-stream")
|
341
341
|
@test_object2 = ActiveFedora::Base.new
|
342
342
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino_jpg_no_file_ext" ))
|
343
343
|
@test_object2.add_file_datastream(f,{:mimeType=>"image/jpeg"})
|
344
344
|
@test_object2.save
|
345
345
|
test_obj = ActiveFedora::Base.find(@test_object2.pid)
|
346
|
-
test_obj.datastreams["DS1"].mimeType.
|
346
|
+
expect(test_obj.datastreams["DS1"].mimeType).to eq("image/jpeg")
|
347
347
|
@test_object3 = ActiveFedora::Base.new
|
348
348
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino_jpg_no_file_ext" ))
|
349
349
|
@test_object3.add_file_datastream(f,{:mime_type=>"image/jpeg"})
|
350
350
|
@test_object3.save
|
351
351
|
test_obj = ActiveFedora::Base.find(@test_object3.pid)
|
352
|
-
test_obj.datastreams["DS1"].mimeType.
|
352
|
+
expect(test_obj.datastreams["DS1"].mimeType).to eq("image/jpeg")
|
353
353
|
@test_object4 = ActiveFedora::Base.new
|
354
354
|
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/dino_jpg_no_file_ext" ))
|
355
355
|
@test_object4.add_file_datastream(f,{:content_type=>"image/jpeg"})
|
356
356
|
@test_object4.save
|
357
357
|
test_obj = ActiveFedora::Base.find(@test_object4.pid)
|
358
|
-
test_obj.datastreams["DS1"].mimeType.
|
358
|
+
expect(test_obj.datastreams["DS1"].mimeType).to eq("image/jpeg")
|
359
359
|
end
|
360
360
|
end
|
361
361
|
|
@@ -363,16 +363,16 @@ describe ActiveFedora::Base do
|
|
363
363
|
|
364
364
|
it "should be able to add datastreams" do
|
365
365
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'DS1')
|
366
|
-
@test_object.add_datastream(ds).
|
366
|
+
expect(@test_object.add_datastream(ds)).to be_truthy
|
367
367
|
end
|
368
368
|
|
369
369
|
it "adding and saving should add the datastream to the datastreams array" do
|
370
370
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'DS1')
|
371
371
|
ds.content = fixture('dino.jpg').read
|
372
|
-
@test_object.datastreams.
|
372
|
+
expect(@test_object.datastreams).not_to have_key("DS1")
|
373
373
|
@test_object.add_datastream(ds)
|
374
374
|
ds.save
|
375
|
-
@test_object.datastreams.
|
375
|
+
expect(@test_object.datastreams).to have_key("DS1")
|
376
376
|
end
|
377
377
|
|
378
378
|
end
|
@@ -382,18 +382,18 @@ describe ActiveFedora::Base do
|
|
382
382
|
ds.content = "foo"
|
383
383
|
new_ds = ds.save
|
384
384
|
@test_object.add_datastream(new_ds)
|
385
|
-
@test_object.class.find(@test_object.pid).datastreams["DS1"].content.
|
385
|
+
expect(@test_object.class.find(@test_object.pid).datastreams["DS1"].content).to eq(new_ds.content)
|
386
386
|
end
|
387
387
|
|
388
388
|
describe ".create_date" do
|
389
389
|
it "should return W3C date" do
|
390
|
-
@test_object.create_date.
|
390
|
+
expect(@test_object.create_date).not_to be_nil
|
391
391
|
end
|
392
392
|
end
|
393
393
|
|
394
394
|
describe ".modified_date" do
|
395
395
|
it "should return nil before saving and a W3C date after saving" do
|
396
|
-
@test_object.modified_date.
|
396
|
+
expect(@test_object.modified_date).not_to be_nil
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
@@ -401,10 +401,10 @@ describe ActiveFedora::Base do
|
|
401
401
|
|
402
402
|
it "should delete the object from Fedora and Solr" do
|
403
403
|
@test_object.save
|
404
|
-
ActiveFedora::Base.find_with_conditions(:id=>@test_object.pid).first["id"].
|
404
|
+
expect(ActiveFedora::Base.find_with_conditions(:id=>@test_object.pid).first["id"]).to eq(@test_object.pid)
|
405
405
|
pid = @test_object.pid # store so we can access it after deletion
|
406
406
|
@test_object.delete
|
407
|
-
ActiveFedora::Base.find_with_conditions(:id=>pid).
|
407
|
+
expect(ActiveFedora::Base.find_with_conditions(:id=>pid)).to be_empty
|
408
408
|
end
|
409
409
|
end
|
410
410
|
|
@@ -421,11 +421,11 @@ describe ActiveFedora::Base do
|
|
421
421
|
puts "#{e.message}\n#{e.backtrace}"
|
422
422
|
raise e
|
423
423
|
end
|
424
|
-
@test_object.object_relations[:has_part].
|
424
|
+
expect(@test_object.object_relations[:has_part]).to include @test_object2.internal_uri
|
425
425
|
@test_object.remove_relationship(:has_part,@test_object2)
|
426
426
|
@test_object.save
|
427
427
|
@test_object = ActiveFedora::Base.find(@pid)
|
428
|
-
@test_object.object_relations[:has_part].
|
428
|
+
expect(@test_object.object_relations[:has_part]).to be_empty
|
429
429
|
end
|
430
430
|
end
|
431
431
|
|
@@ -25,7 +25,7 @@ describe ActiveFedora::Base do
|
|
25
25
|
describe "setting the id property" do
|
26
26
|
it "should store it" do
|
27
27
|
book.library_id = library.id
|
28
|
-
book.library_id.
|
28
|
+
expect(book.library_id).to eq(library.id)
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "reassigning the parent_id" do
|
@@ -43,19 +43,19 @@ describe ActiveFedora::Base do
|
|
43
43
|
|
44
44
|
it "should be settable via []=" do
|
45
45
|
book[:library_id] = library.id
|
46
|
-
book.library_id.
|
46
|
+
expect(book.library_id).to eq(library.id)
|
47
47
|
end
|
48
48
|
|
49
49
|
it "safely handles invalid data" do
|
50
50
|
book[:library_id] = 'bad:identifier'
|
51
|
-
book.library.
|
51
|
+
expect(book.library).to be_nil
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "getting the id property" do
|
56
56
|
it "should be accessable via []" do
|
57
57
|
book[:library_id] = library.id
|
58
|
-
book[:library_id].
|
58
|
+
expect(book[:library_id]).to eq(library.id)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -135,40 +135,40 @@ describe ActiveFedora::Base do
|
|
135
135
|
|
136
136
|
it "casted association methods should work and return the most complex class" do
|
137
137
|
|
138
|
-
@complex_object.simple_collection.
|
139
|
-
@complex_object.complex_collection.
|
138
|
+
expect(@complex_object.simple_collection).to be_instance_of SimpleCollection
|
139
|
+
expect(@complex_object.complex_collection).to be_nil
|
140
140
|
|
141
|
-
@complex_object_second.simple_collection.
|
142
|
-
@complex_object_second.complex_collection.
|
141
|
+
expect(@complex_object_second.simple_collection).to be_instance_of ComplexCollection
|
142
|
+
expect(@complex_object_second.complex_collection).to be_instance_of ComplexCollection
|
143
143
|
|
144
|
-
@simple_object.simple_collection.
|
145
|
-
@simple_object.complex_collection.
|
144
|
+
expect(@simple_object.simple_collection).to be_instance_of SimpleCollection
|
145
|
+
expect(@simple_object.complex_collection).to be_nil
|
146
146
|
|
147
|
-
@simple_object_second.simple_collection.
|
148
|
-
@simple_object_second.complex_collection.
|
147
|
+
expect(@simple_object_second.simple_collection).to be_instance_of SimpleCollection
|
148
|
+
expect(@simple_object_second.complex_collection).to be_nil
|
149
149
|
|
150
|
-
@simple_object_third.simple_collection.
|
151
|
-
@simple_object_third.complex_collection.
|
150
|
+
expect(@simple_object_third.simple_collection).to be_instance_of ComplexCollection
|
151
|
+
expect(@simple_object_third.complex_collection).to be_instance_of ComplexCollection
|
152
152
|
|
153
|
-
@simple_collection.objects.size.
|
154
|
-
@simple_collection.objects[0].
|
155
|
-
@simple_collection.objects[1].
|
156
|
-
@simple_collection.objects[2].
|
153
|
+
expect(@simple_collection.objects.size).to eq(3)
|
154
|
+
expect(@simple_collection.objects[0]).to be_instance_of SimpleObject
|
155
|
+
expect(@simple_collection.objects[1]).to be_instance_of SimpleObject
|
156
|
+
expect(@simple_collection.objects[2]).to be_instance_of ComplexObject
|
157
157
|
|
158
|
-
@complex_collection.objects.size.
|
159
|
-
@complex_collection.objects[0].
|
160
|
-
@complex_collection.objects[1].
|
158
|
+
expect(@complex_collection.objects.size).to eq(2)
|
159
|
+
expect(@complex_collection.objects[0]).to be_instance_of SimpleObject
|
160
|
+
expect(@complex_collection.objects[1]).to be_instance_of ComplexObject
|
161
161
|
|
162
162
|
end
|
163
163
|
|
164
164
|
it "specified ending relationships should ignore classes not specified" do
|
165
|
-
@simple_collection.complex_objects.size.
|
166
|
-
@simple_collection.complex_objects[0].
|
167
|
-
@simple_collection.complex_objects[1].
|
165
|
+
expect(@simple_collection.complex_objects.size).to eq(1)
|
166
|
+
expect(@simple_collection.complex_objects[0]).to be_instance_of ComplexObject
|
167
|
+
expect(@simple_collection.complex_objects[1]).to be_nil
|
168
168
|
|
169
|
-
@complex_collection.complex_objects.size.
|
170
|
-
@complex_collection.complex_objects[0].
|
171
|
-
@complex_collection.complex_objects[1].
|
169
|
+
expect(@complex_collection.complex_objects.size).to eq(1)
|
170
|
+
expect(@complex_collection.complex_objects[0]).to be_instance_of ComplexObject
|
171
|
+
expect(@complex_collection.complex_objects[1]).to be_nil
|
172
172
|
end
|
173
173
|
|
174
174
|
after do
|
@@ -20,10 +20,10 @@ describe ActiveFedora::Base do
|
|
20
20
|
end
|
21
21
|
describe "load_from_solr" do
|
22
22
|
it "should set rows to count, if not specified" do
|
23
|
-
library.books(response_format: :solr).size.
|
23
|
+
expect(library.books(response_format: :solr).size).to eq(2)
|
24
24
|
end
|
25
25
|
it "should limit rows returned if option passed" do
|
26
|
-
library.books(response_format: :solr, rows: 1).size.
|
26
|
+
expect(library.books(response_format: :solr, rows: 1).size).to eq(1)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|