active-fedora 1.1.4.pre2 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4.pre1
1
+ 1.1.4
@@ -5,9 +5,9 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active-fedora}
8
- s.version = "1.1.4.pre2"
8
+ s.version = "1.1.4"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Zumwalt", "McClain Looney"]
12
12
  s.date = %q{2010-05-15}
13
13
  s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
@@ -191,7 +191,9 @@ Gem::Specification.new do |s|
191
191
  "lib/active_fedora/datastream.rb",
192
192
  "lib/active_fedora/fedora_object.rb",
193
193
  "lib/active_fedora/metadata_datastream.rb",
194
+ "lib/active_fedora/metadata_datastream_helper.rb",
194
195
  "lib/active_fedora/model.rb",
196
+ "lib/active_fedora/nokogiri_datastream.rb",
195
197
  "lib/active_fedora/property.rb",
196
198
  "lib/active_fedora/qualified_dublin_core_datastream.rb",
197
199
  "lib/active_fedora/relationship.rb",
@@ -312,8 +314,6 @@ Gem::Specification.new do |s|
312
314
  "spec/unit/inheritance_spec.rb",
313
315
  "spec/unit/metadata_datastream_spec.rb",
314
316
  "spec/unit/model_spec.rb",
315
- "spec/unit/mods_datastream_spec.rb",
316
- "spec/unit/nokogiri_datastream_spec.rb",
317
317
  "spec/unit/property_spec.rb",
318
318
  "spec/unit/qualified_dublin_core_datastream_spec.rb",
319
319
  "spec/unit/relationship_spec.rb",
@@ -14,7 +14,9 @@ require 'active_fedora/base.rb'
14
14
  require 'active_fedora/content_model.rb'
15
15
  require 'active_fedora/datastream.rb'
16
16
  require 'active_fedora/fedora_object.rb'
17
+ require 'active_fedora/metadata_datastream_helper.rb'
17
18
  require 'active_fedora/metadata_datastream.rb'
19
+ require 'active_fedora/nokogiri_datastream'
18
20
  require 'active_fedora/model.rb'
19
21
  require 'active_fedora/property.rb'
20
22
  require 'active_fedora/qualified_dublin_core_datastream.rb'
@@ -371,24 +371,36 @@ module ActiveFedora
371
371
  end
372
372
 
373
373
  #Returns the xml version of this object as a string.
374
- def to_xml(xml=REXML::Document.new("<xml><fields/><content/></xml>"))
375
- fields_xml = xml.root.elements['fields']
376
- {:id => pid, :system_create_date => self.create_date, :system_modified_date => self.modified_date, :active_fedora_model => self.class.inspect}.each_pair do |attribute_name, value|
377
- el = REXML::Element.new(attribute_name.to_s)
378
- el.text = value
379
- fields_xml << el
374
+ def to_xml(xml=Nokogiri::XML::Document.parse("<xml><fields/><content/></xml>"))
375
+ fields_xml = xml.xpath('//fields').first
376
+ builder = Nokogiri::XML::Builder.with(fields_xml) do |fields_xml|
377
+ fields_xml.id_ pid
378
+ fields_xml.system_create_date self.create_date
379
+ fields_xml.system_modified_date self.modified_date
380
+ fields_xml.active_fedora_model self.class.inspect
380
381
  end
382
+
383
+ # {:id => pid, :system_create_date => self.create_date, :system_modified_date => self.modified_date, :active_fedora_model => self.class.inspect}.each_pair do |attribute_name, value|
384
+ # el = REXML::Element.new(attribute_name.to_s)
385
+ # el.text = value
386
+ # fields_xml << el
387
+ # end
381
388
  datastreams.each_value do |ds|
382
- ds.to_xml(fields_xml) if ds.kind_of?(ActiveFedora::MetadataDatastream) || ds.kind_of?(ActiveFedora::RelsExtDatastream)
389
+ ds.to_xml(fields_xml) if ds.included_modules.include?(ActiveFedora::MetadataDatastreamHelper) || ds.kind_of?(ActiveFedora::RelsExtDatastream)
383
390
  end
384
391
  return xml.to_s
385
392
  end
386
393
 
387
- #Return a Solr::Document version of this object.
388
- def to_solr(solr_doc = Solr::Document.new)
389
- solr_doc << {SOLR_DOCUMENT_ID.to_sym => pid, solr_name(:system_create, :date) => self.create_date, solr_name(:system_modified, :date) => self.modified_date, solr_name(:active_fedora_model, :symbol) => self.class.inspect}
394
+ # Return a Solr::Document version of this object.
395
+ # @solr_doc (optional) Solr::Document to insert the fields into
396
+ # @opts (optional) Hash
397
+ # If opts[:model_only] == true, the base object metadata and the RELS-EXT datastream will be omitted. This is mainly to support shelver, which calls .to_solr for each model an object subscribes to.
398
+ def to_solr(solr_doc = Solr::Document.new, opts={})
399
+ unless opts[:model_only]
400
+ solr_doc << {SOLR_DOCUMENT_ID.to_sym => pid, solr_name(:system_create, :date) => self.create_date, solr_name(:system_modified, :date) => self.modified_date, solr_name(:active_fedora_model, :symbol) => self.class.inspect}
401
+ end
390
402
  datastreams.each_value do |ds|
391
- solr_doc = ds.to_solr(solr_doc) if ds.kind_of?(ActiveFedora::MetadataDatastream) || ds.kind_of?(ActiveFedora::RelsExtDatastream)
403
+ solr_doc = ds.to_solr(solr_doc) if ds.kind_of?(ActiveFedora::MetadataDatastream) || ( ds.kind_of?(ActiveFedora::RelsExtDatastream) && !opts[:model_only] )
392
404
  end
393
405
  return solr_doc
394
406
  end
@@ -2,67 +2,51 @@ module ActiveFedora
2
2
  #this class represents a MetadataDatastream, a special case of ActiveFedora::Datastream
3
3
  class MetadataDatastream < Datastream
4
4
 
5
- include ActiveFedora::SolrMapper
6
-
7
- attr_accessor :fields
5
+ include ActiveFedora::MetadataDatastreamHelper
8
6
 
9
- #constructor, calls up to ActiveFedora::Datastream's constructor
10
- def initialize(attrs=nil)
11
- super
12
- @fields={}
13
- end
7
+ self.xml_model = ActiveFedora::MetadataDatastream
14
8
 
