active-fedora 3.0.7 → 3.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/Gemfile.lock +39 -10
- data/History.txt +0 -4
- data/active-fedora.gemspec +4 -3
- data/lib/active_fedora.rb +9 -9
- data/lib/active_fedora/base.rb +92 -163
- data/lib/active_fedora/datastream.rb +59 -60
- data/lib/active_fedora/datastream_hash.rb +18 -0
- data/lib/active_fedora/metadata_datastream.rb +3 -2
- data/lib/active_fedora/metadata_datastream_helper.rb +3 -15
- data/lib/active_fedora/model.rb +3 -3
- data/lib/active_fedora/nokogiri_datastream.rb +305 -302
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +24 -19
- data/lib/active_fedora/rels_ext_datastream.rb +39 -37
- data/lib/active_fedora/rubydora_connection.rb +40 -0
- data/lib/active_fedora/semantic_node.rb +1 -1
- data/lib/active_fedora/solr_service.rb +1 -1
- data/lib/active_fedora/version.rb +1 -1
- data/lib/ruby-fedora.rb +0 -8
- data/lib/tasks/active_fedora.rake +14 -9
- data/lib/tasks/active_fedora_dev.rake +23 -40
- data/spec/integration/base_loader_spec.rb +4 -21
- data/spec/integration/base_spec.rb +300 -310
- data/spec/integration/bug_spec.rb +9 -10
- data/spec/integration/datastream_spec.rb +12 -12
- data/spec/integration/metadata_datastream_helper_spec.rb +7 -10
- data/spec/integration/model_spec.rb +3 -2
- data/spec/integration/rels_ext_datastream_spec.rb +9 -15
- data/spec/spec_helper.rb +2 -29
- data/spec/unit/active_fedora_spec.rb +5 -5
- data/spec/unit/base_cma_spec.rb +0 -7
- data/spec/unit/base_datastream_management_spec.rb +8 -67
- data/spec/unit/base_delegate_spec.rb +26 -9
- data/spec/unit/base_extra_spec.rb +5 -3
- data/spec/unit/base_file_management_spec.rb +10 -17
- data/spec/unit/base_named_datastream_spec.rb +76 -199
- data/spec/unit/base_spec.rb +152 -69
- data/spec/unit/content_model_spec.rb +1 -1
- data/spec/unit/datastream_concurrency_spec.rb +5 -4
- data/spec/unit/datastream_spec.rb +28 -48
- data/spec/unit/has_many_collection_spec.rb +2 -0
- data/spec/unit/inheritance_spec.rb +6 -6
- data/spec/unit/metadata_datastream_spec.rb +12 -28
- data/spec/unit/model_spec.rb +10 -10
- data/spec/unit/nokogiri_datastream_spec.rb +31 -33
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +15 -15
- data/spec/unit/rels_ext_datastream_spec.rb +35 -29
- data/spec/unit/rubydora_connection_spec.rb +26 -0
- data/spec/unit/semantic_node_spec.rb +12 -17
- data/spec/unit/solr_config_options_spec.rb +13 -14
- data/spec/unit/solr_service_spec.rb +14 -17
- metadata +59 -55
- data/lib/fedora/base.rb +0 -38
- data/lib/fedora/connection.rb +0 -218
- data/lib/fedora/datastream.rb +0 -67
- data/lib/fedora/fedora_object.rb +0 -161
- data/lib/fedora/formats.rb +0 -30
- data/lib/fedora/generic_search.rb +0 -71
- data/lib/fedora/repository.rb +0 -298
- data/spec/integration/datastreams_crud_spec.rb +0 -208
- data/spec/integration/fedora_object_spec.rb +0 -77
- data/spec/integration/repository_spec.rb +0 -301
- data/spec/integration/rf_fedora_object_spec.rb +0 -95
- data/spec/unit/connection_spec.rb +0 -25
- data/spec/unit/fedora_object_spec.rb +0 -74
- data/spec/unit/repository_spec.rb +0 -143
- data/spec/unit/rf_datastream_spec.rb +0 -63
@@ -1,77 +0,0 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
|
3
|
-
require 'active_fedora'
|
4
|
-
|
5
|
-
#
|
6
|
-
# This is moving towards replacing the ActiveFedora::Base class with an ActiveFedora::FedoraObject module.
|
7
|
-
# => Work put on hold 01 October 2008 to wait for re-implementation of Fedora::Repository as a singleton
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
describe ActiveFedora::FedoraObject do
|
12
|
-
|
13
|
-
before :all do
|
14
|
-
class Fobject
|
15
|
-
include ActiveFedora::FedoraObject
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
@test_object = Fobject.new
|
21
|
-
end
|
22
|
-
|
23
|
-
after(:each) do
|
24
|
-
@test_object.delete
|
25
|
-
end
|
26
|
-
|
27
|
-
it "calling constructor should create a new Fedora Object" do
|
28
|
-
@test_object.should have(0).errors
|
29
|
-
@test_object.pid.should_not be_nil
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should return an Hash of the objects datastreams" do
|
33
|
-
datastreams = @test_object.datastreams
|
34
|
-
datastreams.should be_an_instance_of(Hash)
|
35
|
-
@test_object.datastreams["DC"].should be_an_instance_of(ActiveFedora::Datastream)
|
36
|
-
datastreams["DC"].should_not be_nil
|
37
|
-
datastreams["DC"].should be_an_instance_of(ActiveFedora::Datastream)
|
38
|
-
#datastreams["DC"].should be_an_instance_of(Hash)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should expose the DC datastream using dc method" do
|
42
|
-
dc = @test_object.dc
|
43
|
-
dc.should be_an_instance_of(ActiveFedora::Datastream)
|
44
|
-
rexml = REXML::Document.new(dc.content)
|
45
|
-
rexml.root.elements["dc:identifier"].get_text.should_not be_nil
|
46
|
-
#rexml.elements["dc:identifier"].should_not be_nil
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should respond to #rels_ext' do
|
50
|
-
@test_object.should respond_to(:rels_ext)
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#rels_ext' do
|
54
|
-
it 'should create the RELS-EXT datastream if it doesnt exist' do
|
55
|
-
mocker = mock("rels-ext")
|
56
|
-
ActiveFedora::RelsExtDatastream.expects(:new).returns(mocker)
|
57
|
-
@test_object.expects(:add).with(mocker)
|
58
|
-
# Make sure the RELS-EXT datastream does not exist yet
|
59
|
-
@test_object.datastreams["RELS-EXT"].should == nil
|
60
|
-
@test_object.rels_ext
|
61
|
-
# Assume that @test_object.add actually does its job and adds the datastream to the datastreams array. Not testing that here.
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should return the RelsExtDatastream object from the datastreams array' do
|
65
|
-
@test_object.expects(:datastreams).returns({"RELS-EXT" => "foo"}).at_least_once
|
66
|
-
@test_object.rels_ext.should == "foo"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should be able to add datastreams" do
|
71
|
-
ds = ActiveFedora::Datastream.new(:dsID => 'ds1.jpg', :dsLabel => 'hello', :altIDs => '3333',
|
72
|
-
:controlGroup => 'M', :blob => fixture('dino.jpg'))
|
73
|
-
@test_object.add_datastream(ds).should be_true
|
74
|
-
@test_object.save.should be_true
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
@@ -1,301 +0,0 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
|
3
|
-
# - Objects API - http://www.fedora-commons.org/documentation/3.0b1/userdocs/server/webservices/rest/index.html
|
4
|
-
|
5
|
-
# - Object profile
|
6
|
-
#
|
7
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10
|
8
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10.xml
|
9
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10?resultFormat=xml
|
10
|
-
#
|
11
|
-
# - Object history
|
12
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/versions
|
13
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/versions.xml
|
14
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/versions/2007-07-25T17:08:11.915Z
|
15
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/versions/2007-07-25T17:08:11.915Z.xml
|
16
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/versions/2007-07-25T17:08:11.915Z?resultFormat=xml
|
17
|
-
#
|
18
|
-
# - Object export
|
19
|
-
# curl -i -u fedoraAdmin:fedoraAdmin http://localhost:8080/fedora/objects/demo:10/export?resultFormat=foxml1.0&context=private
|
20
|
-
#
|
21
|
-
# - Object XML
|
22
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/objectXML
|
23
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/objectXML?resultFormat=xml
|
24
|
-
#
|
25
|
-
# - Object methods
|
26
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/methods
|
27
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/methods?resultFormat=xml
|
28
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/methods/2007-07-25T17:08:11.915Z
|
29
|
-
# curl -i http://localhost:8080/fedora/objects/demo:10/methods/2007-07-25T17:08:11.915Z.xml
|
30
|
-
#
|
31
|
-
# invalid: curl -i http://localhost:8080/fedora/objects/demo:10/methods.xml
|
32
|
-
#
|
33
|
-
# - Create
|
34
|
-
# curl -i -H "Content-type: text/xml" -XPOST "http://localhost:8080/fedora/objects/new?label=Test&namespace=test" --data "" -u fedoraAdmin:fedoraAdmin
|
35
|
-
# curl -i -H "Content-type: text/xml" -XPOST "http://localhost:9090/fedora/objects/new" --data "" -u fedoraAdmin:fedoraAdmin
|
36
|
-
#
|
37
|
-
# curl -i -H "Content-type: text/xml" -XPOST "http://localhost:8080/fedora/objects/test:02?label=Test" --data "" -u fedoraAdmin:fedoraAdmin
|
38
|
-
# curl -i -H "Content-type: text/xml" -XPOST "http://localhost:8080/fedora/objects/test:01?label=Test&altIDs=3333" --data-binary @foxml.xml -u fedoraAdmin:fedoraAdmin
|
39
|
-
#
|
40
|
-
# - Delete
|
41
|
-
# curl -i -u fedoraAdmin:fedoraAdmin -XDELETE http://localhost:8080/fedora/objects/demo:10
|
42
|
-
#
|
43
|
-
# Objects API
|
44
|
-
# curl -i http://localhost:8080/fedora/objects
|
45
|
-
# curl -i http://localhost:8080/fedora/objects?resultFormat=xml
|
46
|
-
# curl -i http://localhost:8080/fedora/objects/nextPID -u fedoraAdmin:fedoraAdmin
|
47
|
-
# curl -i http://localhost:8080/fedora/objects/nextPID.xml -u fedoraAdmin:fedoraAdmin
|
48
|
-
|
49
|
-
describe Fedora::Repository, "constructor" do
|
50
|
-
after(:all) do
|
51
|
-
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should accept URL as string" do
|
55
|
-
fedora_url = "http://fedoraAdmin:fedoraAdmin@127.0.0.1:8080/fedora"
|
56
|
-
repository = Fedora::Repository.register(fedora_url)
|
57
|
-
|
58
|
-
repository.fedora_url.should == URI.parse(fedora_url)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should accept URL as URI object" do
|
62
|
-
fedora_url = URI.parse("http://fedoraAdmin:fedoraAdmin@127.0.0.1:8080/fedora")
|
63
|
-
repository = Fedora::Repository.register(fedora_url)
|
64
|
-
|
65
|
-
repository.fedora_url.should == fedora_url
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should reject invalid url format" do
|
69
|
-
lambda { Fedora::Repository.register("http://:8080/") }.should raise_error
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe Fedora::Repository, "CRUD" do
|
74
|
-
before(:all) do
|
75
|
-
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
76
|
-
end
|
77
|
-
|
78
|
-
before(:each) do
|
79
|
-
@test_object = Fedora::FedoraObject.new(:label => 'test',
|
80
|
-
:state => 'A',
|
81
|
-
:ownerID => 'fedoraAdmin')
|
82
|
-
end
|
83
|
-
|
84
|
-
after(:each) do
|
85
|
-
if !@test_object.new_object?
|
86
|
-
begin
|
87
|
-
Fedora::Repository.instance.delete(@test_object)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should create new fedora object with auto pid" do
|
93
|
-
Fedora::Repository.instance.save(@test_object).should be_true
|
94
|
-
|
95
|
-
@test_object.should have(0).errors
|
96
|
-
@test_object.pid.should_not be_nil
|
97
|
-
@test_object.label.should == 'test'
|
98
|
-
@test_object.state.should == 'A'
|
99
|
-
@test_object.owner_id.should == 'fedoraAdmin'
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should create new fedora object with assigned pid" do
|
103
|
-
@test_object.pid = "demo:1000"
|
104
|
-
Fedora::Repository.instance.save(@test_object).should be_true
|
105
|
-
@test_object.should have(0).errors
|
106
|
-
@test_object.pid.should == "demo:1000"
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should update object state" do
|
110
|
-
Fedora::Repository.instance.save(@test_object).should be_true
|
111
|
-
|
112
|
-
@test_object.state = 'I'
|
113
|
-
Fedora::Repository.instance.update(@test_object).should be_true
|
114
|
-
@test_object.state.should == 'I'
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should delete object by ref" do
|
118
|
-
Fedora::Repository.instance.create(@test_object).should be_true
|
119
|
-
Fedora::Repository.instance.delete(@test_object).should be_true
|
120
|
-
# prevent after statement from attempting to delete again
|
121
|
-
@test_object.new_object = true
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should delete object by pid" do
|
125
|
-
Fedora::Repository.instance.create(@test_object).should be_true
|
126
|
-
Fedora::Repository.instance.delete(@test_object.uri).should be_true
|
127
|
-
# prevent after statement from attempting to delete again
|
128
|
-
@test_object.new_object = true
|
129
|
-
end
|
130
|
-
|
131
|
-
=begin
|
132
|
-
it "should fetch object profile Image of Coliseum in Rome" do
|
133
|
-
xml = Fedora::Repository.instance.fetch_content("demo:5")
|
134
|
-
validate_xml(xml, 'objectProfile')
|
135
|
-
xml.should =~ %r{Data Object (Coliseum) for Local Simple Image Demo}
|
136
|
-
end
|
137
|
-
=end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe Fedora::Repository, "find_objects" do
|
141
|
-
before(:all) do
|
142
|
-
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
143
|
-
end
|
144
|
-
|
145
|
-
def fields_to_s(fields)
|
146
|
-
fields.inject("") { |s, f| s += '&' + f.to_s + '=true' }
|
147
|
-
end
|
148
|
-
|
149
|
-
def when_find_objects(*args)
|
150
|
-
fake_connection = mock("Connection")
|
151
|
-
Fedora::Repository.instance.expects(:connection).returns(fake_connection)
|
152
|
-
yield fake_connection
|
153
|
-
|
154
|
-
Fedora::Repository.instance.find_objects(*args)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should include all fields by default" do
|
158
|
-
when_find_objects('label~Image*') { |conn|
|
159
|
-
conn.expects(:get).with('/fedora/objects?query=label%7EImage%2A&resultFormat=xml' + fields_to_s(Fedora::ALL_FIELDS))
|
160
|
-
}
|
161
|
-
end
|
162
|
-
|
163
|
-
it "should include all fields when :include => :all " do
|
164
|
-
when_find_objects('label~Image*', :include => :all) { |conn|
|
165
|
-
conn.expects(:get).with('/fedora/objects?query=label%7EImage%2A&resultFormat=xml' + fields_to_s(Fedora::ALL_FIELDS))
|
166
|
-
}
|
167
|
-
end
|
168
|
-
|
169
|
-
it "should fetch results with limit" do
|
170
|
-
when_find_objects('label~Image*', :limit => 10) { |conn|
|
171
|
-
conn.expects(:get).with('/fedora/objects?maxResults=10&query=label%7EImage%2A&resultFormat=xml' + fields_to_s(Fedora::ALL_FIELDS))
|
172
|
-
}
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should fetch results with some fields but not :pid" do
|
176
|
-
when_find_objects('label~Image*', :select => [:label, :mDate]) { |conn|
|
177
|
-
conn.expects(:get).with('/fedora/objects?query=label%7EImage%2A&resultFormat=xml' + fields_to_s([:pid, :label, :mDate]))
|
178
|
-
}
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should fetch results with some fields with :pid" do
|
182
|
-
when_find_objects('label~Image*', :select => [:pid, :label, :mDate]) { |conn|
|
183
|
-
conn.expects(:get).with('/fedora/objects?query=label%7EImage%2A&resultFormat=xml' + fields_to_s([:pid, :label, :mDate]))
|
184
|
-
}
|
185
|
-
end
|
186
|
-
|
187
|
-
def sample_response_xml(n = 1)
|
188
|
-
header = %Q(<result xmlns="http://www.fedora.info/definitions/1/0/types/">
|
189
|
-
<listSession>
|
190
|
-
<token>aToken</token>
|
191
|
-
<cursor>0</cursor>
|
192
|
-
</listSession>
|
193
|
-
<resultList>)
|
194
|
-
|
195
|
-
body = %Q(<objectFields>
|
196
|
-
<pid>demo:10</pid>
|
197
|
-
<label>Column Detail, Pavillion III, IVA Image Collection - University of Virginia</label>
|
198
|
-
</objectFields>) * n
|
199
|
-
|
200
|
-
header + body + %Q(</resultList></result>)
|
201
|
-
end
|
202
|
-
|
203
|
-
it "should convert xml response with 0 objectFields into array of FedoraObject" do
|
204
|
-
objects = when_find_objects('label~Image*', :select => [:pid, :label, :mDate]) { |conn|
|
205
|
-
conn.expects(:get).with('/fedora/objects?query=label%7EImage%2A&resultFormat=xml' + fields_to_s([:pid, :label, :mDate])).
|
206
|
-
returns(Fedora::XmlFormat.decode(sample_response_xml))
|
207
|
-
}
|
208
|
-
|
209
|
-
objects.session_token.should == 'aToken'
|
210
|
-
objects.should_not be_empty
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should return FedoraObjects with new_object set to false" do
|
214
|
-
objects = when_find_objects('label~Image*', :select => [:pid, :label, :mDate]) { |conn|
|
215
|
-
conn.expects(:get).with('/fedora/objects?query=label%7EImage%2A&resultFormat=xml' + fields_to_s([:pid, :label, :mDate])).
|
216
|
-
returns(Fedora::XmlFormat.decode(sample_response_xml))
|
217
|
-
}
|
218
|
-
objects.each do |obj|
|
219
|
-
obj.should_not be_new_object
|
220
|
-
end
|
221
|
-
|
222
|
-
end
|
223
|
-
|
224
|
-
it "should convert xml response with single objectFields into array of FedoraObject" do
|
225
|
-
objects = when_find_objects('label~Image*', :select => [:pid, :label, :mDate]) { |conn|
|
226
|
-
conn.expects(:get).with('/fedora/objects?query=label%7EImage%2A&resultFormat=xml' + fields_to_s([:pid, :label, :mDate])).
|
227
|
-
returns(Fedora::XmlFormat.decode(sample_response_xml(1)))
|
228
|
-
}
|
229
|
-
|
230
|
-
objects.session_token.should == 'aToken'
|
231
|
-
objects.should have(1).record
|
232
|
-
objects.first.pid.should == 'demo:10'
|
233
|
-
objects.first.should be_kind_of(Fedora::FedoraObject)
|
234
|
-
end
|
235
|
-
|
236
|
-
it "should convert xml response 2 objectFields into array of FedoraObject" do
|
237
|
-
objects = when_find_objects('label~Image*', :select => [:pid, :label, :mDate]) { |conn|
|
238
|
-
conn.expects(:get).with('/fedora/objects?query=label%7EImage%2A&resultFormat=xml' + fields_to_s([:pid, :label, :mDate])).
|
239
|
-
returns(Fedora::XmlFormat.decode(sample_response_xml(2)))
|
240
|
-
}
|
241
|
-
|
242
|
-
objects.session_token.should == 'aToken'
|
243
|
-
objects.should have(2).records
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
describe Fedora::Repository, "ingest" do
|
248
|
-
|
249
|
-
after(:each) do
|
250
|
-
begin
|
251
|
-
Fedora::Repository.instance.delete("test:12")
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
it "should successfully ingest foxml" do
|
256
|
-
foxml_file = fixture("test_12.foxml.xml")
|
257
|
-
foxml = fixture("test_12.foxml.xml").read
|
258
|
-
response = Fedora::Repository.instance.ingest(foxml_file)
|
259
|
-
response.code.should == "201"
|
260
|
-
response.body.should == "test:12"
|
261
|
-
end
|
262
|
-
|
263
|
-
end
|
264
|
-
|
265
|
-
describe Fedora::Repository do
|
266
|
-
before(:all) do
|
267
|
-
require 'rexml/document'
|
268
|
-
end
|
269
|
-
|
270
|
-
it "should fetch history" do
|
271
|
-
xml = Fedora::Repository.instance.fetch_custom("demo:20", :versions)
|
272
|
-
validate_xml(xml, 'fedoraObjectHistory')
|
273
|
-
xml.should =~ /pid="demo:20"/
|
274
|
-
end
|
275
|
-
|
276
|
-
it "should fetch profile" do
|
277
|
-
xml = Fedora::Repository.instance.fetch_custom("demo:20", :profile)
|
278
|
-
validate_xml(xml, 'objectProfile')
|
279
|
-
xml.should =~ /pid="demo:20"/
|
280
|
-
end
|
281
|
-
|
282
|
-
it "should fetch export" do
|
283
|
-
xml = Fedora::Repository.instance.fetch_custom("demo:20", :export)
|
284
|
-
validate_xml(xml, 'digitalObject')
|
285
|
-
xml.should =~ /demo:20/
|
286
|
-
xml.should =~ /datastream/
|
287
|
-
end
|
288
|
-
|
289
|
-
it "should fetch objectXML" do
|
290
|
-
xml = Fedora::Repository.instance.fetch_custom("demo:20", :objectXML)
|
291
|
-
xml.should =~ /digitalObject/
|
292
|
-
xml.should =~ /pid="demo:20"/i
|
293
|
-
end
|
294
|
-
|
295
|
-
it "should list object methods" do
|
296
|
-
xml = Fedora::Repository.instance.fetch_custom("demo:20", :methods)
|
297
|
-
xml.should =~ /objectMethods/
|
298
|
-
xml.should =~ /pid="demo:20"/i
|
299
|
-
end
|
300
|
-
|
301
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
|
3
|
-
require "rexml/document"
|
4
|
-
|
5
|
-
describe Fedora::FedoraObject do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
9
|
-
@test_object = Fedora::FedoraObject.new(:pid=>"demo:1000")
|
10
|
-
Fedora::Repository.instance.save(@test_object)
|
11
|
-
end
|
12
|
-
|
13
|
-
after(:each) do
|
14
|
-
Fedora::Repository.instance.delete(@test_object)
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#object_xml' do
|
18
|
-
it "should return XML with a root of digitalObject with namespace info:fedora/fedora-system:def/foxml#" do
|
19
|
-
object_rexml = REXML::Document.new(@test_object.object_xml)
|
20
|
-
object_rexml.root.name.should == "digitalObject"
|
21
|
-
object_rexml.root.namespace.should == "info:fedora/fedora-system:def/foxml#"
|
22
|
-
object_rexml.root.elements["foxml:objectProperties/foxml:property[@NAME='info:fedora/fedora-system:def/model#state']"].attributes["VALUE"].should_not be_nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#profile' do
|
27
|
-
it "should return an array with misc Fedora Object attributes" do
|
28
|
-
profile = @test_object.profile
|
29
|
-
profile.class.should == Hash
|
30
|
-
profile.empty?.should_not == true
|
31
|
-
#profile.class.should_not be_empty
|
32
|
-
profile.should have_key(:owner_id)
|
33
|
-
profile[:owner_id].should == "fedoraAdmin"
|
34
|
-
#profile.should have_key(:content_model)
|
35
|
-
profile.should have_key(:label)
|
36
|
-
profile.should have_key(:create_date)
|
37
|
-
profile.should have_key(:modified_date)
|
38
|
-
profile.should have_key(:methods_list_url)
|
39
|
-
profile.should have_key(:datastreams_list_url)
|
40
|
-
profile.should have_key(:state)
|
41
|
-
profile[:state].should == "A"
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should allow access to fedora object info" do
|
47
|
-
@test_object.label = "test"
|
48
|
-
Fedora::Repository.instance.save(@test_object)
|
49
|
-
obj = Fedora::Repository.instance.find_objects("pid=#{@test_object.pid}").first
|
50
|
-
obj.pid.should == "demo:1000"
|
51
|
-
obj.label.should == 'test'
|
52
|
-
obj.state.should == 'A'
|
53
|
-
obj.owner_id.should == 'fedoraAdmin'
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "properties_from_fedora" do
|
57
|
-
it" should return the object properties from fedora" do
|
58
|
-
@test_object.label = "test"
|
59
|
-
Fedora::Repository.instance.save(@test_object)
|
60
|
-
properties = @test_object.properties_from_fedora
|
61
|
-
properties[:pid].should == "demo:1000"
|
62
|
-
properties[:state].should == 'A'
|
63
|
-
properties[:create_date].should == @test_object.profile[:create_date]
|
64
|
-
properties[:modified_date].should == @test_object.profile[:modified_date]
|
65
|
-
properties[:label].should == 'test'
|
66
|
-
properties[:owner_id].should == 'fedoraAdmin'
|
67
|
-
end
|
68
|
-
it "should not set :label if it is not there in the object_xml" do
|
69
|
-
object_rexml = REXML::Document.new(@test_object.object_xml)
|
70
|
-
# The label node will be missing from the FOXML because label was never set.
|
71
|
-
object_rexml.root.elements["//foxml:property[@NAME='info:fedora/fedora-system:def/model#label']"].attributes["VALUE"].should == ""
|
72
|
-
properties = @test_object.properties_from_fedora
|
73
|
-
properties[:label].should == nil
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "load_attr_from_fedora" do
|
78
|
-
it "should push all of the properties from fedora into the objects attributes" do
|
79
|
-
@test_object.label = "test"
|
80
|
-
Fedora::Repository.instance.save(@test_object)
|
81
|
-
@test_object.attributes.should == {:pid=>"demo:1000", :label=>"test"}
|
82
|
-
@test_object.load_attributes_from_fedora
|
83
|
-
#{:create_date=>"2009-07-16T17:42:33.548Z", :label=>"test", :modified_date=>"2009-07-16T17:42:33.548Z", :state=>"Active", :pid=>"demo:1000", :owner_id=>"fedoraAdmin"}
|
84
|
-
@test_object.attributes[:pid].should == "demo:1000"
|
85
|
-
@test_object.attributes[:state].should == 'A'
|
86
|
-
#@test_object.attributes[:state].should == 'Active'
|
87
|
-
@test_object.attributes[:create_date].should == @test_object.profile[:create_date]
|
88
|
-
@test_object.attributes[:modified_date].should == @test_object.profile[:modified_date]
|
89
|
-
@test_object.attributes[:label].should == 'test'
|
90
|
-
@test_object.attributes[:owner_id].should == 'fedoraAdmin'
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
end
|