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.
Files changed (190) hide show
  1. data/Gemfile +2 -2
  2. data/Gemfile.lock +33 -57
  3. data/History.txt +9 -0
  4. data/active-fedora.gemspec +5 -5
  5. data/lib/active_fedora.rb +37 -10
  6. data/lib/active_fedora/base.rb +0 -18
  7. data/lib/active_fedora/datastream.rb +10 -5
  8. data/lib/active_fedora/datastreams.rb +33 -7
  9. data/lib/active_fedora/dcrdf_datastream.rb +11 -0
  10. data/lib/active_fedora/delegating.rb +2 -2
  11. data/lib/active_fedora/metadata_datastream.rb +3 -2
  12. data/lib/active_fedora/nested_attributes.rb +0 -1
  13. data/lib/active_fedora/ntriples_rdf_datastream.rb +19 -0
  14. data/lib/active_fedora/predicates.rb +4 -0
  15. data/lib/active_fedora/rdf_datastream.rb +108 -0
  16. data/lib/active_fedora/rdf_xml_writer.rb +53 -41
  17. data/lib/active_fedora/relationship_graph.rb +15 -71
  18. data/lib/active_fedora/rels_ext_datastream.rb +1 -4
  19. data/lib/active_fedora/rubydora_connection.rb +2 -9
  20. data/lib/active_fedora/unsaved_digital_object.rb +1 -0
  21. data/lib/active_fedora/version.rb +1 -1
  22. data/lib/tasks/active_fedora_dev.rake +1 -1
  23. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +13 -0
  24. data/spec/fixtures/rails_root/config/fedora.yml +1 -15
  25. data/spec/integration/base_loader_spec.rb +0 -1
  26. data/spec/integration/dc_rdf_datastream_spec.rb +24 -0
  27. data/spec/integration/full_featured_model_spec.rb +1 -1
  28. data/spec/integration/model_spec.rb +0 -1
  29. data/spec/unit/active_fedora_spec.rb +22 -14
  30. data/spec/unit/base_spec.rb +9 -184
  31. data/spec/unit/datastream_collections_spec.rb +2 -2
  32. data/spec/unit/datastream_spec.rb +36 -6
  33. data/spec/unit/datastreams_spec.rb +251 -0
  34. data/spec/unit/dc_rdf_datastream_spec.rb +50 -0
  35. data/spec/unit/metadata_datastream_spec.rb +1 -1
  36. data/spec/unit/nokogiri_datastream_spec.rb +2 -2
  37. data/spec/unit/{rdf_xml_writer.rb → rdf_xml_writer_spec.rb} +8 -8
  38. data/spec/unit/relationship_graph_spec.rb +14 -0
  39. data/spec/unit/rels_ext_datastream_spec.rb +29 -2
  40. data/spec/unit/rubydora_connection_spec.rb +2 -4
  41. data/spec/unit/unsaved_digital_object_spec.rb +22 -9
  42. metadata +106 -258
  43. data/.hg/00changelog.i +0 -0
  44. data/.hg/branch +0 -1
  45. data/.hg/branch.cache +0 -2
  46. data/.hg/dirstate +0 -0
  47. data/.hg/hgrc +0 -2
  48. data/.hg/requires +0 -2
  49. data/.hg/store/00changelog.i +0 -0
  50. data/.hg/store/00manifest.i +0 -0
  51. data/.hg/store/data/.hgignore.i +0 -0
  52. data/.hg/store/data/.hgtags.i +0 -0
  53. data/.hg/store/data/_c_o_p_y_i_n_g.txt.i +0 -0
  54. data/.hg/store/data/_c_o_y_i_n_g._l_e_s_s_e_r.txt.i +0 -0
  55. data/.hg/store/data/_history.txt.i +0 -0
  56. data/.hg/store/data/_license.txt.i +0 -0
  57. data/.hg/store/data/_manifest.txt.i +0 -0
  58. data/.hg/store/data/_post_install.txt.i +0 -0
  59. data/.hg/store/data/_r_e_a_d_m_e.rdoc.i +0 -0
  60. data/.hg/store/data/_r_e_a_d_m_e.txt.i +0 -0
  61. data/.hg/store/data/_rakefile.i +0 -0
  62. data/.hg/store/data/_v_e_r_s_i_o_n.i +0 -0
  63. data/.hg/store/data/active-fedora.gemspec.i +0 -0
  64. data/.hg/store/data/active__fedora/_history.txt.i +0 -0
  65. data/.hg/store/data/active__fedora/_manifest.txt.i +0 -0
  66. data/.hg/store/data/active__fedora/_post_install.txt.i +0 -0
  67. data/.hg/store/data/active__fedora/_r_e_a_d_m_e.rdoc.i +0 -0
  68. data/.hg/store/data/active__fedora/_rakefile.i +0 -0
  69. data/.hg/store/data/active__fedora/lib/active__fedora.rb.i +0 -0
  70. data/.hg/store/data/active__fedora/script/console.i +0 -0
  71. data/.hg/store/data/active__fedora/script/destroy.i +0 -0
  72. data/.hg/store/data/active__fedora/script/generate.i +0 -0
  73. data/.hg/store/data/active__fedora/spec/active__fedora__spec.rb.i +0 -0
  74. data/.hg/store/data/active__fedora/spec/spec__helper.rb.i +0 -0
  75. data/.hg/store/data/config/fedora.yml.i +0 -0
  76. data/.hg/store/data/config/solr__mappings.yml.i +0 -0
  77. data/.hg/store/data/config/solr__mappings__af__0.1.yml.i +0 -0
  78. data/.hg/store/data/config/solr__mappings__bl__2.4.yml.i +0 -0
  79. data/.hg/store/data/lib/active-fedora.rb.i +0 -0
  80. data/.hg/store/data/lib/active__fedora.rb.i +0 -0
  81. data/.hg/store/data/lib/active__fedora/base.rb.i +0 -0
  82. data/.hg/store/data/lib/active__fedora/content__model.rb.i +0 -0
  83. data/.hg/store/data/lib/active__fedora/datastream.rb.i +0 -0
  84. data/.hg/store/data/lib/active__fedora/fedora__object.rb.i +0 -0
  85. data/.hg/store/data/lib/active__fedora/metadata__datastream.rb.i +0 -0
  86. data/.hg/store/data/lib/active__fedora/model.rb.i +0 -0
  87. data/.hg/store/data/lib/active__fedora/property.rb.i +0 -0
  88. data/.hg/store/data/lib/active__fedora/qualified__dublin__core__datastream.rb.i +0 -0
  89. data/.hg/store/data/lib/active__fedora/relationship.rb.i +0 -0
  90. data/.hg/store/data/lib/active__fedora/rels__ext__datastream.rb.i +0 -0
  91. data/.hg/store/data/lib/active__fedora/semantic__node.rb.i +0 -0
  92. data/.hg/store/data/lib/active__fedora/solr__mapper.rb.i +0 -0
  93. data/.hg/store/data/lib/active__fedora/solr__service.rb.i +0 -0
  94. data/.hg/store/data/lib/fedora/base.rb.i +0 -0
  95. data/.hg/store/data/lib/fedora/connection.rb.i +0 -0
  96. data/.hg/store/data/lib/fedora/datastream.rb.i +0 -0
  97. data/.hg/store/data/lib/fedora/fedora__object.rb.i +0 -0
  98. data/.hg/store/data/lib/fedora/formats.rb.i +0 -0
  99. data/.hg/store/data/lib/fedora/generic__search.rb.i +0 -0
  100. data/.hg/store/data/lib/fedora/repository.rb.i +0 -0
  101. data/.hg/store/data/lib/ruby-fedora.rb.i +0 -0
  102. data/.hg/store/data/lib/util/class__level__inheritable__attributes.rb.i +0 -0
  103. data/.hg/store/data/script/console.i +0 -0
  104. data/.hg/store/data/script/destroy.i +0 -0
  105. data/.hg/store/data/script/generate.i +0 -0
  106. data/.hg/store/data/solr/config/schema-1.5.xml.i +0 -0
  107. data/.hg/store/data/solr/config/schema.xml.i +0 -0
  108. data/.hg/store/data/solr/config/solrconfig-1.5.xml.i +0 -0
  109. data/.hg/store/data/spec/fixtures/changeme155.xml.i +0 -0
  110. data/.hg/store/data/spec/fixtures/dino.jpg.i +0 -0
  111. data/.hg/store/data/spec/fixtures/minivan.jpg.d +0 -0
  112. data/.hg/store/data/spec/fixtures/minivan.jpg.i +0 -0
  113. data/.hg/store/data/spec/fixtures/test__12.foxml.xml.i +0 -0
  114. data/.hg/store/data/spec/integration/active__fedora/base__spec.rb.i +0 -0
  115. data/.hg/store/data/spec/integration/active__fedora/datastream__spec.rb.i +0 -0
  116. data/.hg/store/data/spec/integration/active__fedora/fedora__object__spec.rb.i +0 -0
  117. data/.hg/store/data/spec/integration/active__fedora/full__featured__model__spec.rb.i +0 -0
  118. data/.hg/store/data/spec/integration/active__fedora/model__spec.rb.i +0 -0
  119. data/.hg/store/data/spec/integration/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
  120. data/.hg/store/data/spec/integration/active__fedora/semantic__node__spec.rb.i +0 -0
  121. data/.hg/store/data/spec/integration/base__file__management__spec.rb.i +0 -0
  122. data/.hg/store/data/spec/integration/base__spec.rb.i +0 -0
  123. data/.hg/store/data/spec/integration/bug__spec.rb.i +0 -0
  124. data/.hg/store/data/spec/integration/datastream__spec.rb.i +0 -0
  125. data/.hg/store/data/spec/integration/datastreams__crud__spec.rb.i +0 -0
  126. data/.hg/store/data/spec/integration/fedora__object__spec.rb.i +0 -0
  127. data/.hg/store/data/spec/integration/full__featured__model__spec.rb.i +0 -0
  128. data/.hg/store/data/spec/integration/model__spec.rb.i +0 -0
  129. data/.hg/store/data/spec/integration/rels__ext__datastream__spec.rb.i +0 -0
  130. data/.hg/store/data/spec/integration/repository__spec.rb.i +0 -0
  131. data/.hg/store/data/spec/integration/rf__fedora__object__spec.rb.i +0 -0
  132. data/.hg/store/data/spec/integration/semantic__node__spec.rb.i +0 -0
  133. data/.hg/store/data/spec/integration/solr__service__spec.rb.i +0 -0
  134. data/.hg/store/data/spec/samples/models/audio__record.rb.i +0 -0
  135. data/.hg/store/data/spec/samples/models/image.rb.i +0 -0
  136. data/.hg/store/data/spec/samples/models/oral__history.rb.i +0 -0
  137. data/.hg/store/data/spec/samples/models/seminar.rb.i +0 -0
  138. data/.hg/store/data/spec/samples/models/seminar__audio__file.rb.i +0 -0
  139. data/.hg/store/data/spec/samples/oh__qdc.xml.i +0 -0
  140. data/.hg/store/data/spec/samples/oral__history.rb.i +0 -0
  141. data/.hg/store/data/spec/samples/oral__history__sample.xml.i +0 -0
  142. data/.hg/store/data/spec/samples/oral__history__sample__model.rb.i +0 -0
  143. data/.hg/store/data/spec/samples/oral__history__xml.xml.i +0 -0
  144. data/.hg/store/data/spec/spec.opts.i +0 -0
  145. data/.hg/store/data/spec/spec__helper.rb.i +0 -0
  146. data/.hg/store/data/spec/unit/active__fedora/base__cma__spec.rb.i +0 -0
  147. data/.hg/store/data/spec/unit/active__fedora/base__extra__spec.rb.i +0 -0
  148. data/.hg/store/data/spec/unit/active__fedora/base__spec.rb.i +0 -0
  149. data/.hg/store/data/spec/unit/active__fedora/content__model__spec.rb.i +0 -0
  150. data/.hg/store/data/spec/unit/active__fedora/datastream__spec.rb.i +0 -0
  151. data/.hg/store/data/spec/unit/active__fedora/inheritance__spec.rb.i +0 -0
  152. data/.hg/store/data/spec/unit/active__fedora/metadata__datastream__spec.rb.i +0 -0
  153. data/.hg/store/data/spec/unit/active__fedora/model__spec.rb.i +0 -0
  154. data/.hg/store/data/spec/unit/active__fedora/property__spec.rb.i +0 -0
  155. data/.hg/store/data/spec/unit/active__fedora/qualified__dublin__core__datastream__spec.rb.i +0 -0
  156. data/.hg/store/data/spec/unit/active__fedora/relationship__spec.rb.i +0 -0
  157. data/.hg/store/data/spec/unit/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
  158. data/.hg/store/data/spec/unit/active__fedora/semantic__node__spec.rb.i +0 -0
  159. data/.hg/store/data/spec/unit/active__fedora/solr__service__spec.rb.i +0 -0
  160. data/.hg/store/data/spec/unit/active__fedora__spec.rb.i +0 -0
  161. data/.hg/store/data/spec/unit/base__cma__spec.rb.i +0 -0
  162. data/.hg/store/data/spec/unit/base__datastream__management__spec.rb.i +0 -0
  163. data/.hg/store/data/spec/unit/base__extra__spec.rb.i +0 -0
  164. data/.hg/store/data/spec/unit/base__file__management__spec.rb.i +0 -0
  165. data/.hg/store/data/spec/unit/base__loader__spec.rb.i +0 -0
  166. data/.hg/store/data/spec/unit/base__spec.rb.i +0 -0
  167. data/.hg/store/data/spec/unit/connection__spec.rb.i +0 -0
  168. data/.hg/store/data/spec/unit/content__model__spec.rb.i +0 -0
  169. data/.hg/store/data/spec/unit/datastream__concurrency__spec.rb.i +0 -0
  170. data/.hg/store/data/spec/unit/datastream__spec.rb.i +0 -0
  171. data/.hg/store/data/spec/unit/fedora__object__spec.rb.i +0 -0
  172. data/.hg/store/data/spec/unit/inheritance__spec.rb.i +0 -0
  173. data/.hg/store/data/spec/unit/metadata__datastream__spec.rb.i +0 -0
  174. data/.hg/store/data/spec/unit/model__spec.rb.i +0 -0
  175. data/.hg/store/data/spec/unit/property__spec.rb.i +0 -0
  176. data/.hg/store/data/spec/unit/qualified__dublin__core__datastream__spec.rb.i +0 -0
  177. data/.hg/store/data/spec/unit/relationship__spec.rb.i +0 -0
  178. data/.hg/store/data/spec/unit/rels__ext__datastream__spec.rb.i +0 -0
  179. data/.hg/store/data/spec/unit/repository__spec.rb.i +0 -0
  180. data/.hg/store/data/spec/unit/rf__datastream__spec.rb.i +0 -0
  181. data/.hg/store/data/spec/unit/semantic__node__spec.rb.i +0 -0
  182. data/.hg/store/data/spec/unit/solr__config__options__spec.rb.i +0 -0
  183. data/.hg/store/data/spec/unit/solr__mapper__spec.rb.i +0 -0
  184. data/.hg/store/data/spec/unit/solr__service__spec.rb.i +0 -0
  185. data/.hg/store/data/tasks/rspec.rake.i +0 -0
  186. data/.hg/store/undo +0 -0
  187. data/.hg/undo.branch +0 -1
  188. data/.hg/undo.dirstate +0 -0
  189. data/.hgignore +0 -7
  190. 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.fedora_config[:url])
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
@@ -26,6 +26,7 @@ module ActiveFedora
26
26
  obj.datastreams[k] = v
