active-fedora 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +14 -1
- data/README.textile +6 -0
- data/active-fedora.gemspec +1 -1
- data/lib/active_fedora.rb +2 -0
- data/lib/active_fedora/associations.rb +22 -2
- data/lib/active_fedora/associations/association_collection.rb +37 -0
- data/lib/active_fedora/associations/belongs_to_association.rb +8 -0
- data/lib/active_fedora/associations/has_many_association.rb +2 -0
- data/lib/active_fedora/base.rb +43 -6
- data/lib/active_fedora/datastream.rb +13 -37
- data/lib/active_fedora/datastreams.rb +2 -6
- data/lib/active_fedora/digital_object.rb +8 -1
- data/lib/active_fedora/metadata_datastream_helper.rb +2 -2
- data/lib/active_fedora/nokogiri_datastream.rb +55 -16
- data/lib/active_fedora/persistence.rb +14 -9
- data/lib/active_fedora/railtie.rb +15 -0
- data/lib/active_fedora/rdf_datastream.rb +4 -0
- data/lib/active_fedora/rdfxml_rdf_datastream.rb +2 -6
- data/lib/active_fedora/reflection.rb +11 -0
- data/lib/active_fedora/relationships.rb +4 -4
- data/lib/active_fedora/rels_ext_datastream.rb +21 -6
- data/lib/active_fedora/semantic_node.rb +3 -3
- data/lib/active_fedora/test_support.rb +38 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/generators/active_fedora/config/USAGE +9 -0
- data/lib/generators/active_fedora/config/config_generator.rb +10 -0
- data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +12 -0
- data/lib/generators/active_fedora/config/fedora/templates/fedora.yml +14 -0
- data/lib/generators/active_fedora/config/fedora/templates/fedora_conf/conf/development/fedora.fcfg +953 -0
- data/lib/generators/active_fedora/config/fedora/templates/fedora_conf/conf/test/fedora.fcfg +953 -0
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +12 -0
- data/lib/generators/active_fedora/config/solr/templates/solr.yml +10 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_conf/conf/schema.xml +692 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_conf/conf/solrconfig.xml +299 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_conf/solr.xml +35 -0
- data/lib/generators/active_fedora/model/USAGE +9 -0
- data/lib/generators/active_fedora/model/model_generator.rb +21 -0
- data/lib/generators/active_fedora/model/templates/model.rb.erb +6 -0
- data/lib/generators/active_fedora/model/templates/model_spec.rb.erb +21 -0
- data/lib/tasks/active_fedora_dev.rake +8 -0
- data/spec/fixtures/hydrangea_fixture_mods_article2.foxml.xml +234 -0
- data/spec/integration/associations_spec.rb +76 -15
- data/spec/integration/base_spec.rb +38 -10
- data/spec/integration/datastreams_spec.rb +24 -2
- data/spec/integration/nokogiri_datastream_spec.rb +23 -5
- data/spec/unit/base_extra_spec.rb +0 -1
- data/spec/unit/base_spec.rb +7 -47
- data/spec/unit/datastream_collections_spec.rb +0 -7
- data/spec/unit/datastream_spec.rb +7 -16
- data/spec/unit/datastreams_spec.rb +2 -2
- data/spec/unit/nokogiri_datastream_spec.rb +31 -20
- data/spec/unit/ntriples_datastream_spec.rb +7 -10
- data/spec/unit/persistence_spec.rb +0 -11
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -2
- data/spec/unit/relationships_spec.rb +5 -5
- data/spec/unit/rels_ext_datastream_spec.rb +14 -9
- data/spec/unit/semantic_node_spec.rb +4 -4
- metadata +25 -6
@@ -32,41 +32,72 @@ describe ActiveFedora::Base do
|
|
32
32
|
@book2.save
|
33
33
|
end
|
34
34
|
|
35
|
-
it "should build" do
|
35
|
+
it "should build child" do
|
36
36
|
new_book = @library.books.build({})
|
37
37
|
new_book.should be_new_record
|
38
38
|
new_book.should be_kind_of Book
|
39
|
+
new_book.library.should be_nil
|
40
|
+
@library.books.should == [new_book]
|
41
|
+
#TODO save the associated children too, requires something like ActiveRecord::AutosaveAssociation (ver 3.0.12)
|
42
|
+
#@library.save
|
43
|
+
#new_book.library.should == @library
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should not create children if the parent isn't saved" do
|
47
|
+
lambda {@library.books.create({})}.should raise_error ActiveFedora::RecordNotSaved, "You cannot call create unless the parent is saved"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should create children" do
|
51
|
+
@library.save!
|
52
|
+
new_book = @library.books.create({})
|
53
|
+
new_book.should_not be_new_record
|
54
|
+
new_book.should be_kind_of Book
|
55
|
+
new_book.library.should == @library
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should build parent" do
|
59
|
+
new_library = @book.build_library({})
|
60
|
+
new_library.should be_new_record
|
61
|
+
new_library.should be_kind_of Library
|
62
|
+
@book.library.should == new_library
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should create parent" do
|
66
|
+
new_library = @book.create_library({})
|
67
|
+
new_library.should_not be_new_record
|
68
|
+
new_library.should be_kind_of Library
|
69
|
+
@book.library.should == new_library
|
39
70
|
end
|
40
71
|
|
41
72
|
it "should let you shift onto the association" do
|
42
73
|
@library.new_record?.should be_true
|
43
74
|
@library.books.size == 0
|
44
|
-
@library.books.
|
75
|
+
@library.books.should == []
|
45
76
|
@library.book_ids.should ==[]
|
46
77
|
@library.books << @book
|
47
|
-
@library.books.
|
78
|
+
@library.books.should == [@book]
|
48
79
|
@library.book_ids.should ==[@book.pid]
|
49
80
|
|
50
81
|
end
|
51
82
|
|
52
83
|
it "should let you set an array of objects" do
|
53
84
|
@library.books = [@book, @book2]
|
54
|
-
@library.books.
|
85
|
+
@library.books.should == [@book, @book2]
|
55
86
|
@library.save
|
56
87
|
|
57
88
|
@library.books = [@book]
|
58
|
-
@library.books.
|
89
|
+
@library.books.should == [@book]
|
59
90
|
|
60
91
|
end
|
61
92
|
it "should let you set an array of object ids" do
|
62
93
|
@library.book_ids = [@book.pid, @book2.pid]
|
63
|
-
@library.books.
|
94
|
+
@library.books.should == [@book, @book2]
|
64
95
|
end
|
65
96
|
|
66
97
|
it "setter should wipe out previously saved relations" do
|
67
98
|
@library.book_ids = [@book.pid, @book2.pid]
|
68
99
|
@library.book_ids = [@book2.pid]
|
69
|
-
@library.books.
|
100
|
+
@library.books.should == [@book2]
|
70
101
|
|
71
102
|
end
|
72
103
|
|
@@ -75,7 +106,7 @@ describe ActiveFedora::Base do
|
|
75
106
|
@library.books = [@book, @book2]
|
76
107
|
@library.save
|
77
108
|
@library = Library.find(@library.pid)
|
78
|
-
@library.books.
|
109
|
+
@library.books.should == [@book, @book2]
|
79
110
|
end
|
80
111
|
|
81
112
|
|
@@ -87,7 +118,7 @@ describe ActiveFedora::Base do
|
|
87
118
|
@book2.save
|
88
119
|
|
89
120
|
@library = Library.find(@library.pid)
|
90
|
-
@library.books.
|
121
|
+
@library.books.should == [@book, @book2]
|
91
122
|
|
92
123
|
solr_resp = @library.books(:response_format=>:solr)
|
93
124
|
solr_resp.size.should == 2
|
@@ -138,7 +169,7 @@ describe ActiveFedora::Base do
|
|
138
169
|
@book = Book.new
|
139
170
|
@book.topics << @topic1
|
140
171
|
@book.topics.map(&:pid).should == [@topic1.pid]
|
141
|
-
Topic.find(@topic1.pid).books.
|
172
|
+
Topic.find(@topic1.pid).books.should == [] #Can't have saved it because @book isn't saved yet.
|
142
173
|
end
|
143
174
|
after do
|
144
175
|
@topic1.delete
|
@@ -165,10 +196,10 @@ describe ActiveFedora::Base do
|
|
165
196
|
|
166
197
|
@book.library.pid.should == @library.pid
|
167
198
|
@library.books.reload
|
168
|
-
@library.books.
|
199
|
+
@library.books.should == [@book]
|
169
200
|
|
170
201
|
@library2 = Library.find(@library.pid)
|
171
|
-
@library2.books.
|
202
|
+
@library2.books.should == [@book]
|
172
203
|
end
|
173
204
|
|
174
205
|
it "should have a count once it has been saved" do
|
@@ -177,7 +208,7 @@ describe ActiveFedora::Base do
|
|
177
208
|
|
178
209
|
# @book.library.pid.should == @library.pid
|
179
210
|
# @library.books.reload
|
180
|
-
# @library.books.
|
211
|
+
# @library.books.should == [@book]
|
181
212
|
|
182
213
|
@library2 = Library.find(@library.pid)
|
183
214
|
@library2.books.size.should == 2
|
@@ -226,11 +257,11 @@ describe ActiveFedora::Base do
|
|
226
257
|
end
|
227
258
|
it "should set relationships bidirectionally" do
|
228
259
|
@book.topics << @topic1
|
229
|
-
@book.topics.
|
260
|
+
@book.topics.should == [@topic1]
|
230
261
|
@book.relationships(:has_topic).should == [@topic1.internal_uri]
|
231
262
|
@topic1.relationships(:has_topic).should == []
|
232
263
|
@topic1.relationships(:is_topic_of).should == [@book.internal_uri]
|
233
|
-
Topic.find(@topic1.pid).books.
|
264
|
+
Topic.find(@topic1.pid).books.should == [@book] #Can't have saved it because @book isn't saved yet.
|
234
265
|
end
|
235
266
|
it "should save new child objects" do
|
236
267
|
@book.topics << Topic.new
|
@@ -370,4 +401,34 @@ describe ActiveFedora::Base do
|
|
370
401
|
end
|
371
402
|
end
|
372
403
|
end
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
describe "when a object is deleted" do
|
408
|
+
before (:all) do
|
409
|
+
class MasterFile < ActiveFedora::Base
|
410
|
+
belongs_to :media_object, :property=>:is_part_of
|
411
|
+
end
|
412
|
+
class MediaObject < ActiveFedora::Base
|
413
|
+
has_many :parts, :class_name=>'MasterFile', :property=>:is_part_of
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
before :each do
|
418
|
+
@master = MasterFile.create
|
419
|
+
@media = MediaObject.create
|
420
|
+
@master.media_object = @media
|
421
|
+
@master.save
|
422
|
+
@master.reload
|
423
|
+
|
424
|
+
end
|
425
|
+
|
426
|
+
it "should also remove the relationships that point at that object" do
|
427
|
+
@media.delete
|
428
|
+
@master = MasterFile.find(@master.pid)
|
429
|
+
@master.relationships(:is_part_of).should == []
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
|
373
434
|
end
|
@@ -12,11 +12,14 @@ describe "A base object with metadata" do
|
|
12
12
|
describe "a new document" do
|
13
13
|
before do
|
14
14
|
@obj = MockAFBaseRelationship.new
|
15
|
+
|
15
16
|
@obj.foo.person = "bob"
|
16
17
|
@obj.save
|
17
18
|
end
|
18
19
|
it "should save the datastream." do
|
19
|
-
ActiveFedora::Base.find(@obj.pid, :cast=>true)
|
20
|
+
obj = ActiveFedora::Base.find(@obj.pid, :cast=>true)
|
21
|
+
obj.foo.should_not be_new
|
22
|
+
obj.foo.person.should == ['bob']
|
20
23
|
ActiveFedora::SolrService.query("id:#{@obj.pid.gsub(":", "\\:")}", :fl=>'id person_t').first.should == {"id"=>@obj.pid, 'person_t'=>['bob']}
|
21
24
|
end
|
22
25
|
end
|
@@ -86,6 +89,31 @@ describe "A base object with metadata" do
|
|
86
89
|
end
|
87
90
|
end
|
88
91
|
end
|
92
|
+
|
93
|
+
describe '#reload' do
|
94
|
+
before(:each) do
|
95
|
+
@object = MockAFBaseRelationship.new
|
96
|
+
@object.foo.person = 'bob'
|
97
|
+
@object.save
|
98
|
+
|
99
|
+
@object2 = @object.class.find(@object.pid)
|
100
|
+
|
101
|
+
@object2.foo.person = 'dave'
|
102
|
+
@object2.save
|
103
|
+
end
|
104
|
+
it 'should requery Fedora' do
|
105
|
+
@object.reload
|
106
|
+
@object.foo.person.should == ['dave']
|
107
|
+
end
|
108
|
+
it 'should raise an error if not persisted' do
|
109
|
+
@object = MockAFBaseRelationship.new
|
110
|
+
# You will want this stub or else it will be really chatty in your STDERR
|
111
|
+
@object.inner_object.logger.stubs(:error)
|
112
|
+
expect {
|
113
|
+
@object.reload
|
114
|
+
}.to raise_error(ActiveFedora::ObjectNotFoundError)
|
115
|
+
end
|
116
|
+
end
|
89
117
|
end
|
90
118
|
|
91
119
|
describe "Datastreams synched together" do
|
@@ -394,15 +422,12 @@ describe ActiveFedora::Base do
|
|
394
422
|
end
|
395
423
|
|
396
424
|
describe '#delete' do
|
397
|
-
|
398
|
-
@test_object2 = MockAFBaseRelationship.
|
399
|
-
@
|
400
|
-
@
|
401
|
-
@
|
402
|
-
|
403
|
-
@test_object4.save
|
404
|
-
@test_object5 = MockAFBaseRelationship.new
|
405
|
-
@test_object5.save
|
425
|
+
before do
|
426
|
+
@test_object2 = MockAFBaseRelationship.create
|
427
|
+
@test_object3 = MockAFBaseRelationship.create
|
428
|
+
@test_object4 = MockAFBaseRelationship.create
|
429
|
+
@test_object5 = MockAFBaseRelationship.create
|
430
|
+
Deprecation.stubs(:warn)
|
406
431
|
#append to relationship by 'testing'
|
407
432
|
@test_object2.add_relationship_by_name("testing",@test_object3)
|
408
433
|
@test_object2.add_relationship_by_name("testing2",@test_object4)
|
@@ -420,6 +445,9 @@ describe ActiveFedora::Base do
|
|
420
445
|
@test_object4.relationships_by_name(false)[:inbound]["testing_inbound2"].should == [@test_object2.internal_uri]
|
421
446
|
|
422
447
|
@test_object5.relationships_by_name(false)[:self]["testing"].should == [@test_object2.internal_uri]
|
448
|
+
end
|
449
|
+
|
450
|
+
it 'if inbound relationships exist should remove relationships from those inbound targets as well when deleting this object' do
|
423
451
|
|
424
452
|
@test_object2.delete
|
425
453
|
#need to reload since removed from rels_ext in memory
|
@@ -4,11 +4,33 @@ require 'active_fedora'
|
|
4
4
|
require "rexml/document"
|
5
5
|
|
6
6
|
describe ActiveFedora::Datastreams do
|
7
|
+
describe "serializing datastreams" do
|
8
|
+
before :all do
|
9
|
+
class TestingMetadataSerializing < ActiveFedora::Base
|
10
|
+
has_metadata :name => "nokogiri_autocreate_on", :autocreate => true, :type => ActiveFedora::NokogiriDatastream
|
11
|
+
has_metadata :name => "nokogiri_autocreate_off", :autocreate => false, :type => ActiveFedora::NokogiriDatastream
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
after :all do
|
16
|
+
Object.send(:remove_const, :TestingMetadataSerializing)
|
17
|
+
end
|
18
|
+
|
19
|
+
subject { TestingMetadataSerializing.new }
|
20
|
+
|
21
|
+
it "should work" do
|
22
|
+
subject.save(:validate => false)
|
23
|
+
subject.nokogiri_autocreate_on.should_not be_new
|
24
|
+
subject.nokogiri_autocreate_off.should be_new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
7
29
|
describe "#has_metadata" do
|
8
30
|
before :all do
|
9
31
|
class HasMetadata < ActiveFedora::Base
|
10
|
-
has_metadata :name => "with_versions", :label => "Versioned DS", :type => ActiveFedora::SimpleDatastream
|
11
|
-
has_metadata :name => "without_versions", :versionable => false, :type => ActiveFedora::SimpleDatastream
|
32
|
+
has_metadata :name => "with_versions", :autocreate => true, :label => "Versioned DS", :type => ActiveFedora::SimpleDatastream
|
33
|
+
has_metadata :name => "without_versions", :autocreate => true, :versionable => false, :type => ActiveFedora::SimpleDatastream
|
12
34
|
end
|
13
35
|
end
|
14
36
|
after :all do
|
@@ -20,11 +20,26 @@ describe ActiveFedora::NokogiriDatastream do
|
|
20
20
|
Object.send(:remove_const, :HydrangeaArticle2)
|
21
21
|
end
|
22
22
|
|
23
|
+
describe "#changed?" do
|
24
|
+
it "should not be changed if the new xml matches the old xml" do
|
25
|
+
|
26
|
+
@pid = "hydrangea:fixture_mods_article2"
|
27
|
+
@test_object = HydrangeaArticle2.find(@pid)
|
28
|
+
|
29
|
+
@test_object.descMetadata.ng_xml = @test_object.descMetadata.ng_xml
|
30
|
+
|
31
|
+
@test_object.descMetadata.should_not be_changed
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
23
35
|
describe '.term_values' do
|
24
36
|
before do
|
25
|
-
@pid = "hydrangea:
|
26
|
-
@
|
37
|
+
@pid = "hydrangea:fixture_mods_article2"
|
38
|
+
@test_object = HydrangeaArticle2.find(@pid)
|
39
|
+
@test_object.descMetadata.content = File.read(fixture('mods_articles/hydrangea_article1.xml'))
|
40
|
+
@test_object.save
|
27
41
|
@test_object = HydrangeaArticle2.find(@pid)
|
42
|
+
@test_solr_object = ActiveFedora::Base.load_instance_from_solr(@pid)
|
28
43
|
end
|
29
44
|
|
30
45
|
it "should return the same values whether getting from solr or Fedora" do
|
@@ -58,15 +73,18 @@ describe ActiveFedora::NokogiriDatastream do
|
|
58
73
|
|
59
74
|
describe '.update_values' do
|
60
75
|
before do
|
61
|
-
@pid = "hydrangea:
|
76
|
+
@pid = "hydrangea:fixture_mods_article2"
|
77
|
+
@test_object = HydrangeaArticle2.find(@pid)
|
78
|
+
@test_object.descMetadata.content = File.read(fixture('mods_articles/hydrangea_article1.xml'))
|
79
|
+
@test_object.save
|
62
80
|
@test_object = HydrangeaArticle2.find(@pid)
|
63
81
|
end
|
64
82
|
|
65
83
|
it "should not be dirty after .update_values is saved" do
|
66
84
|
@test_object.datastreams["descMetadata"].update_values([{:name=>0},{:role=>0},:text] =>"Funder")
|
67
|
-
@test_object.datastreams["descMetadata"].
|
85
|
+
@test_object.datastreams["descMetadata"].should be_changed
|
68
86
|
@test_object.save
|
69
|
-
@test_object.datastreams["descMetadata"].
|
87
|
+
@test_object.datastreams["descMetadata"].should_not be_changed
|
70
88
|
@test_object.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Funder"]
|
71
89
|
end
|
72
90
|
end
|
@@ -65,7 +65,6 @@ describe ActiveFedora::Base do
|
|
65
65
|
mock_ss = mock("SolrService")
|
66
66
|
mock_ss.stubs(:conn).returns(mock_conn)
|
67
67
|
ActiveFedora::SolrService.stubs(:instance).returns(mock_ss)
|
68
|
-
@test_object.expects(:inbound_relationships).returns({})
|
69
68
|
@test_object.delete
|
70
69
|
end
|
71
70
|
|
data/spec/unit/base_spec.rb
CHANGED
@@ -81,14 +81,14 @@ describe ActiveFedora::Base do
|
|
81
81
|
describe "With a test class" do
|
82
82
|
before :all do
|
83
83
|
class FooHistory < ActiveFedora::Base
|
84
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m|
|
84
|
+
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData", :autocreate => true do |m|
|
85
85
|
m.field "fubar", :string
|
86
86
|
m.field "swank", :text
|
87
87
|
end
|
88
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText" do |m|
|
88
|
+
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText", :autocreate => true do |m|
|
89
89
|
m.field "fubar", :text
|
90
90
|
end
|
91
|
-
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText2", :label=>"withLabel" do |m|
|
91
|
+
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"withText2", :label=>"withLabel", :autocreate => true do |m|
|
92
92
|
m.field "fubar", :text
|
93
93
|
end
|
94
94
|
delegate :fubar, :to=>'withText'
|
@@ -244,7 +244,7 @@ describe ActiveFedora::Base do
|
|
244
244
|
|
245
245
|
it "should update the RELS-EXT datastream and set the datastream as dirty when relationships are added" do
|
246
246
|
mock_ds = mock("Rels-Ext")
|
247
|
-
mock_ds.
|
247
|
+
mock_ds.stubs(:content_will_change!)
|
248
248
|
@test_object.datastreams["RELS-EXT"] = mock_ds
|
249
249
|
@test_object.add_relationship(:is_member_of, "info:fedora/demo:5")
|
250
250
|
@test_object.add_relationship(:is_member_of, "info:fedora/demo:10")
|
@@ -398,46 +398,6 @@ describe ActiveFedora::Base do
|
|
398
398
|
@test_object.add_datastream(dirty_ds)
|
399
399
|
@test_object.expects(:update_index)
|
400
400
|
|
401
|
-
@test_object.save
|
402
|
-
end
|
403
|
-
it "should NOT update solr index if no SimpleDatastreams have changed" do
|
404
|
-
stub_ingest(@this_pid)
|
405
|
-
stub_add_ds(@this_pid, ['ds1', 'RELS-EXT'])
|
406
|
-
@test_object.save
|
407
|
-
@test_object.expects(:new_object?).returns(false).twice
|
408
|
-
ActiveFedora::DigitalObject.any_instance.stubs(:save)
|
409
|
-
mock1 = mock("ds1")
|
410
|
-
mock1.expects( :changed?).returns(false).at_least_once
|
411
|
-
mock1.expects(:serialize!)
|
412
|
-
mock2 = mock("ds2")
|
413
|
-
mock2.expects( :changed?).returns(false).at_least_once
|
414
|
-
mock2.expects(:serialize!)
|
415
|
-
@test_object.stubs(:datastreams).returns({:ds1 => mock1, :ds2 => mock2})
|
416
|
-
@test_object.expects(:update_index).never
|
417
|
-
@test_object.expects(:refresh)
|
418
|
-
@test_object.instance_variable_set(:@new_object, false)
|
419
|
-
|
420
|
-
@test_object.save
|
421
|
-
end
|
422
|
-
it "should update solr index if relationships have changed" do
|
423
|
-
stub_ingest(@this_pid)
|
424
|
-
|
425
|
-
rels_ext = ActiveFedora::RelsExtDatastream.new(@test_object.inner_object, 'RELS-EXT')
|
426
|
-
rels_ext.model = @test_object
|
427
|
-
rels_ext.expects(:changed?).returns(true).twice
|
428
|
-
rels_ext.expects(:save).returns(true)
|
429
|
-
rels_ext.expects(:serialize!)
|
430
|
-
clean_ds = mock("ds2", :digital_object=)
|
431
|
-
clean_ds.stubs(:dirty? => false, :changed? => false, :new? => false)
|
432
|
-
clean_ds.expects(:serialize!)
|
433
|
-
@test_object.datastreams["RELS-EXT"] = rels_ext
|
434
|
-
@test_object.datastreams[:clean_ds] = clean_ds
|
435
|
-
# @test_object.inner_object.stubs(:datastreams).returns({"RELS-EXT" => rels_ext, :clean_ds => clean_ds})
|
436
|
-
# @test_object.stubs(:datastreams).returns({"RELS-EXT" => rels_ext, :clean_ds => clean_ds})
|
437
|
-
@test_object.instance_variable_set(:@new_object, false)
|
438
|
-
@test_object.expects(:refresh)
|
439
|
-
@test_object.expects(:update_index)
|
440
|
-
|
441
401
|
@test_object.save
|
442
402
|
end
|
443
403
|
end
|
@@ -476,11 +436,11 @@ describe ActiveFedora::Base do
|
|
476
436
|
it "should propagate modified datastreams to the adapted object" do
|
477
437
|
@test_object = FooHistory.new()
|
478
438
|
orig_ds = @test_object.datastreams['someData']
|
479
|
-
orig_ds.content="YYY"
|
439
|
+
orig_ds.content="<YYY/>"
|
480
440
|
adapted = @test_object.adapt_to(FooAdaptation)
|
481
441
|
adapted.datastreams.keys.should include 'someData'
|
482
442
|
adapted.datastreams['someData'].should == orig_ds
|
483
|
-
adapted.datastreams['someData'].content.should == "YYY"
|
443
|
+
adapted.datastreams['someData'].content.strip.should == "<YYY/>"
|
484
444
|
adapted.datastreams['someData'].changed?.should be_true
|
485
445
|
end
|
486
446
|
it "should use the datastream definitions from the adapted object" do
|
@@ -585,7 +545,7 @@ describe ActiveFedora::Base do
|
|
585
545
|
it "should call .to_solr on the relationships rels-ext is dirty" do
|
586
546
|
@test_object.add_relationship(:has_collection_member, "info:fedora/foo:member")
|
587
547
|
rels_ext = @test_object.rels_ext
|
588
|
-
rels_ext.
|
548
|
+
rels_ext.should be_changed
|
589
549
|
@test_object.expects(:solrize_relationships)
|
590
550
|
@test_object.to_solr
|
591
551
|
end
|
@@ -212,7 +212,6 @@ describe ActiveFedora::DatastreamCollections do
|
|
212
212
|
thumb1.pid.should == @test_object2.pid
|
213
213
|
thumb1.dsLabel.should == 'minivan.jpg'
|
214
214
|
f.rewind
|
215
|
-
@test_object2.thumbnail.first.content.should == f.read
|
216
215
|
@test_object2.update_named_datastream("thumbnail",{:file=>f2,:dsid=>"THUMB1"})
|
217
216
|
@test_object2.thumbnail.size.should == 1
|
218
217
|
@test_object2.thumbnail_ids == ["THUMB1"]
|
@@ -226,8 +225,6 @@ describe ActiveFedora::DatastreamCollections do
|
|
226
225
|
thumb1.dsid.should == 'THUMB1'
|
227
226
|
thumb1.pid.should == @test_object2.pid
|
228
227
|
thumb1.dsLabel.should == 'dino.jpg'
|
229
|
-
f2.rewind
|
230
|
-
@test_object2.thumbnail.first.content.should == f2.read
|
231
228
|
end
|
232
229
|
end
|
233
230
|
describe '#named_datastreams_desc' do
|
@@ -293,8 +290,6 @@ describe ActiveFedora::DatastreamCollections do
|
|
293
290
|
datastreams["thumbnail"].first.dsid.should == 'THUMB1'
|
294
291
|
datastreams["thumbnail"].first.dsLabel.should == 'minivan.jpg'
|
295
292
|
datastreams["thumbnail"].first.controlGroup.should == "M"
|
296
|
-
f.rewind
|
297
|
-
datastreams["thumbnail"].first.content.should == f.read
|
298
293
|
|
299
294
|
datastreams["external"].size.should == 1
|
300
295
|
datastreams["external"].first.dsid.should == "EXTERNAL1"
|
@@ -306,8 +301,6 @@ describe ActiveFedora::DatastreamCollections do
|
|
306
301
|
datastreams["high"].first.dsLabel.should == 'dino.jpg'
|
307
302
|
datastreams["high"].first.controlGroup.should == "M"
|
308
303
|
datastreams["high"].first.dsid.should == "HIGH1"
|
309
|
-
f2.rewind
|
310
|
-
datastreams["high"].first.content.should == f2.read
|
311
304
|
end
|
312
305
|
end
|
313
306
|
|