active-fedora 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/.hg/00changelog.i +0 -0
  4. data/.hg/branch +1 -0
  5. data/.hg/branch.cache +2 -0
  6. data/.hg/dirstate +0 -0
  7. data/.hg/hgrc +2 -0
  8. data/.hg/requires +2 -0
  9. data/.hg/store/00changelog.i +0 -0
  10. data/.hg/store/00manifest.i +0 -0
  11. data/.hg/store/data/.hgignore.i +0 -0
  12. data/.hg/store/data/.hgtags.i +0 -0
  13. data/.hg/store/data/_c_o_p_y_i_n_g.txt.i +0 -0
  14. data/.hg/store/data/_c_o_y_i_n_g._l_e_s_s_e_r.txt.i +0 -0
  15. data/.hg/store/data/_history.txt.i +0 -0
  16. data/.hg/store/data/_license.txt.i +0 -0
  17. data/.hg/store/data/_manifest.txt.i +0 -0
  18. data/.hg/store/data/_post_install.txt.i +0 -0
  19. data/.hg/store/data/_r_e_a_d_m_e.rdoc.i +0 -0
  20. data/.hg/store/data/_r_e_a_d_m_e.txt.i +0 -0
  21. data/.hg/store/data/_rakefile.i +0 -0
  22. data/.hg/store/data/_v_e_r_s_i_o_n.i +0 -0
  23. data/.hg/store/data/active-fedora.gemspec.i +0 -0
  24. data/.hg/store/data/active__fedora/_history.txt.i +0 -0
  25. data/.hg/store/data/active__fedora/_manifest.txt.i +0 -0
  26. data/.hg/store/data/active__fedora/_post_install.txt.i +0 -0
  27. data/.hg/store/data/active__fedora/_r_e_a_d_m_e.rdoc.i +0 -0
  28. data/.hg/store/data/active__fedora/_rakefile.i +0 -0
  29. data/.hg/store/data/active__fedora/lib/active__fedora.rb.i +0 -0
  30. data/.hg/store/data/active__fedora/script/console.i +0 -0
  31. data/.hg/store/data/active__fedora/script/destroy.i +0 -0
  32. data/.hg/store/data/active__fedora/script/generate.i +0 -0
  33. data/.hg/store/data/active__fedora/spec/active__fedora__spec.rb.i +0 -0
  34. data/.hg/store/data/active__fedora/spec/spec__helper.rb.i +0 -0
  35. data/.hg/store/data/config/fedora.yml.i +0 -0
  36. data/.hg/store/data/config/solr__mappings.yml.i +0 -0
  37. data/.hg/store/data/config/solr__mappings__af__0.1.yml.i +0 -0
  38. data/.hg/store/data/config/solr__mappings__bl__2.4.yml.i +0 -0
  39. data/.hg/store/data/lib/active-fedora.rb.i +0 -0
  40. data/.hg/store/data/lib/active__fedora.rb.i +0 -0
  41. data/.hg/store/data/lib/active__fedora/base.rb.i +0 -0
  42. data/.hg/store/data/lib/active__fedora/content__model.rb.i +0 -0
  43. data/.hg/store/data/lib/active__fedora/datastream.rb.i +0 -0
  44. data/.hg/store/data/lib/active__fedora/fedora__object.rb.i +0 -0
  45. data/.hg/store/data/lib/active__fedora/metadata__datastream.rb.i +0 -0
  46. data/.hg/store/data/lib/active__fedora/model.rb.i +0 -0
  47. data/.hg/store/data/lib/active__fedora/property.rb.i +0 -0
  48. data/.hg/store/data/lib/active__fedora/qualified__dublin__core__datastream.rb.i +0 -0
  49. data/.hg/store/data/lib/active__fedora/relationship.rb.i +0 -0
  50. data/.hg/store/data/lib/active__fedora/rels__ext__datastream.rb.i +0 -0
  51. data/.hg/store/data/lib/active__fedora/semantic__node.rb.i +0 -0
  52. data/.hg/store/data/lib/active__fedora/solr__mapper.rb.i +0 -0
  53. data/.hg/store/data/lib/active__fedora/solr__service.rb.i +0 -0
  54. data/.hg/store/data/lib/fedora/base.rb.i +0 -0
  55. data/.hg/store/data/lib/fedora/connection.rb.i +0 -0
  56. data/.hg/store/data/lib/fedora/datastream.rb.i +0 -0
  57. data/.hg/store/data/lib/fedora/fedora__object.rb.i +0 -0
  58. data/.hg/store/data/lib/fedora/formats.rb.i +0 -0
  59. data/.hg/store/data/lib/fedora/generic__search.rb.i +0 -0
  60. data/.hg/store/data/lib/fedora/repository.rb.i +0 -0
  61. data/.hg/store/data/lib/ruby-fedora.rb.i +0 -0
  62. data/.hg/store/data/lib/util/class__level__inheritable__attributes.rb.i +0 -0
  63. data/.hg/store/data/script/console.i +0 -0
  64. data/.hg/store/data/script/destroy.i +0 -0
  65. data/.hg/store/data/script/generate.i +0 -0
  66. data/.hg/store/data/solr/config/schema-1.5.xml.i +0 -0
  67. data/.hg/store/data/solr/config/schema.xml.i +0 -0
  68. data/.hg/store/data/solr/config/solrconfig-1.5.xml.i +0 -0
  69. data/.hg/store/data/spec/fixtures/changeme155.xml.i +0 -0
  70. data/.hg/store/data/spec/fixtures/dino.jpg.i +0 -0
  71. data/.hg/store/data/spec/fixtures/minivan.jpg.d +0 -0
  72. data/.hg/store/data/spec/fixtures/minivan.jpg.i +0 -0
  73. data/.hg/store/data/spec/fixtures/test__12.foxml.xml.i +0 -0
  74. data/.hg/store/data/spec/integration/active__fedora/base__spec.rb.i +0 -0
  75. data/.hg/store/data/spec/integration/active__fedora/datastream__spec.rb.i +0 -0
  76. data/.hg/store/data/spec/integration/active__fedora/fedora__object__spec.rb.i +0 -0
  77. data/.hg/store/data/spec/integration/active__fedora/full__featured__model__spec.rb.i +0 -0
  78. data/.hg/store/data/spec/integration/active__fedora/model__spec.rb.i +0 -0
  79. data/.hg/store/data/spec/integration/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
  80. data/.hg/store/data/spec/integration/active__fedora/semantic__node__spec.rb.i +0 -0
  81. data/.hg/store/data/spec/integration/base__file__management__spec.rb.i +0 -0
  82. data/.hg/store/data/spec/integration/base__spec.rb.i +0 -0
  83. data/.hg/store/data/spec/integration/bug__spec.rb.i +0 -0
  84. data/.hg/store/data/spec/integration/datastream__spec.rb.i +0 -0
  85. data/.hg/store/data/spec/integration/datastreams__crud__spec.rb.i +0 -0
  86. data/.hg/store/data/spec/integration/fedora__object__spec.rb.i +0 -0
  87. data/.hg/store/data/spec/integration/full__featured__model__spec.rb.i +0 -0
  88. data/.hg/store/data/spec/integration/model__spec.rb.i +0 -0
  89. data/.hg/store/data/spec/integration/rels__ext__datastream__spec.rb.i +0 -0
  90. data/.hg/store/data/spec/integration/repository__spec.rb.i +0 -0
  91. data/.hg/store/data/spec/integration/rf__fedora__object__spec.rb.i +0 -0
  92. data/.hg/store/data/spec/integration/semantic__node__spec.rb.i +0 -0
  93. data/.hg/store/data/spec/integration/solr__service__spec.rb.i +0 -0
  94. data/.hg/store/data/spec/samples/models/audio__record.rb.i +0 -0
  95. data/.hg/store/data/spec/samples/models/image.rb.i +0 -0
  96. data/.hg/store/data/spec/samples/models/oral__history.rb.i +0 -0
  97. data/.hg/store/data/spec/samples/models/seminar.rb.i +0 -0
  98. data/.hg/store/data/spec/samples/models/seminar__audio__file.rb.i +0 -0
  99. data/.hg/store/data/spec/samples/oh__qdc.xml.i +0 -0
  100. data/.hg/store/data/spec/samples/oral__history.rb.i +0 -0
  101. data/.hg/store/data/spec/samples/oral__history__sample.xml.i +0 -0
  102. data/.hg/store/data/spec/samples/oral__history__sample__model.rb.i +0 -0
  103. data/.hg/store/data/spec/samples/oral__history__xml.xml.i +0 -0
  104. data/.hg/store/data/spec/spec.opts.i +0 -0
  105. data/.hg/store/data/spec/spec__helper.rb.i +0 -0
  106. data/.hg/store/data/spec/unit/active__fedora/base__cma__spec.rb.i +0 -0
  107. data/.hg/store/data/spec/unit/active__fedora/base__extra__spec.rb.i +0 -0
  108. data/.hg/store/data/spec/unit/active__fedora/base__spec.rb.i +0 -0
  109. data/.hg/store/data/spec/unit/active__fedora/content__model__spec.rb.i +0 -0
  110. data/.hg/store/data/spec/unit/active__fedora/datastream__spec.rb.i +0 -0
  111. data/.hg/store/data/spec/unit/active__fedora/inheritance__spec.rb.i +0 -0
  112. data/.hg/store/data/spec/unit/active__fedora/metadata__datastream__spec.rb.i +0 -0
  113. data/.hg/store/data/spec/unit/active__fedora/model__spec.rb.i +0 -0
  114. data/.hg/store/data/spec/unit/active__fedora/property__spec.rb.i +0 -0
  115. data/.hg/store/data/spec/unit/active__fedora/qualified__dublin__core__datastream__spec.rb.i +0 -0
  116. data/.hg/store/data/spec/unit/active__fedora/relationship__spec.rb.i +0 -0
  117. data/.hg/store/data/spec/unit/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
  118. data/.hg/store/data/spec/unit/active__fedora/semantic__node__spec.rb.i +0 -0
  119. data/.hg/store/data/spec/unit/active__fedora/solr__service__spec.rb.i +0 -0
  120. data/.hg/store/data/spec/unit/active__fedora__spec.rb.i +0 -0
  121. data/.hg/store/data/spec/unit/base__cma__spec.rb.i +0 -0
  122. data/.hg/store/data/spec/unit/base__datastream__management__spec.rb.i +0 -0
  123. data/.hg/store/data/spec/unit/base__extra__spec.rb.i +0 -0
  124. data/.hg/store/data/spec/unit/base__file__management__spec.rb.i +0 -0
  125. data/.hg/store/data/spec/unit/base__loader__spec.rb.i +0 -0
  126. data/.hg/store/data/spec/unit/base__spec.rb.i +0 -0
  127. data/.hg/store/data/spec/unit/connection__spec.rb.i +0 -0
  128. data/.hg/store/data/spec/unit/content__model__spec.rb.i +0 -0
  129. data/.hg/store/data/spec/unit/datastream__concurrency__spec.rb.i +0 -0
  130. data/.hg/store/data/spec/unit/datastream__spec.rb.i +0 -0
  131. data/.hg/store/data/spec/unit/fedora__object__spec.rb.i +0 -0
  132. data/.hg/store/data/spec/unit/inheritance__spec.rb.i +0 -0
  133. data/.hg/store/data/spec/unit/metadata__datastream__spec.rb.i +0 -0
  134. data/.hg/store/data/spec/unit/model__spec.rb.i +0 -0
  135. data/.hg/store/data/spec/unit/property__spec.rb.i +0 -0
  136. data/.hg/store/data/spec/unit/qualified__dublin__core__datastream__spec.rb.i +0 -0
  137. data/.hg/store/data/spec/unit/relationship__spec.rb.i +0 -0
  138. data/.hg/store/data/spec/unit/rels__ext__datastream__spec.rb.i +0 -0
  139. data/.hg/store/data/spec/unit/repository__spec.rb.i +0 -0
  140. data/.hg/store/data/spec/unit/rf__datastream__spec.rb.i +0 -0
  141. data/.hg/store/data/spec/unit/semantic__node__spec.rb.i +0 -0
  142. data/.hg/store/data/spec/unit/solr__config__options__spec.rb.i +0 -0
  143. data/.hg/store/data/spec/unit/solr__mapper__spec.rb.i +0 -0
  144. data/.hg/store/data/spec/unit/solr__service__spec.rb.i +0 -0
  145. data/.hg/store/data/tasks/rspec.rake.i +0 -0
  146. data/.hg/store/undo +0 -0
  147. data/.hg/undo.branch +1 -0
  148. data/.hg/undo.dirstate +0 -0
  149. data/.hgignore +7 -0
  150. data/.hgtags +14 -0
  151. data/COPYING.txt +674 -0
  152. data/COYING.LESSER.txt +165 -0
  153. data/History.txt +34 -0
  154. data/LICENSE +20 -0
  155. data/License.txt +58 -0
  156. data/Manifest.txt +1 -1
  157. data/README.rdoc +13 -54
  158. data/README.txt +59 -0
  159. data/Rakefile +35 -0
  160. data/VERSION +1 -0
  161. data/active-fedora.gemspec +359 -0
  162. data/config/fedora.yml +16 -0
  163. data/config/solr_mappings.yml +14 -0
  164. data/config/solr_mappings_af_0.1.yml +16 -0
  165. data/config/solr_mappings_bl_2.4.yml +14 -0
  166. data/lib/active_fedora.rb +66 -6
  167. data/lib/active_fedora/base.rb +59 -23
  168. data/lib/active_fedora/datastream.rb +1 -1
  169. data/lib/active_fedora/metadata_datastream.rb +14 -7
  170. data/lib/active_fedora/model.rb +4 -4
  171. data/lib/active_fedora/rels_ext_datastream.rb +1 -1
  172. data/lib/active_fedora/semantic_node.rb +4 -3
  173. data/lib/active_fedora/solr_mapper.rb +17 -0
  174. data/lib/active_fedora/solr_service.rb +44 -2
  175. data/lib/fedora/base.rb +38 -0
  176. data/lib/fedora/connection.rb +210 -0
  177. data/lib/fedora/datastream.rb +56 -0
  178. data/lib/fedora/fedora_object.rb +161 -0
  179. data/lib/fedora/formats.rb +30 -0
  180. data/lib/fedora/generic_search.rb +71 -0
  181. data/lib/fedora/repository.rb +287 -0
  182. data/lib/ruby-fedora.rb +20 -0
  183. data/lib/util/class_level_inheritable_attributes.rb +23 -0
  184. data/script/console +15 -0
  185. data/script/destroy +14 -0
  186. data/script/generate +14 -0
  187. data/solr/config/schema-1.5.xml +468 -0
  188. data/solr/config/schema.xml +174 -212
  189. data/solr/config/solrconfig-1.5.xml +1069 -0
  190. data/spec/active_fedora_spec.rb +7 -0
  191. data/spec/fixtures/changeme155.xml +255 -0
  192. data/spec/fixtures/dino.jpg +0 -0
  193. data/spec/fixtures/minivan.jpg +0 -0
  194. data/spec/fixtures/test_12.foxml.xml +121 -0
  195. data/spec/integration/base_file_management_spec.rb +20 -0
  196. data/spec/integration/base_spec.rb +196 -0
  197. data/spec/integration/bug_spec.rb +57 -0
  198. data/spec/integration/datastream_spec.rb +60 -0
  199. data/spec/integration/datastreams_crud_spec.rb +208 -0
  200. data/spec/integration/fedora_object_spec.rb +77 -0
  201. data/spec/integration/full_featured_model_spec.rb +207 -0
  202. data/spec/integration/model_spec.rb +54 -0
  203. data/spec/integration/rels_ext_datastream_spec.rb +67 -0
  204. data/spec/integration/repository_spec.rb +297 -0
  205. data/spec/integration/rf_fedora_object_spec.rb +95 -0
  206. data/spec/integration/semantic_node_spec.rb +95 -0
  207. data/spec/integration/solr_service_spec.rb +33 -0
  208. data/spec/samples/models/audio_record.rb +29 -0
  209. data/spec/samples/models/image.rb +5 -0
  210. data/spec/samples/models/oral_history.rb +50 -0
  211. data/spec/samples/models/seminar.rb +29 -0
  212. data/spec/samples/models/seminar_audio_file.rb +34 -0
  213. data/spec/samples/oh_qdc.xml +32 -0
  214. data/spec/samples/oral_history_sample.xml +38 -0
  215. data/spec/samples/oral_history_sample_model.rb +39 -0
  216. data/spec/samples/oral_history_xml.xml +35 -0
  217. data/spec/spec.opts +5 -0
  218. data/spec/spec_helper.rb +41 -0
  219. data/spec/unit/active_fedora_spec.rb +15 -0
  220. data/spec/unit/base_cma_spec.rb +25 -0
  221. data/spec/unit/base_datastream_management_spec.rb +119 -0
  222. data/spec/unit/base_extra_spec.rb +108 -0
  223. data/spec/unit/base_file_management_spec.rb +90 -0
  224. data/spec/unit/base_loader_spec.rb +43 -0
  225. data/spec/unit/base_spec.rb +584 -0
  226. data/spec/unit/connection_spec.rb +25 -0
  227. data/spec/unit/content_model_spec.rb +51 -0
  228. data/spec/unit/datastream_concurrency_spec.rb +59 -0
  229. data/spec/unit/datastream_spec.rb +85 -0
  230. data/spec/unit/fedora_object_spec.rb +66 -0
  231. data/spec/unit/inheritance_spec.rb +46 -0
  232. data/spec/unit/metadata_datastream_spec.rb +290 -0
  233. data/spec/unit/model_spec.rb +186 -0
  234. data/spec/unit/property_spec.rb +50 -0
  235. data/spec/unit/qualified_dublin_core_datastream_spec.rb +177 -0
  236. data/spec/unit/relationship_spec.rb +77 -0
  237. data/spec/unit/rels_ext_datastream_spec.rb +99 -0
  238. data/spec/unit/repository_spec.rb +136 -0
  239. data/spec/unit/rf_datastream_spec.rb +49 -0
  240. data/spec/unit/semantic_node_spec.rb +354 -0
  241. data/spec/unit/solr_config_options_spec.rb +98 -0
  242. data/spec/unit/solr_mapper_spec.rb +31 -0
  243. data/spec/unit/solr_service_spec.rb +83 -0
  244. data/tasks/hoe.rake +0 -0
  245. data/tasks/rspec.rake +29 -0
  246. metadata +373 -55