27
27
  end
28
28
  obj.ownerId = ownerId if ownerId
29
+ obj.label = label if label
29
30
  obj
30
31
  end
31
32
 
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "3.2.2"
2
+ VERSION = "3.3.0"
3
3
  end
@@ -47,7 +47,7 @@ require 'rspec/core/rake_task'
47
47
  ActiveFedora.init unless Thread.current[:repo]
48
48
 
49
49
  ENV["pid"] = "hydrangea:fixture_mods_article1"
50
- Rake::Task["af:refresh_fixture"].invoke
50
+ Rake::Task["repo:refresh"].invoke
51
51
  ENV["pid"] = nil
52
52
  end
53
53
 
@@ -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
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
  require 'active_fedora'
3
3
  require 'active_fedora/base'
4
4
  require 'active_fedora/metadata_datastream'
5
- require 'ruby-debug'
6
5
  require 'nokogiri'
7
6
 
8
7
  # Load Sample OralHistory Model
@@ -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
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'rexml/document'
3
- require 'lib/active_fedora/samples/hydra-mods_article_datastream'
3
+ require File.join(File.dirname(__FILE__), "../..", "lib/active_fedora/samples", 'hydra-mods_article_datastream')
4
4
 
5
5
  include ActiveFedora
6
6
 
@@ -23,7 +23,6 @@ describe ActiveFedora::Model do
23
23
 
