active-fedora 4.0.0.rc16 → 4.0.0.rc17

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- require 'active_fedora'
4
- require 'active_fedora/base'
5
- require 'active_fedora/metadata_datastream'
6
- require 'active_fedora/qualified_dublin_core_datastream'
7
-
8
3
  describe ActiveFedora::Base do
9
4
  before(:each) do
10
5
  #Fedora::Repository.instance.stubs(:nextid).returns("_nextid_")
@@ -12,9 +7,10 @@ describe ActiveFedora::Base do
12
7
  has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"foostream" do|m|
13
8
  m.field "foostream", :string
14
9
  end
15
- has_metadata :type=>ActiveFedora::QualifiedDublinCoreDatastream, :name=>"dcstream" do|m|
16
- m.field "fz", :string
17
- end
10
+ has_metadata :type=>ActiveFedora::QualifiedDublinCoreDatastream, :name=>"dcstream"
11
+ # do|m|
12
+ # m.field "fz", :string
13
+ # end
18
14
  end
19
15
  class Bar < ActiveFedora::Base
20
16
  has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"barstream" do |m|
@@ -1,52 +1,47 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::QualifiedDublinCoreDatastream do
4
+ DC_ELEMENTS = [:contributor, :coverage, :creator, :date, :description, :identifier, :language, :publisher, :relation, :rights, :source]
4
5
 
5
6
  before(:all) do
6
7
  # Load Sample OralHistory Model
7
8
  require File.join( File.dirname(__FILE__), "..", "samples","oral_history_sample_model" )
8
- @dc_elements = [:contributor, :coverage, :creator, :date, :description, :format, :identifier, :language, :publisher, :relation, :rights, :source]
9
9
  @dc_terms = []
10
10
  end
11
11
 
12
12
  before(:each) do
13
- stub_get("_nextid_", ['RELS-EXT', 'sensitive_passages', 'significant_passages', 'dublin_core', 'properties'])
14
- Rubydora::Repository.any_instance.stubs(:client).returns(@mock_client)
15
- ActiveFedora::Base.stubs(:assign_pid).returns("_nextid_")
16
- @test_ds = ActiveFedora::QualifiedDublinCoreDatastream.new(nil, nil)
17
- @test_ds.stubs(:content).returns('')
13
+ @sample_xml = "<dc xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:dcterms='http://purl.org/dc/terms/'>
14
+ <dcterms:type xsi:type='DCMITYPE'>sound</dcterms:type>
15
+ <dcterms:medium>medium</dcterms:medium>
16
+ <dcterms:rights>rights</dcterms:rights>
17
+ <dcterms:language>English</dcterms:language>
18
+ <dcterms:temporal>tmp</dcterms:temporal>
19
+ <dcterms:subject>kw1</dcterms:subject>
20
+ <dcterms:subject>kw2</dcterms:subject>
21
+ <dcterms:creator>creator</dcterms:creator>
22
+ <dcterms:creator>creator</dcterms:creator>
23
+ <dcterms:contributor>contributor</dcterms:contributor>
24
+ <dcterms:coverage>coverage</dcterms:coverage>
25
+ <dcterms:identifier>identifier</dcterms:identifier>
26
+ <dcterms:relation>relation</dcterms:relation>
27
+ <dcterms:source>source</dcterms:source>
28
+ <dcterms:title>title</dcterms:title>
29
+ <dcterms:extent>extent</dcterms:extent>
30
+ <dcterms:format>audio/x-wav</dcterms:format>
31
+ <dcterms:subject xsi:type='LCSH'>sh1</dcterms:subject>
32
+ <dcterms:subject xsi:type='LCSH'>sh2</dcterms:subject>
33
+ <dcterms:spatial>sp1</dcterms:spatial>
34
+ <dcterms:spatial>sp2</dcterms:spatial>
35
+ <dcterms:publisher>jwa</dcterms:publisher>
36
+ <dcterms:alternative>alt</dcterms:alternative>
37
+ <dcterms:description>desc</dcterms:description>
38
+ <dcterms:date>datestr</dcterms:date>
39
+ </dc>"
40
+ @test_ds = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(@sample_xml )
18
41
 
