active-fedora 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/active-fedora.gemspec +11 -8
- data/lib/active_fedora/base.rb +12 -2
- data/lib/active_fedora/metadata_datastream.rb +9 -9
- data/lib/active_fedora/metadata_datastream_helper.rb +0 -26
- data/lib/active_fedora/nokogiri_datastream.rb +66 -33
- data/lib/active_fedora/solr_service.rb +1 -0
- data/lib/hydra.rb +2 -2
- data/lib/hydra/mods_article.rb +49 -0
- data/lib/hydra/opinionated_mods_document.rb +14 -0
- data/spec/fixtures/hydrangea_fixture_mods_article1.foxml.xml +187 -0
- data/spec/fixtures/mods_articles/hydrangea_article1.xml +90 -0
- data/spec/integration/full_featured_model_spec.rb +7 -0
- data/spec/integration/repository_spec.rb +4 -0
- data/spec/unit/nokogiri_datastream_spec.rb +131 -191
- data/spec/unit/semantic_node_spec.rb +1 -1
- data/spec/unit/solr_service_spec.rb +4 -0
- metadata +51 -14
- data/lib/hydra_libs/mods_datastream.rb +0 -6
- data/lib/hydra_libs/opinionated_mods_document.rb +0 -2
- data/spec/unit/mods_datastream_spec.rb +0 -289
@@ -205,7 +205,7 @@ describe ActiveFedora::SemanticNode do
|
|
205
205
|
local_node.expects(:outbound_relationships).returns({:is_member_of => ["my:_PID1_", "my:_PID2_", "my:_PID3_"]}).times(2)
|
206
206
|
mock_repo = mock("repo")
|
207
207
|
solr_result = mock("solr result", :is_a? => true)
|
208
|
-
solr_result.expects(:hits).returns([{"id"=> "my:_PID1_", "active_fedora_model_s" => "SpecNode"}, {"id"=> "my:_PID2_", "active_fedora_model_s" => "SpecNode"}, {"id"=> "my:_PID3_", "active_fedora_model_s" => "SpecNode"}])
|
208
|
+
solr_result.expects(:hits).returns([{"id"=> "my:_PID1_", "active_fedora_model_s" => ["SpecNode"]}, {"id"=> "my:_PID2_", "active_fedora_model_s" => ["SpecNode"]}, {"id"=> "my:_PID3_", "active_fedora_model_s" => ["SpecNode"]}])
|
209
209
|
ActiveFedora::SolrService.instance.conn.expects(:query).with("id:my\\:_PID1_ OR id:my\\:_PID2_ OR id:my\\:_PID3_").returns(solr_result)
|
210
210
|
mock_repo.expects(:find_model).with("my:_PID1_", SpecNode).returns("AR1")
|
211
211
|
mock_repo.expects(:find_model).with("my:_PID2_", SpecNode).returns("AR2")
|
@@ -5,6 +5,10 @@ require 'active_fedora/solr_service'
|
|
5
5
|
include ActiveFedora
|
6
6
|
|
7
7
|
describe ActiveFedora::SolrService do
|
8
|
+
after(:all) do
|
9
|
+
ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
|
10
|
+
end
|
11
|
+
|
8
12
|
it "should take a narg constructor and configure for localhost" do
|
9
13
|
mconn = mock('conn')
|
10
14
|
Solr::Connection.expects(:new).with('http://localhost:8080/solr', {:autocommit=>:on}).returns(mconn)
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
9
|
+
- 7
|
10
|
+
version: 1.1.7
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Matt Zumwalt
|
@@ -15,16 +16,18 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-06-
|
19
|
+
date: 2010-06-23 00:00:00 -05:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
23
|
name: solr-ruby
|
23
24
|
prerelease: false
|
24
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
27
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 19
|
28
31
|
segments:
|
29
32
|
- 0
|
30
33
|
- 0
|
@@ -36,9 +39,11 @@ dependencies:
|
|
36
39
|
name: xml-simple
|
37
40
|
prerelease: false
|
38
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
39
43
|
requirements:
|
40
44
|
- - ">="
|
41
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 15
|
42
47
|
segments:
|
43
48
|
- 1
|
44
49
|
- 0
|
@@ -50,9 +55,11 @@ dependencies:
|
|
50
55
|
name: mime-types
|
51
56
|
prerelease: false
|
52
57
|
requirement: &id003 !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
53
59
|
requirements:
|
54
60
|
- - ">="
|
55
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 47
|
56
63
|
segments:
|
57
64
|
- 1
|
58
65
|
- 16
|
@@ -63,9 +70,11 @@ dependencies:
|
|
63
70
|
name: multipart-post
|
64
71
|
prerelease: false
|
65
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
66
74
|
requirements:
|
67
75
|
- - ">="
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
69
78
|
segments:
|
70
79
|
- 0
|
71
80
|
version: "0"
|
@@ -75,54 +84,78 @@ dependencies:
|
|
75
84
|
name: nokogiri
|
76
85
|
prerelease: false
|
77
86
|
requirement: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
78
88
|
requirements:
|
79
89
|
- - ">="
|
80
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
81
92
|
segments:
|
82
93
|
- 0
|
83
94
|
version: "0"
|
84
95
|
type: :runtime
|
85
96
|
version_requirements: *id005
|
86
97
|
- !ruby/object:Gem::Dependency
|
87
|
-
name:
|
98
|
+
name: om
|
88
99
|
prerelease: false
|
89
100
|
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
90
102
|
requirements:
|
91
103
|
- - ">="
|
92
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 19
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
- 1
|
109
|
+
- 4
|
110
|
+
version: 0.1.4
|
111
|
+
type: :runtime
|
112
|
+
version_requirements: *id006
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rspec
|
115
|
+
prerelease: false
|
116
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
hash: 13
|
93
122
|
segments:
|
94
123
|
- 1
|
95
124
|
- 2
|
96
125
|
- 9
|
97
126
|
version: 1.2.9
|
98
127
|
type: :development
|
99
|
-
version_requirements: *
|
128
|
+
version_requirements: *id007
|
100
129
|
- !ruby/object:Gem::Dependency
|
101
130
|
name: mocha
|
102
131
|
prerelease: false
|
103
|
-
requirement: &
|
132
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
104
134
|
requirements:
|
105
135
|
- - ">="
|
106
136
|
- !ruby/object:Gem::Version
|
137
|
+
hash: 13
|
107
138
|
segments:
|
108
139
|
- 1
|
109
140
|
- 2
|
110
141
|
- 9
|
111
142
|
version: 1.2.9
|
112
143
|
type: :development
|
113
|
-
version_requirements: *
|
144
|
+
version_requirements: *id008
|
114
145
|
- !ruby/object:Gem::Dependency
|
115
146
|
name: ruby-debug
|
116
147
|
prerelease: false
|
117
|
-
requirement: &
|
148
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
118
150
|
requirements:
|
119
151
|
- - ">="
|
120
152
|
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
121
154
|
segments:
|
122
155
|
- 0
|
123
156
|
version: "0"
|
124
157
|
type: :development
|
125
|
-
version_requirements: *
|
158
|
+
version_requirements: *id009
|
126
159
|
description: ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.
|
127
160
|
email: matt.zumwalt@yourmediashelf.com
|
128
161
|
executables: []
|
@@ -325,8 +358,8 @@ files:
|
|
325
358
|
- lib/fedora/generic_search.rb
|
326
359
|
- lib/fedora/repository.rb
|
327
360
|
- lib/hydra.rb
|
328
|
-
- lib/
|
329
|
-
- lib/
|
361
|
+
- lib/hydra/mods_article.rb
|
362
|
+
- lib/hydra/opinionated_mods_document.rb
|
330
363
|
- lib/ruby-fedora.rb
|
331
364
|
- lib/util/class_level_inheritable_attributes.rb
|
332
365
|
- script/console
|
@@ -337,7 +370,9 @@ files:
|
|
337
370
|
- solr/config/solrconfig-1.5.xml
|
338
371
|
- spec/fixtures/changeme155.xml
|
339
372
|
- spec/fixtures/dino.jpg
|
373
|
+
- spec/fixtures/hydrangea_fixture_mods_article1.foxml.xml
|
340
374
|
- spec/fixtures/minivan.jpg
|
375
|
+
- spec/fixtures/mods_articles/hydrangea_article1.xml
|
341
376
|
- spec/fixtures/oh_qdc.xml
|
342
377
|
- spec/fixtures/test_12.foxml.xml
|
343
378
|
- spec/integration/base_file_management_spec.rb
|
@@ -378,7 +413,6 @@ files:
|
|
378
413
|
- spec/unit/inheritance_spec.rb
|
379
414
|
- spec/unit/metadata_datastream_spec.rb
|
380
415
|
- spec/unit/model_spec.rb
|
381
|
-
- spec/unit/mods_datastream_spec.rb
|
382
416
|
- spec/unit/nokogiri_datastream_spec.rb
|
383
417
|
- spec/unit/property_spec.rb
|
384
418
|
- spec/unit/qualified_dublin_core_datastream_spec.rb
|
@@ -402,23 +436,27 @@ rdoc_options:
|
|
402
436
|
require_paths:
|
403
437
|
- lib
|
404
438
|
required_ruby_version: !ruby/object:Gem::Requirement
|
439
|
+
none: false
|
405
440
|
requirements:
|
406
441
|
- - ">="
|
407
442
|
- !ruby/object:Gem::Version
|
443
|
+
hash: 3
|
408
444
|
segments:
|
409
445
|
- 0
|
410
446
|
version: "0"
|
411
447
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
448
|
+
none: false
|
412
449
|
requirements:
|
413
450
|
- - ">="
|
414
451
|
- !ruby/object:Gem::Version
|
452
|
+
hash: 3
|
415
453
|
segments:
|
416
454
|
- 0
|
417
455
|
version: "0"
|
418
456
|
requirements: []
|
419
457
|
|
420
458
|
rubyforge_project: rubyfedora
|
421
|
-
rubygems_version: 1.3.
|
459
|
+
rubygems_version: 1.3.7
|
422
460
|
signing_key:
|
423
461
|
specification_version: 3
|
424
462
|
summary: A convenience libary for manipulating MODS (Metadata Object Description Schema) documents.
|
@@ -458,7 +496,6 @@ test_files:
|
|
458
496
|
- spec/unit/inheritance_spec.rb
|
459
497
|
- spec/unit/metadata_datastream_spec.rb
|
460
498
|
- spec/unit/model_spec.rb
|
461
|
-
- spec/unit/mods_datastream_spec.rb
|
462
499
|
- spec/unit/nokogiri_datastream_spec.rb
|
463
500
|
- spec/unit/property_spec.rb
|
464
501
|
- spec/unit/qualified_dublin_core_datastream_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
|