24
24
  end
25
25
 
26
- ActiveFedora::RubydoraConnection.connect(ActiveFedora.fedora_config[:url])
27
26
  @test_instance = ModelIntegrationSpec::Basic.new
28
27
  @test_instance.save
29
28
 
@@ -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 = {"test"=> {"fedora"=>{"url"=>"http://fedoraAdmin:fedorAdmin@oldstyle_url:8983/fedora"}}}
149
- ActiveFedora.determine_url("fedora",config).should eql("http://fedoraAdmin:fedorAdmin@oldstyle_url:8983/fedora")
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 = {"test"=> {"url"=>"http://fedoraAdmin:fedorAdmin@oldstyle_url:8983/fedora"}}
154
- ActiveFedora.determine_url("fedora",config).should eql("http://fedoraAdmin:fedorAdmin@oldstyle_url:8983/fedora")
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 = {"test"=>{"default" => "http://default.solr:8983"}}
159
- ActiveFedora.expects(:get_solr_url).with(config["test"]).returns("http://default.solr:8983")
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","test"=>{"url"=>"http://myfedora:8080"}})
169
- ActiveFedora.fedora_config.should eql({:url=>"http://myfedora:8080","test"=>{"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","development"=>{"default"=>{"url"=>"http://devsolr:8983"}}, "test"=>{"default"=>{"url"=>"http://mysolr:8080"}}})
175
- ActiveFedora.solr_config.should eql({:url=>"http://mysolr:8080","development"=>{"default"=>{"url"=>"http://devsolr:8983"}}, "test"=>{"default"=>{"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://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora-test"
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://fedoraAdmin:fedoraAdmin@testhost.com:8983/fedora"
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://fedoraAdmin:fedoraAdmin@testhost.com:8983/fedora"
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://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora-test"
413
+ ActiveFedora.fedora_config[:url].should == "http://127.0.0.1:8983/fedora-test"
406
414
  end
407
415
  end
408
416
  end
@@ -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 an array of datastream names defined by has_datastream' do
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 == ["thumbnail","EAD"]
52
+ @test_object2.datastream_names.should include("thumbnail","EAD")
53
53
  end
54
54
  end
55
55