15
- # sets the blob, which in this case is the xml version of self, then calls ActiveFedora::Datastream.save
16
- def save
17
- self.set_blob_for_save
18
- super
19
- end
20
-
21
- def set_blob_for_save # :nodoc:
22
- self.blob = self.to_xml
23
- end
24
-
25
- def to_solr(solr_doc = Solr::Document.new) # :nodoc:
26
- fields.each do |field_key, field_info|
27
- if field_info.has_key?(:values) && !field_info[:values].nil?
28
- field_symbol = generate_solr_symbol(field_key, field_info[:type])
29
- field_info[:values].each do |val|
30
- solr_doc << Solr::Field.new(field_symbol => val)
31
- end
32
- end
33
- end
34
-
35
- return solr_doc
36
- end
37
-
38
- def to_xml(xml = REXML::Document.new("<fields />")) #:nodoc:
39
- fields.each_pair do |field,field_info|
40
- el = REXML::Element.new("#{field.to_s}")
41
- if field_info[:element_attrs]
42
- field_info[:element_attrs].each{|k,v| el.add_attribute(k.to_s, v.to_s)}
43
- end
44
- field_info[:values].each do |val|
45
- el = el.clone
46
- el.text = val.to_s
47
- if xml.class == REXML::Document
48
- xml.root.elements.add(el)
49
- else
50
- xml.add(el)
51
- end
52
- end
53
- end
54
- return xml.to_s
55
- end
56
-
57
- # @tmpl ActiveFedora::MetadataDatastream
58
- # @node Nokogiri::XML::Node
59
- def self.from_xml(tmpl, node) # :nodoc:
60
- node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/fields/node()").each do |f|
61
- tmpl.send("#{f.name}_append", f.text) unless f.class == Nokogiri::XML::Text
62
- end
63
- tmpl.send(:dirty=, false)
64
- tmpl
65
- end
9
+ # def to_solr(solr_doc = Solr::Document.new) # :nodoc:
10
+ # fields.each do |field_key, field_info|
11
+ # if field_info.has_key?(:values) && !field_info[:values].nil?
12
+ # field_symbol = generate_solr_symbol(field_key, field_info[:type])
13
+ # field_info[:values].each do |val|
14
+ # solr_doc << Solr::Field.new(field_symbol => val)
15
+ # end
16
+ # end
17
+ # end
18
+ #
19
+ # return solr_doc
20
+ # end
21
+ #
22
+ # def to_xml(xml = REXML::Document.new("<fields />")) #:nodoc:
23
+ # fields.each_pair do |field,field_info|
24
+ # el = REXML::Element.new("#{field.to_s}")
25
+ # if field_info[:element_attrs]
26
+ # field_info[:element_attrs].each{|k,v| el.add_attribute(k.to_s, v.to_s)}
27
+ # end
28
+ # field_info[:values].each do |val|
29
+ # el = el.clone
30
+ # el.text = val.to_s
31
+ # if xml.class == REXML::Document
32
+ # xml.root.elements.add(el)
33
+ # else
34
+ # xml.add(el)
35
+ # end
36
+ # end
37
+ # end
38
+ # return xml.to_s
39
+ # end
40
+ #
41
+ # # @tmpl ActiveFedora::MetadataDatastream
42
+ # # @node Nokogiri::XML::Node
43
+ # def self.from_xml(tmpl, node) # :nodoc:
44
+ # node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/fields/node()").each do |f|
45
+ # tmpl.send("#{f.name}_append", f.text) unless f.class == Nokogiri::XML::Text
46
+ # end
47
+ # tmpl.send(:dirty=, false)
48
+ # tmpl
49
+ # end
66
50
 
67
51
  # This method generates the various accessor and mutator methods on self for the datastream metadata attributes.
68
52
  # each field will have the 3 magic methods:
@@ -108,27 +92,6 @@ module ActiveFedora
108
92
  EOS
109
93
  end
110
94
 
111
- #get the field list
112
- def self.fields
113
- @@classFields
114
- end
115
-
116
- protected
117
-
118
- def generate_solr_symbol(field_name, field_type) # :nodoc:
119
- solr_name(field_name, field_type)
120
- # #if field_name.to_s[-field_type.to_s.length - 1 .. -1] == "_#{field_type.to_s}"
121
- # # return field_name.to_sym
122
- # case field_type
123
- # when :date
124
- # return "#{field_name.to_s}_dt".to_sym
125
- # when :string
126
- # return "#{field_name.to_s}_t".to_sym
127
- # else
128
- # return "#{field_name.to_s}_t".to_sym
129
- # end
130
- end
131
-
132
95
  end
133
96
 
134
97
  end