@@ -0,0 +1,57 @@
1
+ require File.join( File.dirname(__FILE__), "..", "spec_helper" )
2
+
3
+ require 'active_fedora'
4
+ require 'active_fedora/model'
5
+ require "rexml/document"
6
+ require 'ftools'
7
+ require 'mocha'
8
+
9
+ include ActiveFedora::Model
10
+ include Mocha::Standalone
11
+
12
+ describe 'bugs' do
13
+ class FooHistory < ActiveFedora::Base
14
+ has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"someData" do |m|
15
+ m.field "fubar", :string
16
+ m.field "swank", :text
17
+ end
18
+ has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"withText" do |m|
19
+ m.field "fubar", :text
20
+ end
21
+ end
22
+
23
+ before(:each) do
24
+ #Fedora::Repository.instance.stubs(:nextid).returns("foo:pid")
25
+ @test_object = FooHistory.new
26
+ @test_object.save
27
+ end
28
+ after(:each) do
29
+ @test_object.delete
30
+ end
31
+ it "should not clobber everything when setting a value" do
32
+ @test_object.datastreams["someData"].fubar_values.should == []
33
+ @test_object.datastreams["someData"].should_not be_nil
34
+ @test_object.datastreams["someData"].fubar_values=['bar']
35
+ @test_object.datastreams["someData"].fubar_values.should == ['bar']
36
+ @test_object.save
37
+
38
+ @test_object.pid.should_not be_nil
39
+
40
+ x = *FooHistory.find(@test_object.pid)
41
+ x.datastreams["someData"].fubar_values.should == ['bar']
42
+ x.datastreams['someData'].dirty?.should == false
43
+ x.datastreams['someData'].fubar_values = ["meh"]
44
+ x.datastreams['someData'].fubar_values.should == ["meh"]
45
+ x.datastreams['someData'].dirty?.should == true
46
+ x.save
47
+ x = *FooHistory.find(@test_object.pid)
48
+ x.datastreams['someData'].fubar_values.should == ["meh"]
49
+ x.save
50
+ end
51
+ it "should update the index, even if there is no metadata" do
52
+ pending
53
+ oh = FooHistory.new
54
+ oh.save
55
+ end
56
+
57
+ end
@@ -0,0 +1,60 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+
3
+ require 'active_fedora'
4
+ require "rexml/document"
5
+ require 'ftools'
6
+
7
+ describe ActiveFedora::Datastream do
8
+
9
+ before(:each) do
10
+ @test_object = ActiveFedora::Base.new
11
+ puts @test_object.inspect
12
+ @test_object.save
13
+ end
14
+
15
+ after(:each) do
16
+ @test_object.delete
17
+ end
18
+
19
+ it "should be able to access Datastreams using datastreams method" do
20
+ dc = @test_object.datastreams["DC"]
21
+ dc.should be_an_instance_of(ActiveFedora::Datastream)
22
+ dc.attributes.should be_an_instance_of(Hash)
23
+ dc.attributes["dsid"].to_s.should eql("DC")
24
+ dc.attributes[:pid].should_not be_nil
25
+ # dc.control_group.should == "X"
26
+ end
27
+
28
+ it "should be able to access Datastream content using content method" do
29
+ dc = @test_object.datastreams["DC"].content
30
+ dc.should_not be_nil
31
+ end
32
+
33
+ it "should be able to update XML Datastream content and save to Fedora" do
34
+ xml_content =REXML::Document.new(@test_object.datastreams["DC"].content)
35
+ title = REXML::Element.new "dc:title"
36
+ title.text = "Test Title"
37
+ xml_content.root.elements << title
38
+
39
+ @test_object.datastreams["DC"].content = xml_content.to_s
40
+ @test_object.datastreams["DC"].save
41
+
42
+ @test_object.datastreams["DC"].content.should eql(Fedora::Repository.instance.fetch_custom(@test_object.pid, "datastreams/DC/content"))
43
+ end
44
+
45
+ it "should be able to update Blob Datastream content and save to Fedora" do
46
+ dsid = "ds#{Time.now.to_i}"
47
+ ds = ActiveFedora::Datastream.new(:dsID => dsid, :dsLabel => 'hello', :altIDs => '3333',
48
+ :controlGroup => 'M', :blob => fixture('dino.jpg'))
49
+ File.identical?(ds.blob, fixture('dino.jpg')).should be_true
50
+ @test_object.add_datastream(ds).should be_true
51
+ @test_object.save
52
+ to = ActiveFedora::Base.load_instance(@test_object.pid)
53
+ to.should_not be_nil
54
+ to.datastreams[dsid].should_not be_nil
55
+ # to.datastreams[dsid].control_group.should == "M"
56
+ to.datastreams[dsid].content.length.should eql(fixture('dino.jpg').read.length)
57
+
58
+ end
59
+
60
+ end
@@ -0,0 +1,208 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+ # Datastream API:
3
+ # - To list datastream
4
+ # curl -i http://localhost:8080/fedora/objects/test:02/datastreams
5
+ # curl -i http://localhost:8080/fedora/objects/test:02/datastreams?format=xml
6
+ #
7
+ # invalid: curl -i http://localhost:8080/fedora/objects/test:02/datastreams.xml
8
+ #
9
+ # - To obtain a datastream
10
+ # curl -i http://localhost:8080/fedora/objects/test:02/datastreams/DC
11
+ # curl -i http://localhost:8080/fedora/objects/test:02/datastreams/DS1
12
+ #
13
+ # - To create create a new datastream
14
+ #
15
+ # regular post (always creates inline (I) datastream. Will fail if not valid XML):
16
+ # curl -i -H "Content-type: text/xml" -XPOST --data-binary @build.xml -u fedoraAdmin:fedoraAdmin "http://localhost:8080/fedora/objects/test:02/datastreams/DS1?dsLabel=A%20Test%20Datastream&altIDs=3333"
17
+ #
18
+ # "E" and "R" datastreams
19
+ # curl -i -H "Content-type: text/html" -XPOST "http://localhost:8080/fedora/objects/test:02/datastreams/REDIRECT?dsLabel=A%20Redirect%20Datastream&altIDs=3333&controlGroup=R&dsLocation=http://www.yourmediashelf.com" -u fedoraAdmin:fedoraAdmin
20
+ # curl -i -H "Content-type: text/html" -XPOST "http://localhost:8080/fedora/objects/test:02/datastreams/EXT?dsLabel=A%20Ext%20Datastream&altIDs=3333&controlGroup=E&dsLocation=http://www.yahoo.com" -u fedoraAdmin:fedoraAdmin
21
+ #
22
+ # multipart/form-data (always creates managed content (M) datastream):
23
+ # curl -i -H -XPOST -F file=@build.xml -u fedoraAdmin:fedoraAdmin "http://localhost:8080/fedora/objects/test:02/datastreams/DS3?dsLabel=hello&altIDs=3333"
24
+ # curl -i -H -XPOST -F file=@dino.jpg -u fedoraAdmin:fedoraAdmin "http://localhost:8080/fedora/objects/test:02/datastreams/JPEG?dsLabel=hello&altIDs=3333"
25
+ # MIME Type is set according to Content Type Header:
26
+ # curl -i -H -XPOST -F "file=@01 Float On.m4a;type=audio/mp4a-latm" -u fedoraAdmin:fedoraAdmin "http://localhost:8080/fedora/objects/test:02/datastreams/Float_On.m4a?dsLabel=hello&altIDs=3333"
27
+ # curl -i -H -XPOST -F "file=@educause2004Fedora.ppt;type=application/vnd.ms-powerpoint" -u fedoraAdmin:fedoraAdmin "http://localhost:8080/fedora/objects/test:02/datastreams/PPT.ppt?dsLabel=hello&altIDs=3333"
28
+ #
29
+ # mutipart/related is also supported but can only be tested with xform clients.
30
+ #
31
+ # - To update a datastream
32
+ # curl -i -H "Content-type: text/xml" -XPUT "http://localhost:8080/fedora/objects/test:02/datastreams/DS1?dsLabel=hello&altIDs=3333" --data-binary @build.xml -u fedoraAdmin:fedoraAdmin
33
+ # curl -i -H "Content-type: text/xml" -XPOST "http://localhost:8080/fedora/objects/test:02/datastreams/DS1?dsLabel=hello&altIDs=3333" --data-binary @build.xml -u fedoraAdmin:fedoraAdmin
34
+ #
35
+ # - To delete a datastream
36
+ # curl -i -XDELETE "http://localhost:8080/fedora/objects/test:02/datastreams/DS1" -u fedoraAdmin:fedoraAdmin
37
+ #
38
+ # curl -i -H -XPOST -F file=@test/fixtures/minivan-in-minneapolis.jpg -u fedoraAdmin:fedoraAdmin "http://localhost:8080/fedora/objects/test:test_xml_post/datastreams/FOO"
39
+ #
40
+ # curl -i -XDELETE -u admin:muradora "http://localhost:9090/fedora/objects/test:test:test_object_1"
41
+ #
42
+ # curl -i -H "Content-type: text/xml" -XPOST --data-binary @test/fixtures/mods-mskcc-filledsample.xml -u fedoraAdmin:fedoraAdmin "http://localhost:9090/fedora/objects/test:02/datastreams/DS1?dsLabel=A%20Test%20Datastream"
43
+ #
44
+ # curl -i -H "Content-type: image/jpeg" -XPOST -F file=@test/fixtures/dino.jpg -u admin:muradora "http://localhost:9090/fedora/objects/test:02/datastreams/DINO?dsLabel=A%20Test%20Datastream"
45
+ describe Fedora::Repository do
46
+ def sample_mods
47
+ xml = <<-EOS
48
+ <mods:mods xmlns:xlink="http://www.w3.org/1999/xlink" version="3.2"
49
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mods="http://www.loc.gov/mods/v3"
50
+ xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd"
51
+ xmlns="http://www.w3.org/1999/xhtml">
52
+ <mods:identifier>mskcc:2045</mods:identifier>
53
+ <mods:titleInfo authority="" displayLabel="">
54
+ <mods:title>Sample Title</mods:title>
55
+ <mods:subTitle>Sample SubTitle</mods:subTitle>
56
+ </mods:titleInfo>
57
+ <mods:name type="personal" authority="" ID="owner">
58
+ <mods:namePart type="family">Smith</mods:namePart>
59
+ <mods:namePart type="given">John</mods:namePart>
60
+ <mods:namePart type="termsOfAddress">Mr.</mods:namePart>
61
+ <mods:affiliation>Surgery</mods:affiliation>
62
+ <mods:role>
63
+ <mods:roleTerm type="text" authority="">Owner</mods:roleTerm>
64
+ </mods:role>
65
+ </mods:name>
66
+ <mods:name type="personal" authority="non-owner">
67
+ <mods:namePart type="family">Rushdie</mods:namePart>
68
+ <mods:namePart type="given">Salman</mods:namePart>
69
+ <mods:namePart type="termsOfAddress">Mr.</mods:namePart>
70
+ <mods:affiliation>Surgery</mods:affiliation>
71
+ <mods:role>
72
+ <mods:roleTerm type="text" authority="">Contributor</mods:roleTerm>
73
+ </mods:role>
74
+ </mods:name>
75
+ <mods:originInfo>
76
+ <mods:place>
77
+ <mods:placeTerm type="text">Sample Place of Creation</mods:placeTerm>
78
+ </mods:place>
79
+ <mods:publisher>MSKCC</mods:publisher>
80
+ <mods:dateIssued encoding="" keydate="" qualifier="" point=""/>
81
+ <mods:dateCreated encoding="" keydate="" qualifier="" point=""/>
82
+ <mods:dateModified encoding="" keydate="" qualifier="" point=""/>
83
+ <mods:copyrightDate encoding="" keydate="" qualifier="" point=""/>
84
+ <mods:dateOther encoding="" keydate="" qualifier="" point=""/>
85
+ </mods:originInfo>
86
+ <mods:abstract displayLabel="" type=""></mods:abstract>
87
+ <mods:note type=""/>
88
+ <mods:subject authority="lcsh">
89
+ <mods:topic>carcinoma</mods:topic>
90
+ <mods:topic>adinoma</mods:topic>
91
+ </mods:subject>
92
+ <!-- part, extension -->
93
+ </mods:mods>
94
+ EOS
95
+ end
96
+
97
+ before(:all) do
98
+ Fedora::Repository.register(ActiveFedora.fedora_config[:url])
99
+ @fedora = Fedora::Repository.instance
100
+ end
101
+
102
+ before(:each) do
103
+ @test_object = Fedora::FedoraObject.new(:label => 'test',
104
+ :contentModel => 'Image',
105
+ :state => 'A',
106
+ :ownerID => 'fedoraAdmin')
107
+
108
+ @fedora.save(@test_object).should be_true
109
+ end
110
+
111
+ after(:each) do
112
+ @fedora.delete(@test_object).should be_true
113
+ end
114
+
115
+ def fetch_content(pid, dsID)
116
+ content = @fedora.fetch_content("#{pid}/datastreams/#{dsID}/content")
117
+ end
118
+
119
+ it "should create/update xml datastream" do
120
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'foo', :altIDs => '3333',
121
+ :blob => sample_mods)
122
+ @fedora.save(ds).should be_true
123
+
124
+ ds.attributes[:dsLabel] = 'bar'
125
+ @fedora.save(ds).should be_true
126
+ end
127
+
128
+ it "should be able to save file objects" do
129
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'hello', :altIDs => '3333',
130
+ :controlGroup => 'M', :blob => fixture('dino.jpg'))
131
+
132
+ ds.control_group.should == 'M'
133
+ @fedora.save(ds).should be_true
134
+ end
135
+
136
+ it "should be able to save StringIO objects" do
137
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'hello', :altIDs => '3333', :controlGroup => 'M', :blob => StringIO.new("hi there"))
138
+
139
+ @fedora.save(ds).should be_true
140
+ end
141
+
142
+ it "should create/update image/file datastream" do
143
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'hello', :altIDs => '3333',
144
+ :controlGroup => 'M', :blob => fixture('dino.jpg'))
145
+
146
+ @fedora.save(ds).should be_true
147
+
148
+ content = fetch_content(@test_object.pid, 'DS1')
149
+ content.content_type.should == 'image/jpeg'
150
+
151
+ ds.blob = fixture('minivan.jpg')
152
+ @fedora.save(ds).should be_true
153
+ end
154
+
155
+ it "should set controlGroup to 'M' if mimeType is specified" do
156
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'foo',
157
+ :mimeType => 'text/plain', :blob => "This is plain text")
158
+ end
159
+
160
+ it "should create datastream with custom mimeType for text blob" do
161
+ blob = "This is plain text"
162
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'foo',
163
+ :mimeType => 'text/plain', :blob => blob)
164
+ @fedora.save(ds).should be_true
165
+
166
+ content = @fedora.fetch_content("#{@test_object.pid}/datastreams/DS1/content")
167
+ content.should == blob
168
+ content.content_type.should == 'text/plain'
169
+ end
170
+
171
+ it "should create datastream with custom mimeType for file blob" do
172
+ blob = "This is plain text"
173
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'foo',
174
+ :mimeType => 'image/jpeg', :blob => fixture('dino.jpg'))
175
+ @fedora.save(ds).should be_true
176
+
177
+ content = fetch_content(@test_object.pid, "DS1")
178
+ content.content_type.should == 'image/jpeg'
179
+ end
180
+
181
+ it "should delete datastream by ref" do
182
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'foo', :altIDs => '3333', :blob => sample_mods)
183
+ @fedora.save(ds).should be_true
184
+ @fedora.delete(ds).should be_true
185
+ end
186
+
187
+ it "should delete datastream by uri" do
188
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DS1', :dsLabel => 'foo', :altIDs => '3333', :blob => sample_mods)
189
+ @fedora.save(ds).should be_true
190
+ @fedora.delete(ds.uri).should be_true
191
+ end
192
+
193
+ it "should fetch thumbnail jpg for Image of Coliseum in Rome" do
194
+ # Have to check for two possible sizes because the image size changed between Fedora 3.0 and Fedora 3.1
195
+ fetch_content("demo:26", "TEI_SOURCE").length.should satisfy{ |l| l == 1098 || 1086}
196
+ end
197
+
198
+ describe ".label" do
199
+ it "should apply to the dsLabel when you save the datastream" do
200
+ ds = Fedora::Datastream.new(:pid => @test_object.pid, :dsID => 'DSLabelTest', :blob => sample_mods)
201
+ ds.label = "My Test dsLabel"
202
+ @fedora.save(ds)
203
+ object_rexml = REXML::Document.new(@test_object.object_xml)
204
+ #puts object_rexml.root.elements["foxml:datastream[@ID='DSLabelTest']/foxml:datastreamVersion"].inspect
205
+ object_rexml.root.elements["foxml:datastream[@ID='DSLabelTest']/foxml:datastreamVersion[last()]"].attributes["LABEL"].should == ds.label
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,77 @@
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
@@ -0,0 +1,207 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+
3
+ require 'rexml/document'
4
+
5
+ include ActiveFedora
6
+
7
+ describe ActiveFedora::Base do
8
+
9
+ before(:all) do
10
+ class OralHistory < ActiveFedora::Base
11
+ #include Model
12
+
13
+ # Imitating DataMapper ...
14
+
15
+ has_relationship "parts", :is_part_of, :inbound => true
16
+
17
+ # These are all the properties that don't quite fit into Qualified DC
18
+ # Put them on the object itself (in the properties datastream) for now.
19
+ has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
20
+ m.field "narrator", :string
21
+ m.field "interviewer", :string
22
+ m.field "transcript_editor", :text
23
+ m.field "bio", :string
24
+ m.field "notes", :text
25
+ m.field "hard_copy_availability", :text
26
+ m.field "hard_copy_location", :text
27
+ m.field "other_contributor", :string
28
+ m.field "restrictions", :text
29
+ m.field "series", :string
30
+ m.field "location", :string
31
+ end
32
+
33
+ has_metadata :name => "dublin_core", :type => ActiveFedora::QualifiedDublinCoreDatastream do |m|
34
+ # Default :multiple => true
35
+ #
36
+ # on retrieval, these will be pluralized and returned as arrays
37
+ # ie. subject_entries = my_oral_history.dublin_core.subjects
38
+ #
39
+ # aimint to use method-missing to support calling methods like
40
+ # my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible
41
+
42
+ # Setting new Types for dates and text content
43
+ m.field "creation_date", :date, :xml_node => "date"
44
+ m.field "abstract", :text, :xml_node => "abstract"
45
+ m.field "rights", :text, :xml_node => "rights"
46
+
47
+ # Setting up special named fields
48
+ m.field "subject_heading", :string, :xml_node => "subject", :encoding => "LCSH"
49
+ m.field "spatial_coverage", :string, :xml_node => "spatial", :encoding => "TGN"
50
+ m.field "temporal_coverage", :string, :xml_node => "temporal", :encoding => "Period"
51
+ m.field "type", :string, :xml_node => "type", :encoding => "DCMITYPE"
52
+ m.field "alt_title", :string, :xml_node => "alternative"
53
+ end
54
+
55
+ has_metadata :name => "significant_passages", :type => ActiveFedora::MetadataDatastream do |m|
56
+ m.field "significant_passage", :text
57
+ end
58
+
59
+ has_metadata :name => "sensitive_passages", :type => ActiveFedora::MetadataDatastream do |m|
60
+ m.field "sensitive_passage", :text
61
+ end
62
+
63
+ end
64
+ sample_location = "Boston, Massachusetts"
65
+ sample_notes = 'Addelson, Frances. (1973?) “The Induced Abortion,” American Journal of Ortho-Psychiatry, Addelson, Frances. “Abortion: Source of Guilt or Growth,” National Journal of Gynecology and Obstetrics., Addelson, Frances. “First Zionist Novel,” Jewish Frontier.'
66
+ sample_other_contributor = 'any other contributors, people or corporate names (eg. Temple Israel)'
67
+ sample_transcript_editor = 'Siegel, Cheryl'
68
+ sample_hard_copy_availability = <<-END
69
+ Yes, please contact the Jewish Women\\\'s Archive for more information on using this source.
70
+ END
71
+ sample_narrator = 'Addelson, Frances'
72
+ sample_bio = <<-END
73
+ Rochelle Ruthchild interviewed Frances Addleson on October 18, November 14, and December 10, 1997. The interview thoroughly examined the trajectory of Frances’ life from birth until the time of the interview. As a young child, Frances’ father died during the influenza epidemic, and her mother was not equipped to care for her and her siblings. Consequently, they were placed in a Jewish foster home. Although her experience was mostly positive, this experience would leave life-long effects. Frances attended Radcliffe upon the urging of a mentor and later obtained her Master’s degree in social work from Simmons College in 1954. In the 1940’s, she returned to work while her children were still young; a rather unusual event for that time period. While working as a social worker at Beth Israel Hospital in the early 1970’s, she helped counsel countless women who came to the hospital seeking abortions before the procedure was officially legalized during the landmark Roe vs. Wade decision in 1973. Frances would later write two articles that were published in medical journals about her experience during this time. Although not a very religious person, Frances felt connected to the Jewish notion of social justice and remained very active until an accident in the late 1990’s.
74
+ END
75
+ sample_interviewer = "Ruthchild, & Rochelle"
76
+
77
+ @properties_sample_values2 = Hash[:narrator => "Narrator1 & Narrator2", :interviewer => "Interviewer", :transcript_editor => "Transcript Editor", :bio => "Biographic info",
78
+ :notes => "My Note\\\'s a good one", :hard_copy_availability => "Yes", :hard_copy_location => "Archives", :other_contributor => "Sally Ride",
79
+ :restrictions => "None", :series => "My Series", :location => "location"]
80
+
81
+ @properties_sample_values = Hash[:narrator => sample_narrator, :interviewer => sample_interviewer, :transcript_editor => sample_transcript_editor, :bio => sample_bio,
82
+ :notes => sample_notes, :hard_copy_availability => sample_hard_copy_availability, :hard_copy_location => "Archives", :other_contributor => sample_other_contributor,
83
+ :restrictions => "None", :series => "My Series", :location => sample_location]
84
+
85
+ @dublin_core_sample_values = Hash[:creator => 'Matt && McClain', :publisher => 'Jewish Women\\\'s Archive', :description => "description", :identifier => "jwa:sample_pid",
86
+ :title => "title", :alt_title => "alt_title", :subject => "subject", :subject_heading => "subject heading",
87
+ :creation_date => "2008-07-02T05:09:42.015Z", :language => "language", :spatial_coverage => "spatial coverage",
88
+ :temporal_coverage => "temporal coverage", :abstract => "abstract", :rights => "rights", :type => "type", :extent => "extent",
89
+ :format => "format", :medium => "medium"]
90
+ @signigicant_passages_sample_values = {}
91
+ @sensitive_passages_sample_values = {}
92
+ @sample_xml = "<xml><fields><system_create_date>REMOVED</system_create_date><system_modified_date>REMOVED</system_modified_date><active_fedora_model_s>OralHistory</active_fedora_model_s><id>changeme:14527</id><subject_heading>subject heading</subject_heading><type>type</type><rights>rights</rights><publisher>publisher</publisher><creation_date>creation date</creation_date><identifier>jwa:sample_pid</identifier><format>format</format><extent>extent</extent><language>language</language><description>description</description><title>title</title><medium>medium</medium><spatial_coverage>spatial coverage</spatial_coverage><alt_title>alt_title</alt_title><temporal_coverage>temporal coverage</temporal_coverage><subject>subject</subject><creator>creator</creator><abstract>abstract</abstract><other_contributor>Sally Ride</other_contributor><transcript_editor>Transcript Editor</transcript_editor><restrictions>None</restrictions><bio>Biographic info</bio><series>My Series</series><notes>My Note</notes><location>location</location><hard_copy_availability>Yes</hard_copy_availability><narrator>Narrator</narrator><hard_copy_location>Archives</hard_copy_location><interviewer>Interviewer</interviewer></fields><content/></xml>"
93
+
94
+ end
95
+
96
+ before(:each) do
97
+ @test_history = OralHistory.new
98
+ end
99
+
100
+ after(:each) do
101
+ end
102
+
103
+ after(:all) do
104
+ Object.send(:remove_const, :OralHistory)
105
+ end
106
+
107
+ it "should be an instance of ActiveFedora::Base" do
108
+ @test_history.should be_kind_of(ActiveFedora::Base)
109
+ end
110
+
111
+ it "should reflect all of the metadata fields" do
112
+ pending
113
+ properties_ds = @test_history.datastreams["properties"]
114
+ dublin_core_ds = @test_history.datastreams["dublin_core"]
115
+
116
+ @properties_sample_values.each do |field, value|
117
+ properties_ds.send("#{field.to_s}_values=",value)
118
+ end
119
+
120
+ @dublin_core_sample_values.each do |field, value|
121
+ dublin_core_ds.send("#{field.to_s}_values=",[value])
122
+ end
123
+
124
+ @test_history.save
125
+
126
+ retrieved_obj = OralHistory.find(@test_history.pid)
127
+ retrieved_obj.inner_object.should_not be_new_object
128
+
129
+ end
130
+
131
+ it "t1" do# should load all of the metadata fields from fedora xml" do
132
+ pending
133
+ properties_ds = @test_history.datastreams["properties"]
134
+ dublin_core_ds = @test_history.datastreams["dublin_core"]
135
+
136
+
137
+ @properties_sample_values.each do |field, value|
138
+ properties_ds.send("#{field.to_s}_values=", [value])
139
+ end
140
+
141
+ @dublin_core_sample_values.each do |field, value|
142
+ dublin_core_ds.send("#{field.to_s}_values=", [value])
143
+ end
144
+
145
+ @test_history.save
146
+
147
+ @retrieved_history = OralHistory.find(@test_history.pid).first
148
+ retrieved_properties_ds = @retrieved_history.datastreams["properties"]
149
+ retrieved_dublin_core_ds = @retrieved_history.datastreams["dublin_core"]
150
+ retrieved_properties_ds.should_not be_nil
151
+ retrieved_dublin_core_ds.should_not be_nil
152
+ @properties_sample_values.each do |field, value|
153
+ retrieved_properties_ds.send("#{field.to_s}_values").should == [value]
154
+ end
155
+
156
+ @dublin_core_sample_values.each do |field, value|
157
+ retrieved_dublin_core_ds.send("#{field.to_s}_values").should == [value]
158
+ end
159
+ end
160
+
161
+ it "should push all of the metadata fields into solr" do
162
+ # TODO: test must test values using solr symbol names (ie. _field, _text and _date)
163
+ properties_ds = @test_history.datastreams["properties"]
164
+ dublin_core_ds = @test_history.datastreams["dublin_core"]
165
+
166
+ @properties_sample_values.each_pair do |field, value|
167
+ properties_ds.send("#{field.to_s}_values=", [value])
168
+ end
169
+
170
+ @dublin_core_sample_values.each_pair do |field, value|
171
+ dublin_core_ds.send("#{field.to_s}_values=", [value])
172
+ end
173
+
174
+ @test_history.save
175
+
176
+ @solr_result = OralHistory.find_by_solr(@test_history.pid).hits[0]
177
+ puts @solr_result.inspect
178
+ @properties_sample_values.each_pair do |field, value|
179
+ (@solr_result["#{field.to_s}_t"] || @solr_result["#{field.to_s}_dt"]).should == [value]
180
+ end
181
+
182
+ @dublin_core_sample_values.each_pair do |field, value|
183
+ dublin_core_ds.send("#{field.to_s}_values").should == [value]
184
+ end
185
+ end
186
+
187
+ it "should have Qualified Dublin core, with custom accessors" do
188
+
189
+ #xml = REXML::Document.new(@test_history.to_xml.to_s)
190
+ dublin_core_ds = @test_history.datastreams["dublin_core"]
191
+
192
+ dublin_core_ds.subject_heading_values = "My Subject Heading"
193
+ dc_xml = REXML::Document.new(dublin_core_ds.to_dc_xml)
194
+
195
+ dc_xml.root.elements["dcterms:subject"].text.should == "My Subject Heading"
196
+ dc_xml.root.elements["dcterms:subject"].attributes["xsi:type"].should == "LCSH"
197
+
198
+ end
199
+
200
+ describe '#new' do
201
+ it "should support custom pids" do
202
+ oh = OralHistory.new(:pid=>"uuid:blah-blah-blah")
203
+ oh.pid.should == "uuid:blah-blah-blah"
204
+ end
205
+ end
206
+
207
+ end