19
42
  end
20
43
  it "from_xml should parse everything correctly" do
21
- #originally just tested that lcsh encoding and stuff worked, but the other stuff is worth testing
22
- tmpl = OralHistorySampleModel.new.datastreams['dublin_core']
23
-
24
- tmpl.expects(:subject_append).with('sh1')
25
- tmpl.expects(:subject_append).with('sh2')
26
- tmpl.expects(:subject_append).with('kw2')
27
- tmpl.expects(:subject_append).with('kw1')
28
- tmpl.expects(:spatial_append).with('sp1')
29
- tmpl.expects(:spatial_append).with('sp2')
30
- tmpl.expects(:language_append).with('English')
31
- tmpl.expects(:alternative_append).with('alt')
32
- tmpl.expects(:title_append).with('title')
33
- tmpl.expects(:temporal_append).with('tmp')
34
- tmpl.expects(:extent_append).with('extent')
35
- tmpl.expects(:medium_append).with('medium')
36
- tmpl.expects(:format_append).with('audio/x-wav')
37
- tmpl.expects(:subject_heading_append).with('sh1')
38
- tmpl.expects(:subject_heading_append).with('sh2')
39
- tmpl.expects(:creator_append).with('creator')
40
- tmpl.expects(:type_append).with('sound')
41
- tmpl.expects(:rights_append).with('rights')
42
- tmpl.expects(:publisher_append).with('jwa')
43
- tmpl.expects(:description_append).with('desc')
44
-
45
- sample_xml = fixture('oh_qdc.xml')
46
- sample_ds_xml = Nokogiri::XML::Document.parse(sample_xml).xpath('//foxml:datastream/foxml:datastreamVersion/foxml:xmlContent/dc').first
47
-
48
- z = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(sample_ds_xml.to_s, tmpl)
49
- z.should === tmpl
44
+ @test_ds.ng_xml.should be_equivalent_to @sample_xml
50
45
  end
51
46
 
52
47
  it "should create the right number of fields" do
@@ -58,31 +53,13 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
58
53
 
59
54
  end
60
55
 
61
- it "should have identity in and out" do
62
- sample = fixture('oh_qdc.xml')
63
- tmpl = OralHistorySampleModel.new.datastreams['dublin_core']
64
- x1 = Nokogiri::XML::Document.parse(sample).xpath('/wrapper/foxml:datastream/foxml:datastreamVersion/foxml:xmlContent/dc').first.to_xml
65
- z = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(x1, tmpl)
66
- y = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(z.to_dc_xml, tmpl)
67
- y.to_dc_xml.should == z.to_dc_xml
68
- end
69
-
70
- it "should handle arbitrary attribs" do
71
- tmpl = OralHistorySampleModel.new.datastreams['dublin_core']
72
- tmpl.field :mycomplicated, :string, :xml_node=>'alt', :element_attrs=>{:foo=>'bar'}
73
- tmpl.mycomplicated_values='fubar'
74
- Nokogiri::XML(tmpl.to_dc_xml).should be_equivalent_to('<dc xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' xmlns:dcterms=\'http://purl.org/dc/terms/\'><dcterms:alt foo=\'bar\'>fubar</dcterms:alt></dc>')
75
- end
76
-
77
-
78
-
79
56
  it "should parse dcterms and dcelements from xml" do
80
57
  doc = Nokogiri::XML::Document.parse(File.open( File.dirname(__FILE__)+'/../fixtures/changeme155.xml') )
81
58
  stream = doc.xpath('//foxml:datastream[@ID=\'dublin_core\']/foxml:datastreamVersion/foxml:xmlContent/dc')
82
59
  ds = ActiveFedora::QualifiedDublinCoreDatastream.new(nil, nil)
83
60
  n = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(stream.to_xml, ds)