@@ -0,0 +1,104 @@
1
+ #this class represents a MetadataDatastream, a special case of ActiveFedora::Datastream
2
+ module ActiveFedora::MetadataDatastreamHelper
3
+
4
+ attr_accessor :fields
5
+
6
+ module ClassMethods
7
+
8
+ attr_accessor :xml_model
9
+
10
+ #get the Class's field list
11
+ def fields
12
+ @@classFields
13
+ end
14
+
15
+ # @tmpl ActiveFedora::MetadataDatastream
16
+ # @node Nokogiri::XML::Node
17
+ def from_xml(tmpl, node) # :nodoc:
18
+ node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/fields/node()").each do |f|
19
+ tmpl.send("#{f.name}_append", f.text) unless f.class == Nokogiri::XML::Text
20
+ end
21
+ tmpl.send(:dirty=, false)
22
+ tmpl
23
+ end
24
+
25
+ end
26
+
27
+ def self.included(klass)
28
+ klass.extend(ClassMethods)
29
+ klass.send(:include, ActiveFedora::SolrMapper)
30
+ end
31
+
32
+ #constructor, calls up to ActiveFedora::Datastream's constructor
33
+ def initialize(attrs=nil)
34
+ super
35
+ @fields={}
36
+ end
37
+
38
+ # sets the blob, which in this case is the xml version of self, then calls ActiveFedora::Datastream.save
39
+ def save
40
+ self.set_blob_for_save
41
+ super
42
+ end
43
+
44
+ def set_blob_for_save # :nodoc:
45
+ self.blob = self.to_xml
46
+ end
47
+
48
+ def to_solr(solr_doc = Solr::Document.new) # :nodoc:
49
+ fields.each do |field_key, field_info|
50
+ if field_info.has_key?(:values) && !field_info[:values].nil?
51
+ field_symbol = generate_solr_symbol(field_key, field_info[:type])
52
+ field_info[:values].each do |val|
53
+ solr_doc << Solr::Field.new(field_symbol => val)
54
+ end
55
+ end
56
+ end
57
+
58
+ return solr_doc
59
+ end
60
+
61
+ def to_xml(xml = Nokogiri::XML::Document.parse("<fields />")) #:nodoc:
62
+ if xml.instance_of?(Nokogiri::XML::Document)
63
+ xml_insertion_point = xml.root
64
+ else
65
+ xml_insertion_point = xml
66
+ end
67
+
68
+ builder = Nokogiri::XML::Builder.with(xml_insertion_point) do |xml|
69
+ fields.each_pair do |field,field_info|
70
+ element_attrs = field_info[:element_attrs].nil? ? {} : field_info[:element_attrs]
71
+ field_info[:values].each do |val|
72
+ builder_arg = "xml.#{field}(val, element_attrs)"
73
+ puts builder_arg.inspect
74
+ eval(builder_arg)
75
+ end
76
+ end
77
+ end
78
+
79
+ # fields.each_pair do |field,field_info|
80
+ # el = REXML::Element.new("#{field.to_s}")
81
+ # if field_info[:element_attrs]
82
+ # field_info[:element_attrs].each{|k,v| el.add_attribute(k.to_s, v.to_s)}
83
+ # end
84
+ # field_info[:values].each do |val|
85
+ # el = el.clone
86
+ # el.text = val.to_s
87
+ # if xml.class == REXML::Document
88
+ # xml.root.elements.add(el)
89
+ # else
90
+ # xml.add(el)
91
+ # end
92
+ # end
93
+ # end
94
+ return builder.to_xml
95
+ end
96
+
97
+
98
+ protected
99
+
100
+ def generate_solr_symbol(field_name, field_type) # :nodoc:
101
+ solr_name(field_name, field_type)
102
+ end
103
+
104
+ end
@@ -0,0 +1,60 @@
1
+ require "nokogiri"
2
+ #this class represents a MetadataDatastream, a special case of ActiveFedora::Datastream
3
+ class ActiveFedora::NokogiriDatastream < ActiveFedora::Datastream
4
+
5
+ include ActiveFedora::MetadataDatastreamHelper
6
+
7
+ self.xml_model = Nokogiri::XML::Document
8
+
9
+ attr_accessor :ng_xml
10
+
11
+ #constructor, calls up to ActiveFedora::Datastream's constructor
12
+ def initialize(attrs=nil)
13
+ super
14
+ @fields={}
15
+ @ng_xml = self.class.xml_model.new()
16
+ end
17
+
18
+ def to_solr(solr_doc = Solr::Document.new) # :nodoc:
19
+ fields.each do |field_key, field_info|
20
+ if field_info.has_key?(:values) && !field_info[:values].nil?
21
+ field_symbol = generate_solr_symbol(field_key, field_info[:type])
22
+ field_info[:values].each do |val|
23
+ solr_doc << Solr::Field.new(field_symbol => val)
24
+ end
25
+ end
26
+ end
27
+
28
+ return solr_doc
29
+ end
30
+
31
+ def to_xml(xml = REXML::Document.new("<fields />")) #:nodoc:
32
+ fields.each_pair do |field,field_info|
33
+ el = REXML::Element.new("#{field.to_s}")
34
+ if field_info[:element_attrs]
35
+ field_info[:element_attrs].each{|k,v| el.add_attribute(k.to_s, v.to_s)}
36
+ end
37
+ field_info[:values].each do |val|
38
+ el = el.clone
39
+ el.text = val.to_s
40
+ if xml.class == REXML::Document
41
+ xml.root.elements.add(el)
42
+ else
43
+ xml.add(el)
44
+ end
45
+ end
46
+ end
47
+ return xml.to_s
48
+ end
49
+
50
+ # @tmpl ActiveFedora::MetadataDatastream
51
+ # @node Nokogiri::XML::Node
52
+ def self.from_xml(tmpl, node) # :nodoc:
53
+ node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/fields/node()").each do |f|
54
+ tmpl.send("#{f.name}_append", f.text) unless f.class == Nokogiri::XML::Text
55
+ end
56
+ tmpl.send(:dirty=, false)
57
+ tmpl
58
+ end
59
+
60
+ end
@@ -10,12 +10,12 @@ describe ActiveFedora::SemanticNode do
10
10
  has_relationship "collection_members", :has_collection_member
11
11
  end
12
12
  @node = SpecNode.new
13
- class SpecModel < ActiveFedora::Base
13
+ class SNSpecModel < ActiveFedora::Base
14
14
  has_relationship("parts", :is_part_of, :inbound => true)
15
15
  has_relationship("containers", :is_member_of)
16
16
  end
17
17
 
18
- @test_object = SpecModel.new
18
+ @test_object = SNSpecModel.new
19
19
  @test_object.save
20
20
 
21
21
  @part1 = ActiveFedora::Base.new()
@@ -43,7 +43,7 @@ describe ActiveFedora::SemanticNode do
43
43
  @container2.delete
44
44
  @test_object.delete
45
45
 
46
- Object.send(:remove_const, :SpecModel)
46
+ Object.send(:remove_const, :SNSpecModel)
47
47
 
48
48
  end
49
49
 
@@ -285,8 +285,8 @@ describe ActiveFedora::Base do
285
285
  it "should call .to_xml on all MetadataDatastreams and return the resulting document" do
286
286
  mock1 = mock("ds1", :to_xml)
287
287
  mock2 = mock("ds2", :to_xml)
288
- mock1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
289
- mock2.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
288
+ mock1.expects(:included_modules).returns( [ActiveFedora::MetadataDatastreamHelper] )
289
+ mock2.expects(:included_modules).returns( [ActiveFedora::MetadataDatastreamHelper] )
290
290
 
291
291
  @test_object.expects(:datastreams).returns({:ds1 => mock1, :ds2 => mock2})
292
292
  @test_object.to_xml
@@ -318,6 +318,16 @@ describe ActiveFedora::Base do
318
318
  solr_doc[:id].should eql(@test_object.pid)
