active-fedora 3.0.7 → 3.1.0.pre1
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/.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,25 +0,0 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
|
3
|
-
require 'active_resource'
|
4
|
-
require 'fedora/repository'
|
5
|
-
|
6
|
-
describe Fedora::Connection do
|
7
|
-
it "should be creatable w/ a surrogate id" do
|
8
|
-
c = Fedora::Connection.new('http://127.0.0.1/fedora', 'fubar', 'bob')
|
9
|
-
c.site.to_s.should == "http://127.0.0.1/fedora"
|
10
|
-
c.format.should == 'fubar'
|
11
|
-
c.surrogate.should == 'bob'
|
12
|
-
end
|
13
|
-
it "should set a from header if surrogate defined." do
|
14
|
-
c = Fedora::Connection.new('http://127.0.0.1/fedora', ActiveResource::Formats[:xml], 'bob')
|
15
|
-
h = Hash.new
|
16
|
-
r= c.send(:build_request_headers,h)
|
17
|
-
r['From'].should == 'bob'
|
18
|
-
end
|
19
|
-
it "should not set a from header if surrogate undefined." do
|
20
|
-
c = Fedora::Connection.new('http://127.0.0.1/fedora' )
|
21
|
-
h = Hash.new
|
22
|
-
r= c.send(:build_request_headers,h)
|
23
|
-
r['From'].should be_nil
|
24
|
-
end
|
25
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
|
3
|
-
describe Fedora::FedoraObject do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
7
|
-
@test_object = Fedora::FedoraObject.new
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should respond to #object_xml' do
|
11
|
-
Fedora::FedoraObject.should respond_to(:object_xml)
|
12
|
-
end
|
13
|
-
it 'hash should not have to_query) on it' do
|
14
|
-
Fedora::BaseObject.new
|
15
|
-
{:foo=>:bar}.to_fedora_query.should == 'foo=bar'
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should respond to .object_xml' do
|
19
|
-
@test_object.should respond_to(:object_xml)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should provide .url" do
|
23
|
-
@test_object.should respond_to(:url)
|
24
|
-
end
|
25
|
-
|
26
|
-
describe ".url" do
|
27
|
-
it "should return the Repository fedora_url with /objects/pid appended" do
|
28
|
-
Fedora::Repository.instance.expects(:fedora_url).returns(mock("fedora url", :scheme => "_scheme_", :host => "_host_", :port => "_port_", :path => "_path_"))
|
29
|
-
@test_object.expects(:pid).returns("_PID_")
|
30
|
-
@test_object.url.should == "_scheme_://_host_:_port__path_/objects/_PID_"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe ".label" do
|
35
|
-
before(:all) do
|
36
|
-
@properties = [:label, :state, :modified_date, :create_date, :owner_id]
|
37
|
-
@sample_attributes = {:label => "label", :state => "state", :modified_date => "modified_date", :create_date => "create_date", :owner_id => "owner_id"}
|
38
|
-
end
|
39
|
-
it "should give preference to pulling from attributes hash" do
|
40
|
-
@test_object.expects(:attributes).times(@properties.length*2).returns(@sample_attributes)
|
41
|
-
@properties.each do |p|
|
42
|
-
@test_object.send(p)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should rely solely on attributes hash if new_object" do
|
47
|
-
@test_object.new_object = true
|
48
|
-
@test_object.expects(:properties_from_fedora).never
|
49
|
-
@test_object.expects(:attributes).times(@properties.length*2).returns(@sample_attributes)
|
50
|
-
@properties.each do |p|
|
51
|
-
@test_object.send(p)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should call properties_from_fedora if not a new_object" do
|
56
|
-
@test_object.new_object = false
|
57
|
-
@test_object.expects(:properties_from_fedora).times(@properties.length).returns(@sample_attributes)
|
58
|
-
@test_object.expects(:attributes).times(@properties.length).returns({})
|
59
|
-
@properties.each do |p|
|
60
|
-
@test_object.send(p)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
describe ".owner_id=" do
|
67
|
-
it "should update the attributes hash with ownerId attribute" do
|
68
|
-
@test_object.owner_id.should be_nil
|
69
|
-
@test_object.owner_id="fooTest"
|
70
|
-
@test_object.attributes[:ownerId].should == "fooTest"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
@@ -1,143 +0,0 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
|
3
|
-
describe Fedora::Repository do
|
4
|
-
|
5
|
-
after(:all) do
|
6
|
-
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should trim extra slash on uri" do
|
10
|
-
Fedora::Repository.expects(:new).with('http://bar.baz/bat', nil)
|
11
|
-
Fedora::Repository.register('http://bar.baz/bat/')
|
12
|
-
Fedora::Repository.expects(:new).with('http://bar.baz/bat', nil)
|
13
|
-
Fedora::Repository.register(URI.parse('http://bar.baz/bat/'))
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should accept a url to register" do
|
17
|
-
Fedora::Repository.expects(:new).with('http://bar.baz', nil).returns(stub_everything)
|
18
|
-
Fedora::Repository.register('http://bar.baz').should_not be_nil
|
19
|
-
z = Fedora::Repository.instance
|
20
|
-
z.should_not be_nil
|
21
|
-
(z === Fedora::Repository.instance).should == true
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should initialize a repo" do
|
25
|
-
Fedora::Repository.expects(:new).with('http://foo.bar', nil).returns(stub_everything)
|
26
|
-
Fedora::Repository.register('http://foo.bar')
|
27
|
-
z = Fedora::Repository.instance
|
28
|
-
y = Fedora::Repository.instance
|
29
|
-
z.should_not be_nil
|
30
|
-
y.should_not be_nil
|
31
|
-
(z===y).should == true
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should be a singleton' do
|
35
|
-
Fedora::Repository.expects(:new).with('http://foo.bar',nil).returns(stub_everything)
|
36
|
-
Fedora::Repository.register('http://foo.bar')
|
37
|
-
a = Fedora::Repository.instance
|
38
|
-
b = Fedora::Repository.instance
|
39
|
-
(a === b).should == true
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should be able to reserve an id" do
|
43
|
-
bodymock = mock('body')
|
44
|
-
bodymock.expects(:body).returns <<-EOS
|
45
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
46
|
-
<pidList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fedora.info/definitions/1/0/management/ http://www.fedora.info/definitions/1/0/objectHistory.xsd">
|
47
|
-
<pid>changeme:5035</pid>
|
48
|
-
</pidList>
|
49
|
-
EOS
|
50
|
-
|
51
|
-
Fedora::Repository.register('http://fedoraAdmin:fedoraAdmin@127.0.0.1:8080/fedora').should_not be_nil
|
52
|
-
Fedora::Repository.instance.send(:connection).expects(:post).with('/fedora/management/getNextPID?xml=true').returns(bodymock)
|
53
|
-
Fedora::Repository.instance.should_not be_nil
|
54
|
-
Fedora::Repository.instance.nextid.should == 'changeme:5035'
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should have attributes corresponding to the info in fedora/describe" do
|
58
|
-
Fedora::Repository.register('http://foo.bar')
|
59
|
-
#skipping oai_namespace_identifier and oai_delimiter
|
60
|
-
%w[repository_name base_url fedora_version pid_namespace pid_delimiter].each do |attribute_name|
|
61
|
-
Fedora::Repository.instance.should respond_to(attribute_name)
|
62
|
-
Fedora::Repository.instance.should respond_to(attribute_name + "=")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "export" do
|
67
|
-
it "should call fetch_custom with the appropriate parameters" do
|
68
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:FOXML-1.1", :context=>"archive")
|
69
|
-
Fedora::Repository.instance.export("test:my_pid")
|
70
|
-
end
|
71
|
-
it "should support :foxml, :mets, :atom, and :atom_zip" do
|
72
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOM-1.1", :context=>"archive")
|
73
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOMZip-1.1", :context=>"archive")
|
74
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:FOXML-1.1", :context=>"archive")
|
75
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:METSFedoraExt-1.1", :context=>"archive")
|
76
|
-
|
77
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>:atom)
|
78
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>:atom_zip)
|
79
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>:foxml)
|
80
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>:mets)
|
81
|
-
end
|
82
|
-
it "should allow you to pass through the format uri as a string" do
|
83
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOMZip-1.1", :context=>"archive")
|
84
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>"info:fedora/fedora-system:ATOMZip-1.1")
|
85
|
-
end
|
86
|
-
it "should support export context" do
|
87
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOM-1.1", :context=>"public").times(2)
|
88
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOM-1.1", :context=>"migrate")
|
89
|
-
Fedora::Repository.instance.expects(:fetch_custom).with("test:my_pid", "export", :format=>"info:fedora/fedora-system:ATOM-1.1", :context=>"archive")
|
90
|
-
|
91
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>:atom, :context=>:public)
|
92
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>:atom, :context=>"public")
|
93
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>:atom, :context=>:migrate)
|
94
|
-
Fedora::Repository.instance.export("test:my_pid", :format=>:atom, :context=>:archive)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "ingest" do
|
99
|
-
it "should post the provided xml or file to fedora" do
|
100
|
-
foxml = fixture("test_12.foxml.xml").read
|
101
|
-
connection = Fedora::Repository.instance.send(:connection)
|
102
|
-
connection.expects(:post).with("/fedora/objects/new",foxml)
|
103
|
-
Fedora::Repository.instance.ingest(foxml)
|
104
|
-
end
|
105
|
-
it "should accept a file as its input" do
|
106
|
-
foxml_file = fixture("test_12.foxml.xml")
|
107
|
-
foxml = fixture("test_12.foxml.xml").read
|
108
|
-
connection = Fedora::Repository.instance.send(:connection)
|
109
|
-
connection.expects(:post).with("/fedora/objects/new",foxml)
|
110
|
-
Fedora::Repository.instance.ingest(foxml_file)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe ".find_model" do
|
115
|
-
it "should raise an ObjectNotFound error if there is no object" do
|
116
|
-
Fedora::Repository.instance.expects(:find_objects).returns([])
|
117
|
-
lambda { Fedora::Repository.instance.find_model("mypid", ActiveFedora::Base) }.should raise_error(ActiveFedora::ObjectNotFoundError)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe "#register" do
|
122
|
-
after(:all) do
|
123
|
-
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
124
|
-
end
|
125
|
-
it "should initialize the attributes from fedora/describe" do
|
126
|
-
sample_attrs = {"sampleSearch-URL"=>["http://127.0.0.1:8080/fedora/search"], "repositoryOAI-identifier"=>[{"OAI-sample"=>["oai:example.org:changeme:100"], "OAI-delimiter"=>[":"], "OAI-namespaceIdentifier"=>["example.org"]}], "repositoryBaseURL"=>["http://127.0.0.1:8080/fedora"], "xsi:schemaLocation"=>"http://www.fedora.info/definitions/1/0/access/ http://www.fedora.info/definitions/1/0/fedoraRepository.xsd", "xmlns:xsd"=>"http://www.w3.org/2001/XMLSchema", "repositoryPID"=>[{"PID-sample"=>["changeme:100"], "PID-namespaceIdentifier"=>["changeme"], "PID-delimiter"=>[":"], "retainPID"=>["*"]}], "adminEmail"=>["bob@example.org", "sally@example.org"], "repositoryVersion"=>["3.1"], "sampleOAI-URL"=>["http://localhost:8080/fedora/oai?verb=Identify"], "sampleAccess-URL"=>["http://localhost:8080/fedora/get/demo:5"], "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance", "repositoryName"=>["Fedora Repository"]}
|
127
|
-
Fedora::Repository.any_instance.expects(:describe_repository).returns(sample_attrs)
|
128
|
-
Fedora::Repository.register('http://foo.bar')
|
129
|
-
boo = Fedora::Repository.instance
|
130
|
-
boo.repository_name.should == "Fedora Repository"
|
131
|
-
boo.base_url.should == "http://127.0.0.1:8080/fedora"
|
132
|
-
boo.fedora_version.should == "3.1"
|
133
|
-
boo.pid_namespace.should == "changeme"
|
134
|
-
boo.pid_delimiter.should == ":"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
|
139
|
-
it "should provide .describe_repository" do
|
140
|
-
Fedora::Repository.instance.should respond_to(:describe_repository)
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
-
|
3
|
-
require 'ruby-fedora'
|
4
|
-
|
5
|
-
|
6
|
-
describe Fedora::Datastream do
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
10
|
-
@test_datastream = Fedora::Datastream.new
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should track the controlgroup attr" do
|
14
|
-
td = Fedora::Datastream.new(:controlGroup=>'M')
|
15
|
-
td.control_group.should == 'M'
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should provide .url" do
|
19
|
-
@test_datastream.should respond_to(:url)
|
20
|
-
@test_datastream.expects(:pid).returns("_foo_")
|
21
|
-
@test_datastream.url.should == 'http://localhost:8983/fedora/objects/_foo_/datastreams/'
|
22
|
-
end
|
23
|
-
|
24
|
-
describe ".url" do
|
25
|
-
it "should return the Repository base_url with /objects/pid appended" do
|
26
|
-
Fedora::Repository.instance.expects(:base_url).returns("BASE_URL")
|
27
|
-
@test_datastream.expects(:pid).returns("_PID_")
|
28
|
-
@test_datastream.expects(:dsid).returns("_DSID_")
|
29
|
-
@test_datastream.url.should == "BASE_URL/objects/_PID_/datastreams/_DSID_"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe ".label" do
|
34
|
-
it "should return the dsLabel attribute" do
|
35
|
-
@test_datastream.label.should == @test_datastream.attributes[:dsLabel]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe ".label=" do
|
40
|
-
it "should set the dsLabel attribute" do
|
41
|
-
@test_datastream.label.should_not == "Foo dsLabel"
|
42
|
-
@test_datastream.attributes[:dsLabel].should_not == "Foo dsLabel"
|
43
|
-
@test_datastream.label = "Foo dsLabel"
|
44
|
-
@test_datastream.label.should == "Foo dsLabel"
|
45
|
-
@test_datastream.attributes[:dsLabel].should == "Foo dsLabel"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe ".mime_type" do
|
50
|
-
it "should return the mimeType attribute" do
|
51
|
-
@test_datastream.mime_type.should == @test_datastream.attributes["mimeType"]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe ".mime_type=" do
|
56
|
-
it "should set the mimeType attribute" do
|
57
|
-
@test_datastream.mime_type.should_not == "foo/bar"
|
58
|
-
@test_datastream.attributes["mimeType"].should_not == "foo/bar"
|
59
|
-
@test_datastream.mime_type= "foo/bar"
|
60
|
-
@test_datastream.mime_type.should == "foo/bar"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|