84
- n.spatial_values.should == ["Boston [7013445]", "Dorchester [7013575]", "Roxbury [7015002]"]
85
- n.title_values.should == ["Oral history with Frances Addelson, 1997 November 14"]
61
+ n.spatial.should == ["Boston [7013445]", "Dorchester [7013575]", "Roxbury [7015002]"]
62
+ n.title.should == ["Oral history with Frances Addelson, 1997 November 14"]
86
63
  n.dirty?.should == false
87
64
 
88
65
  end
@@ -102,79 +79,46 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
102
79
  ActiveFedora::QualifiedDublinCoreDatastream.should respond_to(:new)
103
80
  end
104
81
 
105
- it 'should initialize an object with fields for all DC elements' do
106
- @dc_elements.each do |el|
107
- @test_ds.fields.should_not be_nil
108
- @test_ds.fields.should have_key("#{el.to_s}".to_sym)
109
- end
110
- end
111
82
 
112
- it 'should respond to getters and setters for all DC elements' do
113
- @dc_elements.each do |el|
114
- @test_ds.should respond_to("#{el.to_s}_values")
115
- @test_ds.should respond_to("#{el.to_s}_values=")
116
- eval("@test_ds.#{el.to_s}_values").class.should == Array
117
- eval("@test_ds.#{el.to_s}_values = ['test_value']").should == ['test_value']
83
+ describe "model methods" do
84
+
85
+ DC_ELEMENTS.each do |el|
86
+ it "should respond to getters and setters for #{el} element" do
87
+ pending if el == :type
88
+ value = "Hey #{el}"
89
+ @test_ds.send("#{el.to_s}=", value)
90
+ @test_ds.send(el).first.should == value #Looking at first because creator has 2 nodes
91
+ end
118
92
  end
119
93
  end
120
94
 
121
95
  end
122
96
 
123
- describe 'serialize!' do
124
- it "should call .content= with to_dc_xml" do
125
- result = @test_ds.to_dc_xml
126
- @test_ds.ensure_xml_loaded
127
- @test_ds.expects(:content=).with(result)
128
- @test_ds.expects(:dirty?).returns(true)
129
- @test_ds.serialize!
130
- end
131
- end
132
-
133
- describe '.to_dc_xml' do
97
+ describe '.to_xml' do
134
98
 
135
- it 'should respond to .to_dc_xml' do
136
- @test_ds.should respond_to(:to_dc_xml)
137
- end
138
-
139
-
140
- #
141
- # I think the fields should just be tracked as a Nokogiri::XML::Document internally. Too much BS otherwise.
142
- #
143
-
144
-
145
99
  it 'should output the fields hash as Qualified Dublin Core XML' do
100
+ #@test_ds.expects(:new?).returns(true).twice
146
101
  sample_xml = "<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><dcterms:title>title1</dcterms:title><dcterms:publisher>publisher1</dcterms:publisher><dcterms:creator>creator1</dcterms:creator><dcterms:creator>creator2</dcterms:creator></dc>"