319
319
  end
320
320
 
321
+ it "should omit base metadata and RELS-EXT if :model_only==true" do
322
+ @test_object.add_relationship(:has_part, "foo")
323
+ # @test_object.expects(:modified_date).returns("mDate")
324
+ solr_doc = @test_object.to_solr(Solr::Document.new, :model_only => true)
325
+ solr_doc[:system_create_dt].should be_nil
326
+ solr_doc[:system_modified_dt].should be_nil
327
+ solr_doc[:id].should be_nil
328
+ solr_doc[:has_part_s].should be_nil
329
+ end
330
+
321
331
  it "should add self.class as the :active_fedora_model" do
322
332
  solr_doc = @test_object.to_solr
323
333
  solr_doc[:active_fedora_model_s].should eql(@test_object.class.inspect)
@@ -361,6 +371,7 @@ describe ActiveFedora::Base do
361
371
  rels_ext.expects(:to_solr)
362
372
  @test_object.to_solr
363
373
  end
374
+
364
375
  end
365
376
 
366
377
  describe ".update_index" do
@@ -54,33 +54,29 @@ describe ActiveFedora::MetadataDatastream do
54
54
  end
55
55
  it 'should output the fields hash as XML' do
56
56
  @test_ds.expects(:fields).returns(@sample_fields)
57
- #sample_rexml = REXML::Document.new(sample_xml)
58
- #returned_rexml = REXML::Document.new(@test_ds.to_dc_xml)
59
- #returned_rexml.to_s.should == sample_rexml.to_s
60
57
  returned_xml = XmlSimple.xml_in(@test_ds.to_xml)
61
58
  returned_xml.should == @sample_xml
62
59
  end
63
60
 
64
- it 'should accept an optional REXML Document as an argument and insert its fields into that' do
65
- @test_ds.expects(:fields).returns(@sample_fields)
66
- rexml = REXML::Document.new("<test_rexml/>")
67
- rexml.root.elements.expects(:add).times(5)
68
- result = @test_ds.to_xml(rexml)
61
+ it 'should accept an optional Nokogiri::XML Document as an argument and insert its fields into that (mocked test)' do
62
+ doc = Nokogiri::XML::Document.parse("<test_rexml/>")
63
+ Nokogiri::XML::Builder.expects(:with).with(doc.root).returns(doc.root)
64
+ result = @test_ds.to_xml(doc)
69
65
  end
70
- it 'should accept an optional REXML Document as an argument and insert its fields into that' do
66
+
67
+ it 'should accept an optional Nokogiri::XML Document as an argument and insert its fields into that (functional test)' do
71
68
  @test_ds.expects(:fields).returns(@sample_fields)
72
- rexml = REXML::Document.new("<test_rexml/>")
73
- result = @test_ds.to_xml(rexml)
74
- XmlSimple.xml_in(rexml.to_s).should == @sample_xml
69
+ doc = Nokogiri::XML::Document.parse("<test_rexml/>")
70
+ result = @test_ds.to_xml(doc)
71
+ XmlSimple.xml_in(doc.to_s).should == @sample_xml
75
72
  XmlSimple.xml_in(result).should == @sample_xml
76
73
  end
77
74
 
78
- it 'should add to root of REXML::Documents, but add directly to the elements if a REXML::Element is passed in' do
79
- @test_ds.expects(:fields).returns(@sample_fields).times(2)
80
- doc = REXML::Document.new("<test_document/>")
81
- el = REXML::Element.new("<test_element/>")
82
- doc.root.elements.expects(:add).times(5)
83
- el.expects(:add).times(5)
75
+ it 'should add to root of Nokogiri::XML::Documents, but add directly to the elements if a REXML::Element is passed in' do
76
+ doc = Nokogiri::XML::Document.parse("<test_document/>")
77
+ el = Nokogiri::XML::Node.new("test_element", Nokogiri::XML::Document.new)
78
+ Nokogiri::XML::Builder.expects(:with).with(doc.root).returns(doc.root)
79
+ Nokogiri::XML::Builder.expects(:with).with(el).returns(el)
84
80
  @test_ds.to_xml(doc)
85
81
  @test_ds.to_xml(el)
86
82
  end
@@ -131,7 +127,8 @@ describe ActiveFedora::MetadataDatastream do
131
127
  sds = SpecDatastream.new
132
128
  sds.mycomplicated_field_values='foo'
133
129
  sds.fields[:mycomplicated_field][:element_attrs].should == {:foo=>:bar, :baz=>:bat}
134
- sds.to_xml.should == '<fields><mycomplicated_field baz=\'bat\' foo=\'bar\'>foo</mycomplicated_field></fields>'
130
+ expected_xml = '<fields><mycomplicated_field baz=\'bat\' foo=\'bar\'>foo</mycomplicated_field></fields>'
131
+ XmlSimple.xml_in(sds.to_xml).should == XmlSimple.xml_in(expected_xml)
135
132
  end
136
133
 
137
134
  it "should add getters and setters and appenders with field name" do
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ prerelease: false
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
8
  - 4
9
- - pre2
10
- version: 1.1.4.pre2
9
+ version: 1.1.4
11
10
  platform: ruby
12
11
  authors:
13
12
  - Matt Zumwalt
@@ -296,7 +295,9 @@ files:
296
295
  - lib/active_fedora/datastream.rb
297
296
  - lib/active_fedora/fedora_object.rb
298
297
  - lib/active_fedora/metadata_datastream.rb
298
+ - lib/active_fedora/metadata_datastream_helper.rb
299
299
  - lib/active_fedora/model.rb
300
+ - lib/active_fedora/nokogiri_datastream.rb
300
301
  - lib/active_fedora/property.rb
301
302
  - lib/active_fedora/qualified_dublin_core_datastream.rb
302
303
  - lib/active_fedora/relationship.rb
@@ -392,13 +393,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
392
393
  version: "0"
393
394
  required_rubygems_version: !ruby/object:Gem::Requirement
394
395
  requirements:
395
- - - ">"
396
+ - - ">="
396
397
  - !ruby/object:Gem::Version
397
398
  segments:
398
- - 1
399
- - 3
400
- - 1
401
- version: 1.3.1
399
+ - 0
400
+ version: "0"
402
401
  requirements: []
403
402
 
404
403
  rubyforge_project: rubyfedora
