active-fedora 3.2.2 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +33 -57
- data/History.txt +9 -0
- data/active-fedora.gemspec +5 -5
- data/lib/active_fedora.rb +37 -10
- data/lib/active_fedora/base.rb +0 -18
- data/lib/active_fedora/datastream.rb +10 -5
- data/lib/active_fedora/datastreams.rb +33 -7
- data/lib/active_fedora/dcrdf_datastream.rb +11 -0
- data/lib/active_fedora/delegating.rb +2 -2
- data/lib/active_fedora/metadata_datastream.rb +3 -2
- data/lib/active_fedora/nested_attributes.rb +0 -1
- data/lib/active_fedora/ntriples_rdf_datastream.rb +19 -0
- data/lib/active_fedora/predicates.rb +4 -0
- data/lib/active_fedora/rdf_datastream.rb +108 -0
- data/lib/active_fedora/rdf_xml_writer.rb +53 -41
- data/lib/active_fedora/relationship_graph.rb +15 -71
- data/lib/active_fedora/rels_ext_datastream.rb +1 -4
- data/lib/active_fedora/rubydora_connection.rb +2 -9
- data/lib/active_fedora/unsaved_digital_object.rb +1 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora_dev.rake +1 -1
- data/spec/fixtures/dublin_core_rdf_descMetadata.nt +13 -0
- data/spec/fixtures/rails_root/config/fedora.yml +1 -15
- data/spec/integration/base_loader_spec.rb +0 -1
- data/spec/integration/dc_rdf_datastream_spec.rb +24 -0
- data/spec/integration/full_featured_model_spec.rb +1 -1
- data/spec/integration/model_spec.rb +0 -1
- data/spec/unit/active_fedora_spec.rb +22 -14
- data/spec/unit/base_spec.rb +9 -184
- data/spec/unit/datastream_collections_spec.rb +2 -2
- data/spec/unit/datastream_spec.rb +36 -6
- data/spec/unit/datastreams_spec.rb +251 -0
- data/spec/unit/dc_rdf_datastream_spec.rb +50 -0
- data/spec/unit/metadata_datastream_spec.rb +1 -1
- data/spec/unit/nokogiri_datastream_spec.rb +2 -2
- data/spec/unit/{rdf_xml_writer.rb → rdf_xml_writer_spec.rb} +8 -8
- data/spec/unit/relationship_graph_spec.rb +14 -0
- data/spec/unit/rels_ext_datastream_spec.rb +29 -2
- data/spec/unit/rubydora_connection_spec.rb +2 -4
- data/spec/unit/unsaved_digital_object_spec.rb +22 -9
- metadata +106 -258
- data/.hg/00changelog.i +0 -0
- data/.hg/branch +0 -1
- data/.hg/branch.cache +0 -2
- data/.hg/dirstate +0 -0
- data/.hg/hgrc +0 -2
- data/.hg/requires +0 -2
- data/.hg/store/00changelog.i +0 -0
- data/.hg/store/00manifest.i +0 -0
- data/.hg/store/data/.hgignore.i +0 -0
- data/.hg/store/data/.hgtags.i +0 -0
- data/.hg/store/data/_c_o_p_y_i_n_g.txt.i +0 -0
- data/.hg/store/data/_c_o_y_i_n_g._l_e_s_s_e_r.txt.i +0 -0
- data/.hg/store/data/_history.txt.i +0 -0
- data/.hg/store/data/_license.txt.i +0 -0
- data/.hg/store/data/_manifest.txt.i +0 -0
- data/.hg/store/data/_post_install.txt.i +0 -0
- data/.hg/store/data/_r_e_a_d_m_e.rdoc.i +0 -0
- data/.hg/store/data/_r_e_a_d_m_e.txt.i +0 -0
- data/.hg/store/data/_rakefile.i +0 -0
- data/.hg/store/data/_v_e_r_s_i_o_n.i +0 -0
- data/.hg/store/data/active-fedora.gemspec.i +0 -0
- data/.hg/store/data/active__fedora/_history.txt.i +0 -0
- data/.hg/store/data/active__fedora/_manifest.txt.i +0 -0
- data/.hg/store/data/active__fedora/_post_install.txt.i +0 -0
- data/.hg/store/data/active__fedora/_r_e_a_d_m_e.rdoc.i +0 -0
- data/.hg/store/data/active__fedora/_rakefile.i +0 -0
- data/.hg/store/data/active__fedora/lib/active__fedora.rb.i +0 -0
- data/.hg/store/data/active__fedora/script/console.i +0 -0
- data/.hg/store/data/active__fedora/script/destroy.i +0 -0
- data/.hg/store/data/active__fedora/script/generate.i +0 -0
- data/.hg/store/data/active__fedora/spec/active__fedora__spec.rb.i +0 -0
- data/.hg/store/data/active__fedora/spec/spec__helper.rb.i +0 -0
- data/.hg/store/data/config/fedora.yml.i +0 -0
- data/.hg/store/data/config/solr__mappings.yml.i +0 -0
- data/.hg/store/data/config/solr__mappings__af__0.1.yml.i +0 -0
- data/.hg/store/data/config/solr__mappings__bl__2.4.yml.i +0 -0
- data/.hg/store/data/lib/active-fedora.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/base.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/content__model.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/datastream.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/fedora__object.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/metadata__datastream.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/model.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/property.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/qualified__dublin__core__datastream.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/relationship.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/rels__ext__datastream.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/semantic__node.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/solr__mapper.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/solr__service.rb.i +0 -0
- data/.hg/store/data/lib/fedora/base.rb.i +0 -0
- data/.hg/store/data/lib/fedora/connection.rb.i +0 -0
- data/.hg/store/data/lib/fedora/datastream.rb.i +0 -0
- data/.hg/store/data/lib/fedora/fedora__object.rb.i +0 -0
- data/.hg/store/data/lib/fedora/formats.rb.i +0 -0
- data/.hg/store/data/lib/fedora/generic__search.rb.i +0 -0
- data/.hg/store/data/lib/fedora/repository.rb.i +0 -0
- data/.hg/store/data/lib/ruby-fedora.rb.i +0 -0
- data/.hg/store/data/lib/util/class__level__inheritable__attributes.rb.i +0 -0
- data/.hg/store/data/script/console.i +0 -0
- data/.hg/store/data/script/destroy.i +0 -0
- data/.hg/store/data/script/generate.i +0 -0
- data/.hg/store/data/solr/config/schema-1.5.xml.i +0 -0
- data/.hg/store/data/solr/config/schema.xml.i +0 -0
- data/.hg/store/data/solr/config/solrconfig-1.5.xml.i +0 -0
- data/.hg/store/data/spec/fixtures/changeme155.xml.i +0 -0
- data/.hg/store/data/spec/fixtures/dino.jpg.i +0 -0
- data/.hg/store/data/spec/fixtures/minivan.jpg.d +0 -0
- data/.hg/store/data/spec/fixtures/minivan.jpg.i +0 -0
- data/.hg/store/data/spec/fixtures/test__12.foxml.xml.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/base__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/fedora__object__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/full__featured__model__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/model__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/semantic__node__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/base__file__management__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/base__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/bug__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/datastreams__crud__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/fedora__object__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/full__featured__model__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/model__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/rels__ext__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/repository__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/rf__fedora__object__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/semantic__node__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/solr__service__spec.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/audio__record.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/image.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/oral__history.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/seminar.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/seminar__audio__file.rb.i +0 -0
- data/.hg/store/data/spec/samples/oh__qdc.xml.i +0 -0
- data/.hg/store/data/spec/samples/oral__history.rb.i +0 -0
- data/.hg/store/data/spec/samples/oral__history__sample.xml.i +0 -0
- data/.hg/store/data/spec/samples/oral__history__sample__model.rb.i +0 -0
- data/.hg/store/data/spec/samples/oral__history__xml.xml.i +0 -0
- data/.hg/store/data/spec/spec.opts.i +0 -0
- data/.hg/store/data/spec/spec__helper.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/base__cma__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/base__extra__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/base__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/content__model__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/inheritance__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/metadata__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/model__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/property__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/qualified__dublin__core__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/relationship__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/semantic__node__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/solr__service__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__cma__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__datastream__management__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__extra__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__file__management__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__loader__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/connection__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/content__model__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/datastream__concurrency__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/fedora__object__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/inheritance__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/metadata__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/model__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/property__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/qualified__dublin__core__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/relationship__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/rels__ext__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/repository__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/rf__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/semantic__node__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/solr__config__options__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/solr__mapper__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/solr__service__spec.rb.i +0 -0
- data/.hg/store/data/tasks/rspec.rake.i +0 -0
- data/.hg/store/undo +0 -0
- data/.hg/undo.branch +0 -1
- data/.hg/undo.dirstate +0 -0
- data/.hgignore +0 -7
- data/.hgtags +0 -14
@@ -9,13 +9,6 @@ module ActiveFedora
|
|
9
9
|
|
10
10
|
def self.connect(params={})
|
11
11
|
params = params.dup
|
12
|
-
if params.kind_of? String
|
13
|
-
u = URI.parse params
|
14
|
-
params = {}
|
15
|
-
params[:user] = u.user
|
16
|
-
params[:password] = u.password
|
17
|
-
params[:url] = "#{u.scheme}://#{u.host}:#{u.port}#{u.path}"
|
18
|
-
end
|
19
12
|
instance = self.instance
|
20
13
|
force = params.delete(:force)
|
21
14
|
instance.options = params
|
@@ -26,14 +19,14 @@ module ActiveFedora
|
|
26
19
|
def connection
|
27
20
|
return @connection if @connection
|
28
21
|
ActiveFedora.load_configs
|
29
|
-
ActiveFedora::RubydoraConnection.connect(ActiveFedora.
|
22
|
+
ActiveFedora::RubydoraConnection.connect(ActiveFedora.config_for_environment)
|
30
23
|
@connection
|
31
24
|
end
|
32
25
|
|
33
26
|
|
34
27
|
def connect(force=false)
|
35
28
|
return unless @connection.nil? or force
|
36
|
-
allowable_options = [:url, :user, :password, :timeout, :open_timeout, :ssl_client_cert, :ssl_client_key]
|
29
|
+
allowable_options = [:url, :user, :password, :timeout, :open_timeout, :ssl_client_cert, :ssl_client_key, :validateChecksum]
|
37
30
|
client_options = options.reject { |k,v| not allowable_options.include?(k) }
|
38
31
|
#puts "CLIENT OPTS #{client_options.inspect}"
|
39
32
|
@connection = Rubydora.connect client_options
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/description> "This is a work by JD in the field of biology." .
|
2
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/publisher> "Penn State" .
|
3
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/contributor> "Department of Bioinformatics" .
|
4
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/created> "2010-12-31"^^<http://www.w3.org/2001/XMLSchema#date> .
|
5
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/title> "Title of work" .
|
6
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/subject> "Biology" .
|
7
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/language> "en" .
|
8
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/date> "2009-12-31"^^<http://www.w3.org/2001/XMLSchema#date> .
|
9
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/rights> "insert rights statement here" .
|
10
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/type> <http://purl.org/dc/dcmitype/Image> .
|
11
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/format> "image/jpeg" .
|
12
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/creator> "John Doe" .
|
13
|
+
<http://id.psu.edu/object42> <http://purl.org/dc/terms/identifier> "old:identifier:7779" .
|
@@ -1,16 +1,2 @@
|
|
1
|
-
development:
|
2
|
-
fedora:
|
3
|
-
url: http://fedoraAdmin:fedoraAdmin@testhost.com:8983/fedora
|
4
|
-
solr:
|
5
|
-
url: http://testhost.com:8983/solr/development
|
6
1
|
test:
|
7
|
-
fedora
|
8
|
-
url: http://fedoraAdmin:fedoraAdmin@testhost.com:8983/fedora
|
9
|
-
solr:
|
10
|
-
url: http://testhost.com:8983/solr/development
|
11
|
-
production:
|
12
|
-
fedora:
|
13
|
-
url: http://fedoraAdmin:fedoraAdmin@testhost.com:8080/fedora
|
14
|
-
solr:
|
15
|
-
url: http://testhost.com:8080/solr
|
16
|
-
|
2
|
+
url: http://fedoraAdmin:fedoraAdmin@testhost.com:8983/fedora
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::DCRDFDatastream do
|
4
|
+
before do
|
5
|
+
class RdfTest < ActiveFedora::Base
|
6
|
+
has_metadata :name=>'rdf', :type=>ActiveFedora::DCRDFDatastream
|
7
|
+
delegate :description, :to=>'rdf'
|
8
|
+
delegate :title, :to=>'rdf', :unique=>true
|
9
|
+
end
|
10
|
+
@subject = RdfTest.new
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
Object.send(:remove_const, :RdfTest)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should set and recall values" do
|
18
|
+
@subject.title = 'War and Peace'
|
19
|
+
@subject.save
|
20
|
+
|
21
|
+
loaded = RdfTest.find(@subject.pid)
|
22
|
+
loaded.title.should == 'War and Peace'
|
23
|
+
end
|
24
|
+
end
|
@@ -145,18 +145,19 @@ describe ActiveFedora do
|
|
145
145
|
|
146
146
|
describe "#determine url" do
|
147
147
|
it "should support config['environment']['fedora']['url'] if config_type is fedora" do
|
148
|
-
config = {
|
149
|
-
|
148
|
+
config = {:test=> {:fedora=>{"url"=>"http://fedoraAdmin:fedorAdmin@localhost:8983/fedora"}}}
|
149
|
+
ActiveSupport::Deprecation.expects(:warn).with("Using \"fedora\" in the fedora.yml file is no longer supported")
|
150
|
+
ActiveFedora.determine_url("fedora",config).should eql("http://localhost:8983/fedora")
|
150
151
|
end
|
151
152
|
|
152
153
|
it "should support config['environment']['url'] if config_type is fedora" do
|
153
|
-
config = {
|
154
|
-
ActiveFedora.determine_url("fedora",config).should eql("http://
|
154
|
+
config = {:test=> {:url=>"http://fedoraAdmin:fedorAdmin@localhost:8983/fedora"}}
|
155
|
+
ActiveFedora.determine_url("fedora",config).should eql("http://localhost:8983/fedora")
|
155
156
|
end
|
156
157
|
|
157
158
|
it "should call #get_solr_url to determine the solr url if config_type is solr" do
|
158
|
-
config = {
|
159
|
-
ActiveFedora.expects(:get_solr_url).with(config[
|
159
|
+
config = {:test=>{:default => "http://default.solr:8983"}}
|
160
|
+
ActiveFedora.expects(:get_solr_url).with(config[:test]).returns("http://default.solr:8983")
|
160
161
|
ActiveFedora.determine_url("solr",config).should eql("http://default.solr:8983")
|
161
162
|
end
|
162
163
|
end
|
@@ -165,14 +166,14 @@ describe ActiveFedora do
|
|
165
166
|
it "should load the file specified in fedora_config_path" do
|
166
167
|
ActiveFedora.expects(:fedora_config_path).returns("/path/to/fedora.yml")
|
167
168
|
File.expects(:open).with("/path/to/fedora.yml").returns("test:\n url: http://myfedora:8080")
|
168
|
-
ActiveFedora.load_config(:fedora).should eql({:url=>"http://myfedora:8080"
|
169
|
-
ActiveFedora.fedora_config.should eql({:url=>"http://myfedora:8080"
|
169
|
+
ActiveFedora.load_config(:fedora).should eql({:url=>"http://myfedora:8080",:test=>{:url=>"http://myfedora:8080", :user=>nil, :password=>nil}})
|
170
|
+
ActiveFedora.fedora_config.should eql({:url=>"http://myfedora:8080",:test=>{:url=>"http://myfedora:8080", :user=>nil, :password=>nil}})
|
170
171
|
end
|
171
172
|
it "should load the file specified in solr_config_path" do
|
172
173
|
ActiveFedora.expects(:solr_config_path).returns("/path/to/solr.yml")
|
173
174
|
File.expects(:open).with("/path/to/solr.yml").returns("development:\n default:\n url: http://devsolr:8983\ntest:\n default:\n url: http://mysolr:8080")
|
174
|
-
ActiveFedora.load_config(:solr).should eql({:url=>"http://mysolr:8080"
|
175
|
-
ActiveFedora.solr_config.should eql({:url=>"http://mysolr:8080"
|
175
|
+
ActiveFedora.load_config(:solr).should eql({:url=>"http://mysolr:8080",:development=>{"default"=>{"url"=>"http://devsolr:8983"}}, :test=>{:default=>{"url"=>"http://mysolr:8080"}}})
|
176
|
+
ActiveFedora.solr_config.should eql({:url=>"http://mysolr:8080",:development=>{"default"=>{"url"=>"http://devsolr:8983"}}, :test=>{:default=>{"url"=>"http://mysolr:8080"}}})
|
176
177
|
end
|
177
178
|
end
|
178
179
|
|
@@ -359,11 +360,17 @@ describe ActiveFedora do
|
|
359
360
|
describe "outside of rails" do
|
360
361
|
it "should load the default packaged config/fedora.yml file if no explicit config path is passed" do
|
361
362
|
ActiveFedora.init()
|
362
|
-
ActiveFedora.fedora_config[:url].to_s.should == "http://
|
363
|
+
ActiveFedora.fedora_config[:url].to_s.should == "http://127.0.0.1:8983/fedora-test"
|
364
|
+
ActiveFedora.fedora_config[:test][:url].to_s.should == "http://127.0.0.1:8983/fedora-test"
|
365
|
+
ActiveFedora.fedora_config[:test][:user].to_s.should == "fedoraAdmin"
|
366
|
+
ActiveFedora.fedora_config[:test][:password].to_s.should == "fedoraAdmin"
|
363
367
|
end
|
364
368
|
it "should load the passed config if explicit config passed in as a string" do
|
365
369
|
ActiveFedora.init(:fedora_config_path=>'./spec/fixtures/rails_root/config/fedora.yml')
|
366
|
-
ActiveFedora.fedora_config[:url].should == "http://
|
370
|
+
ActiveFedora.fedora_config[:url].should == "http://testhost.com:8983/fedora"
|
371
|
+
ActiveFedora.fedora_config[:test][:url].to_s.should == "http://testhost.com:8983/fedora"
|
372
|
+
ActiveFedora.fedora_config[:test][:user].to_s.should == "fedoraAdmin"
|
373
|
+
ActiveFedora.fedora_config[:test][:password].to_s.should == "fedoraAdmin"
|
367
374
|
end
|
368
375
|
end
|
369
376
|
|
@@ -387,6 +394,7 @@ describe ActiveFedora do
|
|
387
394
|
File.stubs(:open).with(solr_config_path).returns(solr_config)
|
388
395
|
|
389
396
|
|
397
|
+
ActiveSupport::Deprecation.expects(:warn).with("Using \"fedora\" in the fedora.yml file is no longer supported")
|
390
398
|
ActiveFedora.init(:fedora_config_path=>fedora_config_path,:solr_config_path=>solr_config_path)
|
391
399
|
ActiveFedora.solr.class.should == ActiveFedora::SolrService
|
392
400
|
ActiveFedora.fedora.class.should == ActiveFedora::RubydoraConnection
|
@@ -397,12 +405,12 @@ describe ActiveFedora do
|
|
397
405
|
it "should look for the file in the path defined at Rails.root" do
|
398
406
|
stub_rails(:root=>File.join(File.dirname(__FILE__),"../fixtures/rails_root"))
|
399
407
|
ActiveFedora.init()
|
400
|
-
ActiveFedora.fedora_config[:url].should == "http://
|
408
|
+
ActiveFedora.fedora_config[:url].should == "http://testhost.com:8983/fedora"
|
401
409
|
end
|
402
410
|
it "should load the default file if no config is found at Rails.root" do
|
403
411
|
stub_rails(:root=>File.join(File.dirname(__FILE__),"../fixtures/bad/path/to/rails_root"))
|
404
412
|
ActiveFedora.init()
|
405
|
-
ActiveFedora.fedora_config[:url].should == "http://
|
413
|
+
ActiveFedora.fedora_config[:url].should == "http://127.0.0.1:8983/fedora-test"
|
406
414
|
end
|
407
415
|
end
|
408
416
|
end
|
data/spec/unit/base_spec.rb
CHANGED
@@ -68,6 +68,15 @@ describe ActiveFedora::Base do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
describe ".datastream_class_for_name" do
|
72
|
+
it "should return the specifed class" do
|
73
|
+
FooAdaptation.datastream_class_for_name('someData').should == ActiveFedora::NokogiriDatastream
|
74
|
+
end
|
75
|
+
it "should return the specifed class" do
|
76
|
+
FooAdaptation.datastream_class_for_name('content').should == ActiveFedora::Datastream
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
71
80
|
describe ".internal_uri" do
|
72
81
|
it "should return pid as fedors uri" do
|
73
82
|
@test_object.internal_uri.should eql("info:fedora/#{@test_object.pid}")
|
@@ -100,143 +109,6 @@ describe ActiveFedora::Base do
|
|
100
109
|
end
|
101
110
|
### End ActiveModel::Naming
|
102
111
|
|
103
|
-
|
104
|
-
|
105
|
-
it "should respond_to has_metadata" do
|
106
|
-
ActiveFedora::Base.respond_to?(:has_metadata).should be_true
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "has_metadata" do
|
110
|
-
describe "creates datastreams" do
|
111
|
-
before :each do
|
112
|
-
stub_ingest(@this_pid)
|
113
|
-
stub_add_ds(@this_pid, ['RELS-EXT', 'someData', 'withText', 'withText2'])
|
114
|
-
|
115
|
-
@n = FooHistory.new()
|
116
|
-
@n.datastreams['RELS-EXT'].expects(:changed?).returns(true).at_least_once
|
117
|
-
@n.expects(:update_index)
|
118
|
-
@n.save
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should create specified datastreams with specified fields" do
|
122
|
-
@n.datastreams["someData"].should_not be_nil
|
123
|
-
@n.datastreams["someData"].fubar_values='bar'
|
124
|
-
@n.datastreams["someData"].fubar_values.should == ['bar']
|
125
|
-
@n.datastreams["withText2"].dsLabel.should == "withLabel"
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
it "should create specified datastreams with appropriate control group" do
|
131
|
-
ActiveFedora::RubydoraConnection.instance.options.stubs(:[]).returns({:url=>'sub_url'})
|
132
|
-
stub_ingest(@this_pid)
|
133
|
-
stub_add_ds(@this_pid, ['RELS-EXT', 'DC', 'rightsMetadata', 'properties', 'descMetadata', 'UKETD_DC'])
|
134
|
-
stub_get(@this_pid, ['RELS-EXT', 'DC', 'rightsMetadata', 'properties', 'descMetadata', 'UKETD_DC'])
|
135
|
-
class UketdObject < ActiveFedora::Base
|
136
|
-
has_metadata :name => "rightsMetadata", :label=>"Rights metadata", :type => ActiveFedora::NokogiriDatastream
|
137
|
-
|
138
|
-
# Uses the Hydra MODS Article profile for tracking most of the descriptive metadata
|
139
|
-
# TODO: define terminology for ETD
|
140
|
-
has_metadata :name => "descMetadata", :label=>"MODS metadata", :control_group=>"M", :type => ActiveFedora::NokogiriDatastream
|
141
|
-
|
142
|
-
has_metadata :name => "UKETD_DC", :label=>"UKETD_DC metadata", :control_group => "E", :disseminator=>"hull-sDef:uketdObject/getUKETDMetadata", :type => ActiveFedora::NokogiriDatastream
|
143
|
-
|
144
|
-
has_metadata :name => "DC", :type => ActiveFedora::NokogiriDatastream, :label=>"DC admin metadata"
|
145
|
-
|
146
|
-
# A place to put extra metadata values
|
147
|
-
has_metadata :name => "properties", :label=>"Workflow properties", :type => ActiveFedora::MetadataDatastream do |m|
|
148
|
-
m.field 'collection', :string
|
149
|
-
m.field 'depositor', :string
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
153
|
-
@n = UketdObject.new()
|
154
|
-
@n.save
|
155
|
-
@n.datastreams["DC"].controlGroup.should eql("X")
|
156
|
-
@n.datastreams["rightsMetadata"].controlGroup.should eql("X")
|
157
|
-
@n.datastreams["properties"].controlGroup.should eql("X")
|
158
|
-
@n.datastreams["descMetadata"].controlGroup.should eql("M")
|
159
|
-
@n.datastreams["UKETD_DC"].controlGroup.should eql("E")
|
160
|
-
@n.datastreams["UKETD_DC"].dsLocation.should == "urlsub_url/objects/#{@this_pid}/methods/hull-sDef:uketdObject/getUKETDMetadata"
|
161
|
-
end
|
162
|
-
|
163
|
-
context ":control_group => 'E'" do
|
164
|
-
before do
|
165
|
-
stub_get(@this_pid)
|
166
|
-
stub_add_ds(@this_pid, ['RELS-EXT', 'externalDisseminator', 'externalUrl'])
|
167
|
-
end
|
168
|
-
|
169
|
-
after(:all) do
|
170
|
-
# clean up test class
|
171
|
-
Object.send(:remove_const, :MoreFooHistory)
|
172
|
-
end
|
173
|
-
it "should raise an error without :disseminator or :url option" do
|
174
|
-
class MoreFooHistory < ActiveFedora::Base
|
175
|
-
has_metadata :type=>ActiveFedora::NokogiriDatastream, :name=>"externalDisseminator", :control_group => "E"
|
176
|
-
end
|
177
|
-
lambda { @n = MoreFooHistory.new }.should raise_exception
|
178
|
-
end
|
179
|
-
|
180
|
-
it "should allow :control_group => 'E' with a :url option" do
|
181
|
-
class MoreFooHistory < ActiveFedora::Base
|
182
|
-
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"externalDisseminator",:control_group => "E", :url => "http://exampl.com/mypic.jpg"
|
183
|
-
end
|
184
|
-
stub_ingest(@this_pid)
|
185
|
-
@n = MoreFooHistory.new
|
186
|
-
@n.save
|
187
|
-
end
|
188
|
-
it "should raise an error if :url is malformed" do
|
189
|
-
class MoreFooHistory < ActiveFedora::Base
|
190
|
-
has_metadata :type => ActiveFedora::NokogiriDatastream, :name=>"externalUrl", :url=>"my_rul", :control_group => "E"
|
191
|
-
end
|
192
|
-
client = mock_client.stubs(:[]).with do |params|
|
193
|
-
/objects\/#{@this_pid}\/datastreams\/externalUrl/.match(params)
|
194
|
-
end
|
195
|
-
client.raises(RuntimeError, "Error adding datastream externalUrl for object changeme:4020. See logger for details")
|
196
|
-
@n = MoreFooHistory.new
|
197
|
-
lambda {@n.save }.should raise_exception
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
context ":control_group => 'R'" do
|
202
|
-
before do
|
203
|
-
stub_get(@this_pid)
|
204
|
-
stub_add_ds(@this_pid, ['RELS-EXT', 'externalDisseminator' ])
|
205
|
-
end
|
206
|
-
it "should raise an error without :url option" do
|
207
|
-
class MoreFooHistory < ActiveFedora::Base
|
208
|
-
has_metadata :type=>ActiveFedora::NokogiriDatastream, :name=>"externalDisseminator", :control_group => "R"
|
209
|
-
end
|
210
|
-
lambda { @n = MoreFooHistory.new }.should raise_exception
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should work with a valid :url option" do
|
214
|
-
stub_ingest(@this_pid)
|
215
|
-
class MoreFooHistory < ActiveFedora::Base
|
216
|
-
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"externalDisseminator",:control_group => "R", :url => "http://exampl.com/mypic.jpg"
|
217
|
-
end
|
218
|
-
@n = MoreFooHistory.new
|
219
|
-
@n.save
|
220
|
-
end
|
221
|
-
it "should not take a :disseminator option without a :url option" do
|
222
|
-
class MoreFooHistory < ActiveFedora::Base
|
223
|
-
has_metadata :type=>ActiveFedora::NokogiriDatastream, :name=>"externalDisseminator", :control_group => "R", :disseminator => "foo:s-def/hull-cModel:Foo"
|
224
|
-
end
|
225
|
-
lambda { @n = MoreFooHistory.new }.should raise_exception
|
226
|
-
end
|
227
|
-
it "should raise an error if :url is malformed" do
|
228
|
-
class MoreFooHistory < ActiveFedora::Base
|
229
|
-
has_metadata :type => ActiveFedora::NokogiriDatastream, :name=>"externalUrl", :url=>"my_rul", :control_group => "R"
|
230
|
-
end
|
231
|
-
client = mock_client.stubs(:[]).with do |params|
|
232
|
-
/objects\/#{@this_pid}\/datastreams\/externalUrl/.match(params)
|
233
|
-
end
|
234
|
-
client.raises(RuntimeError, "Error adding datastream externalUrl for object changeme:4020. See logger for details")
|
235
|
-
lambda {MoreFooHistory.new }.should raise_exception
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
112
|
|
241
113
|
describe ".datastreams" do
|
242
114
|
before do
|
@@ -522,53 +394,6 @@ describe ActiveFedora::Base do
|
|
522
394
|
|
523
395
|
end
|
524
396
|
|
525
|
-
describe "#create_datastream" do
|
526
|
-
it 'should create a datastream object using the type of object supplied in the string (does reflection)' do
|
527
|
-
f = File.new(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"))
|
528
|
-
f.stubs(:content_type).returns("image/jpeg")
|
529
|
-
f.stubs(:original_filename).returns("minivan.jpg")
|
530
|
-
ds = @test_object.create_datastream("ActiveFedora::Datastream", 'NAME', {:blob=>f})
|
531
|
-
ds.class.should == ActiveFedora::Datastream
|
532
|
-
ds.dsLabel.should == "minivan.jpg"
|
533
|
-
ds.mimeType.should == "image/jpeg"
|
534
|
-
end
|
535
|
-
it 'should create a datastream object from a string' do
|
536
|
-
ds = @test_object.create_datastream("ActiveFedora::Datastream", 'NAME', {:blob=>"My file data"})
|
537
|
-
ds.class.should == ActiveFedora::Datastream
|
538
|
-
ds.dsLabel.should == nil
|
539
|
-
ds.mimeType.should == "application/octet-stream"
|
540
|
-
end
|
541
|
-
|
542
|
-
it 'should not set dsLocation if dsLocation is nil' do
|
543
|
-
ActiveFedora::Datastream.any_instance.expects(:dsLocation=).never
|
544
|
-
ds = @test_object.create_datastream("ActiveFedora::Datastream", 'NAME', {:dsLocation=>nil})
|
545
|
-
end
|
546
|
-
end
|
547
|
-
|
548
|
-
describe ".add_file_datastream" do
|
549
|
-
before do
|
550
|
-
@mock_file = mock('file')
|
551
|
-
end
|
552
|
-
it "should pass prefix" do
|
553
|
-
#@test_object.expects(:create_datastream).with(ActiveFedora::Datastream, nil, attrs)
|
554
|
-
stub_add_ds(@test_object.pid, ['content1'])
|
555
|
-
@test_object.add_file_datastream(@mock_file, :prefix=>'content' )
|
556
|
-
@test_object.datastreams.keys.should include 'content1'
|
557
|
-
end
|
558
|
-
it "should pass dsid" do
|
559
|
-
#@test_object.expects(:create_datastream).with(ActiveFedora::Datastream, "MY_DSID", attrs)
|
560
|
-
stub_add_ds(@test_object.pid, ['MY_DSID'])
|
561
|
-
@test_object.add_file_datastream(@mock_file, :dsid=>'MY_DSID')
|
562
|
-
@test_object.datastreams.keys.should include 'MY_DSID'
|
563
|
-
end
|
564
|
-
it "without dsid or prefix" do
|
565
|
-
#@test_object.expects(:create_datastream).with(ActiveFedora::Datastream, nil, attrs)
|
566
|
-
stub_add_ds(@test_object.pid, ['DS1'])
|
567
|
-
@test_object.add_file_datastream(@mock_file, {} )
|
568
|
-
@test_object.datastreams.keys.should include 'DS1'
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
397
|
describe ".adapt_to" do
|
573
398
|
it "should return an adapted object of the requested type" do
|
574
399
|
@test_object = FooHistory.new()
|
@@ -47,9 +47,9 @@ describe ActiveFedora::DatastreamCollections do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
it 'should return
|
50
|
+
it 'should return a set of datastream names defined by has_datastream' do
|
51
51
|
@test_object2 = MockDatastreamNames.new
|
52
|
-
@test_object2.datastream_names.should
|
52
|
+
@test_object2.datastream_names.should include("thumbnail","EAD")
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|