147
- #@test_ds.expects(:fields).returns({:publisher => ["publisher1"], :creator => ["creator1", "creator2"], :title => ["title1"]})
148
- @test_ds.publisher_values = ["publisher1"]
149
- @test_ds.creator_values = ["creator1", "creator2"]
150
- @test_ds.title_values = ["title1"]
151
-
152
- dc_xml = XmlSimple.xml_in(@test_ds.to_dc_xml)
153
- dc_xml.should == XmlSimple.xml_in(sample_xml)
102
+ @test_ds = ActiveFedora::QualifiedDublinCoreDatastream.new(nil, 'qdc' )
103
+
104
+ @test_ds.field :publisher
105
+ @test_ds.field :creator
106
+ @test_ds.field :title
107
+
108
+ @test_ds.publisher= ["publisher1"]
109
+ @test_ds.creator= ["creator1", "creator2"]
110
+ @test_ds.title= ["title1"]
111
+
112
+ @test_ds.to_xml.should be_equivalent_to('
113
+ <dc xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
114
+ <dcterms:publisher>publisher1</dcterms:publisher>
115
+ <dcterms:creator>creator1</dcterms:creator>
116
+ <dcterms:creator>creator2</dcterms:creator>
117
+ <dcterms:title>title1</dcterms:title>
118
+ </dc>')
154
119
  end
155
120
 
156
- it 'should not include :type information' do
157
- @test_ds.publisher_values = ["publisher1"]
158
- dc_xml = XmlSimple.xml_in(@test_ds.to_dc_xml)
159
- @test_ds.fields[:publisher].should have_key(:type)
160
- dc_xml["publisher"].should_not include("type")
161
- end
162
-
163
- it "should use specified :xml_node if it is available in the field Hash" do
164
- @test_ds.stubs(:fields).returns({:myfieldname => {:values => ["sample spatial coverage"], :xml_node => "nodename" }})
165
- Nokogiri::XML::Document.parse(@test_ds.to_dc_xml).xpath('./dc/dcterms:nodename').text.should == 'sample spatial coverage'
166
- end
167
121
 
168
- it "should use specified :xml_node if it was specified when .field was called" do
169
- sample_xml = "<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><dcterms:nodename>sample spatial coverage</dcterms:nodename></dc>"
170
- @test_ds.field :myfieldname, :string, :xml_node => "nodename"
171
- @test_ds.myfieldname_values = "sample spatial coverage"
172
- dc_xml = XmlSimple.xml_in(@test_ds.to_dc_xml)
173
- dc_xml.should == XmlSimple.xml_in(sample_xml)
174
- end
175
-
176
- it "should only apply encoding info and other qualifiers to the nodes that explicitly declare it" do
177
- end
178
122
  end
179
123
 
180
124
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::SolrDigitalObject do
4
4
  describe "repository" do
5
- subject { ActiveFedora::SolrDigitalObject.new({}) }
5
+ subject { ActiveFedora::SolrDigitalObject.new({},{'datastreams'=>{}}) }
6
6
  describe "when not finished" do
7
7
  it "should not respond_to? :repository" do
8
8
  subject.should_not respond_to :repository
@@ -28,7 +28,7 @@ describe ActiveFedora::SolrDigitalObject do
28
28
  after do
29
29
  Object.send(:remove_const, :WithoutMetadataDs)
30
30
  end
31
- subject { ActiveFedora::SolrDigitalObject.new({'properties_dsProfile_dsMIME_s' =>'text/xml'}, WithoutMetadataDs) }
31
+ subject { ActiveFedora::SolrDigitalObject.new({}, {'datastreams'=>{'properties'=>{'dsMIME'=>'text/xml'}}},WithoutMetadataDs) }
32
32
  it "should create an xml datastream" do
33
33
  subject.datastreams['properties'].should be_kind_of ActiveFedora::NokogiriDatastream
34
34
  end
@@ -1,6 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
-
4
3
  describe ActiveFedora::SolrService do
5
4
  before do
6
5
  Thread.current[:solr_service]=nil
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424181
4
+ hash: 15424183
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 4
8
8
  - 0
9
9
  - 0
10
10
  - rc
11
- - 16
12
- version: 4.0.0.rc16
11
+ - 17
12
+ version: 4.0.0.rc17
13
13
  platform: ruby
14
14
  authors:
15
15
  - Matt Zumwalt
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2012-03-26 00:00:00 Z
22
+ date: 2012-03-29 00:00:00 Z
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
25
  prerelease: false
@@ -103,14 +103,14 @@ dependencies:
103
103
  requirements:
104
104
  - - ~>
105
105
  - !ruby/object:Gem::Version
106
- hash: 15424087
106
+ hash: 15424083
107
107
  segments:
108
108
  - 1
109
109
  - 6
110
110
  - 0
111
111
  - rc
112
- - 1
113
- version: 1.6.0.rc1
112
+ - 3
113
+ version: 1.6.0.rc3
114
114
  version_requirements: *id006
115
115
  name: om
116
116
  type: :runtime
@@ -299,13 +299,14 @@ dependencies:
299
299
  requirement: &id019 !ruby/object:Gem::Requirement
300
300
  none: false
301
301
  requirements:
302
- - - ~>
302
+ - - ">="
303
303
  - !ruby/object:Gem::Version
304
- hash: 3
304
+ hash: 43
305
305
  segments:
306
306
  - 2
307
+ - 9
307
308
  - 0
308
- version: "2.0"
309
+ version: 2.9.0
309
310
  version_requirements: *id019
310
311
  name: rspec
311
312
  type: :development
@@ -371,7 +372,6 @@ files:
371
372
  - lib/active_fedora/associations/belongs_to_association.rb
372
373
  - lib/active_fedora/associations/has_and_belongs_to_many_association.rb
373
374
  - lib/active_fedora/associations/has_many_association.rb
374
- - lib/active_fedora/attribute_methods.rb
375
375
  - lib/active_fedora/base.rb
376
376
  - lib/active_fedora/callbacks.rb
377
377
  - lib/active_fedora/config.rb
@@ -432,7 +432,6 @@ files:
432
432
  - spec/fixtures/minivan.jpg
433
433
  - spec/fixtures/mixed_rdf_descMetadata.nt
434
434
  - spec/fixtures/mods_articles/hydrangea_article1.xml
435
- - spec/fixtures/oh_qdc.xml
436
435
  - spec/fixtures/rails_root/config/fake_fedora.yml
437
436
  - spec/fixtures/rails_root/config/fedora.yml
438
437
  - spec/fixtures/rails_root/config/predicate_mappings.yml
@@ -593,7 +592,6 @@ test_files:
593
592
  - spec/fixtures/minivan.jpg
594
593
  - spec/fixtures/mixed_rdf_descMetadata.nt
595
594
  - spec/fixtures/mods_articles/hydrangea_article1.xml
596
- - spec/fixtures/oh_qdc.xml
597
595
  - spec/fixtures/rails_root/config/fake_fedora.yml
598
596
  - spec/fixtures/rails_root/config/fedora.yml
599
597
  - spec/fixtures/rails_root/config/predicate_mappings.yml
@@ -1,9 +0,0 @@
1
- #attribute_methods/write.rb
2
- module ActiveFedora
3
- module AttributeMethods
4
- extend ActiveSupport::Concern
5
-
6
- module ClassMethods
7
- end
8
- end
9
- end
@@ -1,32 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <wrapper xmlns:foxml="info:fedora/fedora-system:def/foxml#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
- xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
4
-
5
- <foxml:datastream ID='dublin_core' STATE='A' CONTROL_GROUP='X' VERSIONABLE='true'>
6
- <foxml:datastreamVersion SIZE='1726' ID='dublin_core.0' MIMETYPE='text/xml' LABEL='' CREATED='2009-01-15T17:55:49.277Z'>
7
- <foxml:xmlContent>
8
- <dc xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:dcterms='http://purl.org/dc/terms/'>
9
- <dcterms:type xsi:type='DCMITYPE'>sound</dcterms:type>
10
- <dcterms:medium>medium</dcterms:medium>
11
- <dcterms:rights>rights</dcterms:rights>
12
- <dcterms:language>English</dcterms:language>
13
- <dcterms:temporal>tmp</dcterms:temporal>
14
- <dcterms:subject>kw1</dcterms:subject>
15
- <dcterms:subject>kw2</dcterms:subject>
16
- <dcterms:creator>creator</dcterms:creator>
17
- <dcterms:title>title</dcterms:title>
18
- <dcterms:extent>extent</dcterms:extent>
19
- <dcterms:format>audio/x-wav</dcterms:format>
20
- <dcterms:subject xsi:type='LCSH'>sh1</dcterms:subject>
21
- <dcterms:subject xsi:type='LCSH'>sh2</dcterms:subject>
22
- <dcterms:spatial>sp1</dcterms:spatial>
23
- <dcterms:spatial>sp2</dcterms:spatial>
24
- <dcterms:publisher>jwa</dcterms:publisher>
25
- <dcterms:alternative>alt</dcterms:alternative>
26
- <dcterms:description>desc</dcterms:description>
27
- <dcterms:date>datestr</dcterms:date>
28
- </dc>
29
- </foxml:xmlContent>
30
- </foxml:datastreamVersion>
31
- </foxml:datastream>
32
- </wrapper>