@@ -442,8 +441,6 @@ test_files:
442
441
  - spec/unit/inheritance_spec.rb
443
442
  - spec/unit/metadata_datastream_spec.rb
444
443
  - spec/unit/model_spec.rb
445
- - spec/unit/mods_datastream_spec.rb
446
- - spec/unit/nokogiri_datastream_spec.rb
447
444
  - spec/unit/property_spec.rb
448
445
  - spec/unit/qualified_dublin_core_datastream_spec.rb
449
446
  - spec/unit/relationship_spec.rb
@@ -1,289 +0,0 @@
1
- require File.join( File.dirname(__FILE__), "../spec_helper" )
2
-
3
- require 'active_fedora'
4
- require 'hydra'
5
-
6
- describe ModsDatastream do
7
-
8
- before(:all) do
9
- @sample_fields = {:publisher => {:values => ["publisher1"], :type => :string},
10
- :coverage => {:values => ["coverage1", "coverage2"], :type => :text},
11
- :creation_date => {:values => "fake-date", :type => :date},
12
- :mydate => {:values => "fake-date", :type => :date},
13
- :empty_field => {:values => {}}
14
- }
15
- @sample_xml = XmlSimple.xml_in("<fields><coverage>coverage1</coverage><coverage>coverage2</coverage><creation_date>fake-date</creation_date><mydate>fake-date</mydate><publisher>publisher1</publisher></fields>")
16
-
17
- end
18
-
19
- before(:each) do
20
- @test_ds = ModsDatastream.new
21
- end
22
-
23
- after(:each) do
24
- end
25
-
26
- describe '#new' do
27
- it 'should provide #new' do
28
- ModsDatastream.should respond_to(:new)
29
- @test_ds.ng_xml.should be_instance_of(OpinionatedModsDocument)
30
- end
31
- end
32
-
33
-
34
- it 'should provide .fields' do
35
- @test_ds.should respond_to(:fields)
36
- end
37
-
38
- describe '.save' do
39
- it "should provide .save" do
40
- @test_ds.should respond_to(:save)
41
- end
42
- it "should persist the product of .to_xml in fedora" do
43
- Fedora::Repository.instance.expects(:save)
44
- @test_ds.expects(:to_xml).returns("fake xml")
45
- @test_ds.expects(:blob=).with("fake xml")
46
- @test_ds.save
47
- end
48
- end
49
-
50
- describe '.to_xml' do
51
- it "should provide .to_xml" do
52
- @test_ds.should respond_to(:to_xml)
53
- end
54
- it 'should output the fields hash as XML' do
55
- @test_ds.expects(:fields).returns(@sample_fields)
56
- #sample_rexml = REXML::Document.new(sample_xml)
57
- #returned_rexml = REXML::Document.new(@test_ds.to_dc_xml)
58
- #returned_rexml.to_s.should == sample_rexml.to_s
59
- returned_xml = XmlSimple.xml_in(@test_ds.to_xml)
60
- returned_xml.should == @sample_xml
61
- end
62
-
63
- it 'should accept an optional REXML Document as an argument and insert its fields into that' do
64
- @test_ds.expects(:fields).returns(@sample_fields)
65
- rexml = REXML::Document.new("<test_rexml/>")
66
- rexml.root.elements.expects(:add).times(5)
67
- result = @test_ds.to_xml(rexml)
68
- end
69
- it 'should accept an optional REXML Document as an argument and insert its fields into that' do
70
- @test_ds.expects(:fields).returns(@sample_fields)
71
- rexml = REXML::Document.new("<test_rexml/>")
72
- result = @test_ds.to_xml(rexml)
73
- XmlSimple.xml_in(rexml.to_s).should == @sample_xml
74
- XmlSimple.xml_in(result).should == @sample_xml
75
- end
76
-
77
- it 'should add to root of REXML::Documents, but add directly to the elements if a REXML::Element is passed in' do
78
- @test_ds.expects(:fields).returns(@sample_fields).times(2)
79
- doc = REXML::Document.new("<test_document/>")
80
- el = REXML::Element.new("<test_element/>")
81
- doc.root.elements.expects(:add).times(5)
82
- el.expects(:add).times(5)
83
- @test_ds.to_xml(doc)
84
- @test_ds.to_xml(el)
85
- end
86
-
87
- end
88
-
89
- describe '.set_blob_for_save' do
90
- it "should provide .set_blob_for_save" do
91
- @test_ds.should respond_to(:set_blob_for_save)
92
- end
93
-
94
- it "should set the blob to to_xml" do
95
- @test_ds.expects(:blob=).with(@test_ds.to_xml)
96
- @test_ds.set_blob_for_save
97
- end
98
- end
99
-
100
- describe '#field' do
101
-
102
- before(:each) do
103
- class SpecDatastream < ActiveFedora::MetadataDatastream
104
- def initialize
105
- super
106
- field :publisher, :string
107
- field :coverage, :text
108
- field :creation_date, :date
109
- field :mydate, :date
110
- field :mycomplicated_field, :string, :multiple=>false, :encoding=>'LCSH', :element_attrs=>{:foo=>:bar, :baz=>:bat}
111
- end
112
- end
113
- end
114
-
115
- after(:each) do
116
- Object.send(:remove_const, :SpecDatastream)
117
- end
118
-
119
- it 'should add corresponding field to the @fields hash and set the field :type ' do
120
- sds = SpecDatastream.new
121
- sds.fields.should_not have_key(:bio)
122
- sds.field :bio, :text
123
- sds.fields.should have_key(:bio)
124
- sds.fields[:bio].should have_key(:type)
125
- sds.fields[:bio][:type].should == :text
126
- sds.fields[:mycomplicated_field][:element_attrs].should == {:foo=>:bar, :baz=>:bat}
127
- end
128
-
129
- # it "should insert custom element attrs into the xml stream" do
130
- # sds = SpecDatastream.new
131
- # sds.mycomplicated_field_values='foo'
132
- # sds.fields[:mycomplicated_field][:element_attrs].should == {:foo=>:bar, :baz=>:bat}
133
- # sds.to_xml.should == '<fields><mycomplicated_field baz=\'bat\' foo=\'bar\'>foo</mycomplicated_field></fields>'
134
- # end
135
-
136
- it "should add getters and setters and appenders with field name" do
137
- local_test_ds = SpecDatastream.new
138
- local_test_ds.should respond_to(:publisher_values)
139
- local_test_ds.should respond_to(:publisher_append)
140
- local_test_ds.should respond_to(:publisher_values=)
141
- local_test_ds.publisher_values.class.should == Array
142
- local_test_ds.should respond_to(:coverage_values)
143
- local_test_ds.should respond_to(:coverage_values=)
144
- local_test_ds.should respond_to(:coverage_append)
145
- local_test_ds.should respond_to(:creation_date_values)
146
- local_test_ds.should respond_to(:creation_date_append)
147
- local_test_ds.should respond_to(:creation_date_values=)
148
- local_test_ds.should respond_to(:mydate_values)
149
- local_test_ds.should respond_to(:mydate_append)
150
- local_test_ds.should respond_to(:mydate_values=)
151
- end
152
-
153
- it "should track field values at instance level, not at class level" do
154
- local_test_ds1 = SpecDatastream.new
155
- local_test_ds2 = SpecDatastream.new
156
- local_test_ds1.publisher_values = ["publisher1", "publisher2"]
157
- local_test_ds2.publisher_values = ["publisherA", "publisherB"]
158
-
159
- local_test_ds2.publisher_values.should == ["publisherA", "publisherB"]
160
- local_test_ds1.publisher_values.should == ["publisher1", "publisher2"]
161
- end
162
-
163
- it "should allow you to add field values using <<" do
164
- local_test_ds1 = SpecDatastream.new
165
- local_test_ds1.publisher_values << "publisher1"
166
- local_test_ds1.publisher_values.should == ["publisher1"]
167
- end
168
-
169
- it "should create setter that always turns non-arrays into arrays" do
170
- local_test_ds = SpecDatastream.new
171
- local_test_ds.publisher_values = "Foo"
172
- local_test_ds.publisher_values.should == ["Foo"]
173
- end
174
-
175
- it "should create setter that sets datastream.dirty? to true" do
176
- local_test_ds = SpecDatastream.new
177
- local_test_ds.should_not be_dirty
178
- local_test_ds.publisher_values = "Foo"
179
- local_test_ds.should be_dirty
180
-
181
- # Note: If you use << to append values, the datastream will not be marked as dirty!
182
- #local_test_ds.dirty = false
183
-
184
- #local_test_ds.should_not be_dirty
185
- #local_test_ds.publisher_values << "Foo"
186
- #local_test_ds.should be_dirty
187
- end
188
-
189
- it "should add any extra opts to the field hash" do
190
- local_test_ds = SpecDatastream.new
191
- local_test_ds.field "myfield", :string, :foo => "foo", :bar => "bar"
192
- local_test_ds.fields[:myfield].should have_key(:foo)
193
- local_test_ds.fields[:myfield][:foo].should == "foo"
194
- local_test_ds.fields[:myfield].should have_key(:bar)
195
- local_test_ds.fields[:myfield][:bar].should == "bar"
196
- end
197
-
198
- end
199
-
200
- describe ".to_solr" do
201
-
202
- after(:all) do
203
- # Revert to default mappings after running tests
204
- ActiveFedora::SolrService.load_mappings
205
- end
206
-
207
- it "should provide .to_solr and return a SolrDocument" do
208
- @test_ds.should respond_to(:to_solr)
209
- @test_ds.to_solr.should be_kind_of(Solr::Document)
210
- end
211
-
212
- it "should optionally allow you to provide the Solr::Document to add fields to and return that document when done" do
213
- doc = Solr::Document.new
214
- @test_ds.to_solr(doc).should equal(doc)
215
- end
216
-
217
- it "should iterate through @fields hash" do
218
- @test_ds.expects(:fields).returns(@sample_fields)
219
- solr_doc = @test_ds.to_solr
220
-
221
- solr_doc[:publisher_t].should == "publisher1"
222
- solr_doc[:coverage_t].should == "coverage1"
223
- solr_doc[:creation_date_dt].should == "fake-date"
224
- solr_doc[:mydate_dt].should == "fake-date"
225
-
226
- solr_doc[:empty_field_t].should be_nil
227
- end
228
-
229
- it "should allow multiple values for a single field"
230
-
231
- it 'should append create keys in format field_name + _ + field_type' do
232
- @test_ds.stubs(:fields).returns(@sample_fields)
233
-
234
- #should have these
235
-
236
- @test_ds.to_solr[:publisher_t].should_not be_nil
237
- @test_ds.to_solr[:coverage_t].should_not be_nil
238
- @test_ds.to_solr[:creation_date_dt].should_not be_nil
239
-
240
- #should NOT have these
241
- @test_ds.to_solr[:narrator].should be_nil
242
- @test_ds.to_solr[:title].should be_nil
243
- @test_ds.to_solr[:empty_field].should be_nil
244
-
245
- end
246
-
247
- it "should use Solr mappings to generate field names" do
248
- ActiveFedora::SolrService.load_mappings(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings_af_0.1.yml"))
249
- @test_ds.stubs(:fields).returns(@sample_fields)
250
- solr_doc = @test_ds.to_solr
251
-
252
- #should have these
253
-
254
- solr_doc[:publisher_field].should == "publisher1"
255
- solr_doc[:coverage_field].should == "coverage1"
256
- solr_doc[:creation_date_date].should == "fake-date"
257
- solr_doc[:mydate_date].should == "fake-date"
258
-
259
- solr_doc[:publisher_t].should be_nil
260
- solr_doc[:coverage_t].should be_nil
261
- solr_doc[:creation_date_dt].should be_nil
262
-
263
- # Reload default mappings
264
- ActiveFedora::SolrService.load_mappings
265
- end
266
-
267
- it 'should append _dt to dates' do
268
- @test_ds.expects(:fields).returns(@sample_fields).at_least_once
269
-
270
- #should have these
271
-
272
- @test_ds.to_solr[:creation_date_dt].should_not be_nil
273
- @test_ds.to_solr[:mydate_dt].should_not be_nil
274
-
275
- #should NOT have these
276
-
277
- @test_ds.to_solr[:mydate].should be_nil
278
- @test_ds.to_solr[:creation_date_date].should be_nil
279
- end
280
-
281
- end
282
-
283
- describe '.fields' do
284
- it "should return a Hash" do
285
- @test_ds.fields.should be_instance_of(Hash)
286
- end
287
- end
288
-
289
- end
@@ -1,301 +0,0 @@
1
- require File.join( File.dirname(__FILE__), "../spec_helper" )
2
-
3
- require 'active_fedora'
4
- require 'active_fedora/nokogiri_datastream'
5
-
6
- describe ActiveFedora::NokogiriDatastream do
7
-
8
- before(:all) do
9
- @sample_fields = {:publisher => {:values => ["publisher1"], :type => :string},
10
- :coverage => {:values => ["coverage1", "coverage2"], :type => :text},
11
- :creation_date => {:values => "fake-date", :type => :date},
12
- :mydate => {:values => "fake-date", :type => :date},
13
- :empty_field => {:values => {}}
14
- }
15
- @sample_xml = XmlSimple.xml_in("<fields><coverage>coverage1</coverage><coverage>coverage2</coverage><creation_date>fake-date</creation_date><mydate>fake-date</mydate><publisher>publisher1</publisher></fields>")
16
-
17
- end
18
-
19
- before(:each) do
20
- @test_ds = ActiveFedora::NokogiriDatastream.new
21
- end
22
-
23
- after(:each) do
24
- end
25
-
26
- describe '#new' do
27
- it 'should provide #new' do
28
- ActiveFedora::NokogiriDatastream.should respond_to(:new)
29
- @test_ds.ng_xml.should be_instance_of(Nokogiri::XML::Document)
30
- end
31
- end
32
-
33
-
34
- it 'should provide .fields' do
35
- @test_ds.should respond_to(:fields)
36
- end
37
-
38
- describe '.save' do
39
- it "should provide .save" do
40
- @test_ds.should respond_to(:save)
41
- end
42
- it "should persist the product of .to_xml in fedora" do
43
- Fedora::Repository.instance.expects(:save)
44
- @test_ds.expects(:to_xml).returns("fake xml")
45
- @test_ds.expects(:blob=).with("fake xml")
46
- @test_ds.save
47
- end
48
- end
49
-
50
- describe '.to_xml' do
51
- it "should provide .to_xml" do
52
- @test_ds.should respond_to(:to_xml)
53
- end
54
- it 'should output the fields hash as XML' do
55
- @test_ds.expects(:fields).returns(@sample_fields)
56
- returned_xml = XmlSimple.xml_in(@test_ds.to_xml)
57
- returned_xml.should == @sample_xml
58
- end
59
-
60
- it 'should accept an optional REXML Document as an argument and insert its fields into that' do
61
- @test_ds.expects(:fields).returns(@sample_fields)
62
- rexml = REXML::Document.new("<test_rexml/>")
63
- rexml.root.elements.expects(:add).times(5)
64
- result = @test_ds.to_xml(rexml)
65
- end
66
- it 'should accept an optional REXML Document as an argument and insert its fields into that' do
67
- @test_ds.expects(:fields).returns(@sample_fields)
68
- rexml = REXML::Document.new("<test_rexml/>")
69
- result = @test_ds.to_xml(rexml)
70
- XmlSimple.xml_in(rexml.to_s).should == @sample_xml
71
- XmlSimple.xml_in(result).should == @sample_xml
72
- end
73
-
74
- it 'should add to root of REXML::Documents, but add directly to the elements if a REXML::Element is passed in' do
75
- @test_ds.expects(:fields).returns(@sample_fields).times(2)
76
- doc = REXML::Document.new("<test_document/>")
77
- el = REXML::Element.new("<test_element/>")
78
- doc.root.elements.expects(:add).times(5)
79
- el.expects(:add).times(5)
80
- @test_ds.to_xml(doc)
81
- @test_ds.to_xml(el)
82
- end
83
-
84
- end
85
-
86
- describe '.set_blob_for_save' do
87
- it "should provide .set_blob_for_save" do
88
- @test_ds.should respond_to(:set_blob_for_save)
89
- end
90
-
91
- it "should set the blob to to_xml" do
92
- @test_ds.expects(:blob=).with(@test_ds.to_xml)
93
- @test_ds.set_blob_for_save
94
- end
95
- end
96
-
97
- describe '#field' do
98
-
99
- before(:each) do
100
- class SpecDatastream < ActiveFedora::MetadataDatastream
101
- def initialize
102
- super
103
- field :publisher, :string
104
- field :coverage, :text
105
- field :creation_date, :date
106
- field :mydate, :date
107
- field :mycomplicated_field, :string, :multiple=>false, :encoding=>'LCSH', :element_attrs=>{:foo=>:bar, :baz=>:bat}
108
- end
109
- end
110
- end
111
-
112
- after(:each) do
113
- Object.send(:remove_const, :SpecDatastream)
114
- end
115
-
116
-
117
- decribe ".values"
118
- it "should call ng_xml.values_for(#{field_name}) OR call corresponding lookup method and build an array of values by calling .value on each node in the set"
119
- end
120
-
121
- decribe ".values<<"
122
- it "should call corresponding builder method"
123
- end
124
-
125
- decribe ".values="
126
- it "should wipe out any existing nodes, use the corresponding builder, and insert new node(s) as the replacement"
127
- end
128
-
129
- it 'should add corresponding field to the @fields hash and set the field :type ' do
130
- sds = SpecDatastream.new
131
- sds.fields.should_not have_key(:bio)
132
- sds.field :bio, :text
133
- sds.fields.should have_key(:bio)
134
- sds.fields[:bio].should have_key(:type)
135
- sds.fields[:bio][:type].should == :text
136
- sds.fields[:mycomplicated_field][:element_attrs].should == {:foo=>:bar, :baz=>:bat}
137
- end
138
-
139
- # it "should insert custom element attrs into the xml stream" do
140
- # sds = SpecDatastream.new
141
- # sds.mycomplicated_field_values='foo'
142
- # sds.fields[:mycomplicated_field][:element_attrs].should == {:foo=>:bar, :baz=>:bat}
143
- # sds.to_xml.should == '<fields><mycomplicated_field baz=\'bat\' foo=\'bar\'>foo</mycomplicated_field></fields>'
144
- # end
145
-
146
- it "should add getters and setters and appenders with field name" do
147
- local_test_ds = SpecDatastream.new
148
- local_test_ds.should respond_to(:publisher_values)
149
- local_test_ds.should respond_to(:publisher_append)
150
- local_test_ds.should respond_to(:publisher_values=)
151
- local_test_ds.publisher_values.class.should == Array
152
- local_test_ds.should respond_to(:coverage_values)
153
- local_test_ds.should respond_to(:coverage_values=)
154
- local_test_ds.should respond_to(:coverage_append)
155
- local_test_ds.should respond_to(:creation_date_values)
156
- local_test_ds.should respond_to(:creation_date_append)
157
- local_test_ds.should respond_to(:creation_date_values=)
158
- local_test_ds.should respond_to(:mydate_values)
159
- local_test_ds.should respond_to(:mydate_append)
160
- local_test_ds.should respond_to(:mydate_values=)
161
- end
162
-
163
- it "should track field values at instance level, not at class level" do
164
- local_test_ds1 = SpecDatastream.new
165
- local_test_ds2 = SpecDatastream.new
166
- local_test_ds1.publisher_values = ["publisher1", "publisher2"]
167
- local_test_ds2.publisher_values = ["publisherA", "publisherB"]
168
-
169
- local_test_ds2.publisher_values.should == ["publisherA", "publisherB"]
170
- local_test_ds1.publisher_values.should == ["publisher1", "publisher2"]
171
- end
172
-
173
- it "should allow you to add field values using <<" do
174
- local_test_ds1 = SpecDatastream.new
175
- local_test_ds1.publisher_values << "publisher1"
176
- local_test_ds1.publisher_values.should == ["publisher1"]
177
- end
178
-
179
- it "should create setter that always turns non-arrays into arrays" do
180
- local_test_ds = SpecDatastream.new
181
- local_test_ds.publisher_values = "Foo"
182
- local_test_ds.publisher_values.should == ["Foo"]
183
- end
184
-
185
- it "should create setter that sets datastream.dirty? to true" do
186
- local_test_ds = SpecDatastream.new
187
- local_test_ds.should_not be_dirty
188
- local_test_ds.publisher_values = "Foo"
189
- local_test_ds.should be_dirty
190
-
191
- # Note: If you use << to append values, the datastream will not be marked as dirty!
192
- #local_test_ds.dirty = false
193
-
194
- #local_test_ds.should_not be_dirty
195
- #local_test_ds.publisher_values << "Foo"
196
- #local_test_ds.should be_dirty
197
- end
198
-
199
- it "should add any extra opts to the field hash" do
200
- local_test_ds = SpecDatastream.new
201
- local_test_ds.field "myfield", :string, :foo => "foo", :bar => "bar"
202
- local_test_ds.fields[:myfield].should have_key(:foo)
203
- local_test_ds.fields[:myfield][:foo].should == "foo"
204
- local_test_ds.fields[:myfield].should have_key(:bar)
205
- local_test_ds.fields[:myfield][:bar].should == "bar"
206
- end
207
-
208
- end
209
-
210
- describe ".to_solr" do
211
-
212
- after(:all) do
213
- # Revert to default mappings after running tests
214
- ActiveFedora::SolrService.load_mappings
215
- end
216
-
217
- it "should iterate through the class fields, calling .values on each and appending the values to the solr doc"
218
-
219
- it "should provide .to_solr and return a SolrDocument" do
220
- @test_ds.should respond_to(:to_solr)
221
- @test_ds.to_solr.should be_kind_of(Solr::Document)
222
- end
223
-
224
- it "should optionally allow you to provide the Solr::Document to add fields to and return that document when done" do
225
- doc = Solr::Document.new
226
- @test_ds.to_solr(doc).should equal(doc)
227
- end
228
-
229
- it "should iterate through @fields hash" do
230
- @test_ds.expects(:fields).returns(@sample_fields)
231
- solr_doc = @test_ds.to_solr
232
-
233
- solr_doc[:publisher_t].should == "publisher1"
234
- solr_doc[:coverage_t].should == "coverage1"
235
- solr_doc[:creation_date_dt].should == "fake-date"
236
- solr_doc[:mydate_dt].should == "fake-date"
237
-
238
- solr_doc[:empty_field_t].should be_nil
239
- end
240
-
241
- it "should allow multiple values for a single field"
242
-
243
- it 'should append create keys in format field_name + _ + field_type' do
244
- @test_ds.stubs(:fields).returns(@sample_fields)
245
-
246
- #should have these
247
-
248
- @test_ds.to_solr[:publisher_t].should_not be_nil
249
- @test_ds.to_solr[:coverage_t].should_not be_nil
250
- @test_ds.to_solr[:creation_date_dt].should_not be_nil
251
-
252
- #should NOT have these
253
- @test_ds.to_solr[:narrator].should be_nil
254
- @test_ds.to_solr[:title].should be_nil
255
- @test_ds.to_solr[:empty_field].should be_nil
256
-
257
- end
258
-
259
- it "should use Solr mappings to generate field names" do
260
- ActiveFedora::SolrService.load_mappings(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings_af_0.1.yml"))
261
- @test_ds.stubs(:fields).returns(@sample_fields)
262
- solr_doc = @test_ds.to_solr
263
-
264
- #should have these
265
-
266
- solr_doc[:publisher_field].should == "publisher1"
267
- solr_doc[:coverage_field].should == "coverage1"
268
- solr_doc[:creation_date_date].should == "fake-date"
269
- solr_doc[:mydate_date].should == "fake-date"
270
-
271
- solr_doc[:publisher_t].should be_nil
272
- solr_doc[:coverage_t].should be_nil
273
- solr_doc[:creation_date_dt].should be_nil
274
-
275
- # Reload default mappings
276
- ActiveFedora::SolrService.load_mappings
277
- end
278
-
279
- it 'should append _dt to dates' do
280
- @test_ds.expects(:fields).returns(@sample_fields).at_least_once
281
-
282
- #should have these
283
-
284
- @test_ds.to_solr[:creation_date_dt].should_not be_nil
285
- @test_ds.to_solr[:mydate_dt].should_not be_nil
286
-
287
- #should NOT have these
288
-
289
- @test_ds.to_solr[:mydate].should be_nil
290
- @test_ds.to_solr[:creation_date_date].should be_nil
291
- end
292
-
293
- end
294
-
295
- describe '.fields' do
296
- it "should return a Hash" do
297
- @test_ds.fields.should be_instance_of(Hash)
298
- end
299
- end
300
-
301
- end