active-fedora 1.0.5 → 1.1.0
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/.document +5 -0
- data/.gitignore +21 -0
- data/.hg/00changelog.i +0 -0
- data/.hg/branch +1 -0
- data/.hg/branch.cache +2 -0
- data/.hg/dirstate +0 -0
- data/.hg/hgrc +2 -0
- data/.hg/requires +2 -0
- data/.hg/store/00changelog.i +0 -0
- data/.hg/store/00manifest.i +0 -0
- data/.hg/store/data/.hgignore.i +0 -0
- data/.hg/store/data/.hgtags.i +0 -0
- data/.hg/store/data/_c_o_p_y_i_n_g.txt.i +0 -0
- data/.hg/store/data/_c_o_y_i_n_g._l_e_s_s_e_r.txt.i +0 -0
- data/.hg/store/data/_history.txt.i +0 -0
- data/.hg/store/data/_license.txt.i +0 -0
- data/.hg/store/data/_manifest.txt.i +0 -0
- data/.hg/store/data/_post_install.txt.i +0 -0
- data/.hg/store/data/_r_e_a_d_m_e.rdoc.i +0 -0
- data/.hg/store/data/_r_e_a_d_m_e.txt.i +0 -0
- data/.hg/store/data/_rakefile.i +0 -0
- data/.hg/store/data/_v_e_r_s_i_o_n.i +0 -0
- data/.hg/store/data/active-fedora.gemspec.i +0 -0
- data/.hg/store/data/active__fedora/_history.txt.i +0 -0
- data/.hg/store/data/active__fedora/_manifest.txt.i +0 -0
- data/.hg/store/data/active__fedora/_post_install.txt.i +0 -0
- data/.hg/store/data/active__fedora/_r_e_a_d_m_e.rdoc.i +0 -0
- data/.hg/store/data/active__fedora/_rakefile.i +0 -0
- data/.hg/store/data/active__fedora/lib/active__fedora.rb.i +0 -0
- data/.hg/store/data/active__fedora/script/console.i +0 -0
- data/.hg/store/data/active__fedora/script/destroy.i +0 -0
- data/.hg/store/data/active__fedora/script/generate.i +0 -0
- data/.hg/store/data/active__fedora/spec/active__fedora__spec.rb.i +0 -0
- data/.hg/store/data/active__fedora/spec/spec__helper.rb.i +0 -0
- data/.hg/store/data/config/fedora.yml.i +0 -0
- data/.hg/store/data/config/solr__mappings.yml.i +0 -0
- data/.hg/store/data/config/solr__mappings__af__0.1.yml.i +0 -0
- data/.hg/store/data/config/solr__mappings__bl__2.4.yml.i +0 -0
- data/.hg/store/data/lib/active-fedora.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/base.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/content__model.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/datastream.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/fedora__object.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/metadata__datastream.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/model.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/property.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/qualified__dublin__core__datastream.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/relationship.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/rels__ext__datastream.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/semantic__node.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/solr__mapper.rb.i +0 -0
- data/.hg/store/data/lib/active__fedora/solr__service.rb.i +0 -0
- data/.hg/store/data/lib/fedora/base.rb.i +0 -0
- data/.hg/store/data/lib/fedora/connection.rb.i +0 -0
- data/.hg/store/data/lib/fedora/datastream.rb.i +0 -0
- data/.hg/store/data/lib/fedora/fedora__object.rb.i +0 -0
- data/.hg/store/data/lib/fedora/formats.rb.i +0 -0
- data/.hg/store/data/lib/fedora/generic__search.rb.i +0 -0
- data/.hg/store/data/lib/fedora/repository.rb.i +0 -0
- data/.hg/store/data/lib/ruby-fedora.rb.i +0 -0
- data/.hg/store/data/lib/util/class__level__inheritable__attributes.rb.i +0 -0
- data/.hg/store/data/script/console.i +0 -0
- data/.hg/store/data/script/destroy.i +0 -0
- data/.hg/store/data/script/generate.i +0 -0
- data/.hg/store/data/solr/config/schema-1.5.xml.i +0 -0
- data/.hg/store/data/solr/config/schema.xml.i +0 -0
- data/.hg/store/data/solr/config/solrconfig-1.5.xml.i +0 -0
- data/.hg/store/data/spec/fixtures/changeme155.xml.i +0 -0
- data/.hg/store/data/spec/fixtures/dino.jpg.i +0 -0
- data/.hg/store/data/spec/fixtures/minivan.jpg.d +0 -0
- data/.hg/store/data/spec/fixtures/minivan.jpg.i +0 -0
- data/.hg/store/data/spec/fixtures/test__12.foxml.xml.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/base__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/fedora__object__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/full__featured__model__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/model__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/active__fedora/semantic__node__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/base__file__management__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/base__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/bug__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/datastreams__crud__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/fedora__object__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/full__featured__model__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/model__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/rels__ext__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/repository__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/rf__fedora__object__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/semantic__node__spec.rb.i +0 -0
- data/.hg/store/data/spec/integration/solr__service__spec.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/audio__record.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/image.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/oral__history.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/seminar.rb.i +0 -0
- data/.hg/store/data/spec/samples/models/seminar__audio__file.rb.i +0 -0
- data/.hg/store/data/spec/samples/oh__qdc.xml.i +0 -0
- data/.hg/store/data/spec/samples/oral__history.rb.i +0 -0
- data/.hg/store/data/spec/samples/oral__history__sample.xml.i +0 -0
- data/.hg/store/data/spec/samples/oral__history__sample__model.rb.i +0 -0
- data/.hg/store/data/spec/samples/oral__history__xml.xml.i +0 -0
- data/.hg/store/data/spec/spec.opts.i +0 -0
- data/.hg/store/data/spec/spec__helper.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/base__cma__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/base__extra__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/base__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/content__model__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/inheritance__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/metadata__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/model__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/property__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/qualified__dublin__core__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/relationship__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/semantic__node__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora/solr__service__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/active__fedora__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__cma__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__datastream__management__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__extra__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__file__management__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__loader__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/base__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/connection__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/content__model__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/datastream__concurrency__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/fedora__object__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/inheritance__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/metadata__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/model__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/property__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/qualified__dublin__core__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/relationship__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/rels__ext__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/repository__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/rf__datastream__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/semantic__node__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/solr__config__options__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/solr__mapper__spec.rb.i +0 -0
- data/.hg/store/data/spec/unit/solr__service__spec.rb.i +0 -0
- data/.hg/store/data/tasks/rspec.rake.i +0 -0
- data/.hg/store/undo +0 -0
- data/.hg/undo.branch +1 -0
- data/.hg/undo.dirstate +0 -0
- data/.hgignore +7 -0
- data/.hgtags +14 -0
- data/COPYING.txt +674 -0
- data/COYING.LESSER.txt +165 -0
- data/History.txt +34 -0
- data/LICENSE +20 -0
- data/License.txt +58 -0
- data/Manifest.txt +1 -1
- data/README.rdoc +13 -54
- data/README.txt +59 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/active-fedora.gemspec +359 -0
- data/config/fedora.yml +16 -0
- data/config/solr_mappings.yml +14 -0
- data/config/solr_mappings_af_0.1.yml +16 -0
- data/config/solr_mappings_bl_2.4.yml +14 -0
- data/lib/active_fedora.rb +66 -6
- data/lib/active_fedora/base.rb +59 -23
- data/lib/active_fedora/datastream.rb +1 -1
- data/lib/active_fedora/metadata_datastream.rb +14 -7
- data/lib/active_fedora/model.rb +4 -4
- data/lib/active_fedora/rels_ext_datastream.rb +1 -1
- data/lib/active_fedora/semantic_node.rb +4 -3
- data/lib/active_fedora/solr_mapper.rb +17 -0
- data/lib/active_fedora/solr_service.rb +44 -2
- data/lib/fedora/base.rb +38 -0
- data/lib/fedora/connection.rb +210 -0
- data/lib/fedora/datastream.rb +56 -0
- data/lib/fedora/fedora_object.rb +161 -0
- data/lib/fedora/formats.rb +30 -0
- data/lib/fedora/generic_search.rb +71 -0
- data/lib/fedora/repository.rb +287 -0
- data/lib/ruby-fedora.rb +20 -0
- data/lib/util/class_level_inheritable_attributes.rb +23 -0
- data/script/console +15 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/solr/config/schema-1.5.xml +468 -0
- data/solr/config/schema.xml +174 -212
- data/solr/config/solrconfig-1.5.xml +1069 -0
- data/spec/active_fedora_spec.rb +7 -0
- data/spec/fixtures/changeme155.xml +255 -0
- data/spec/fixtures/dino.jpg +0 -0
- data/spec/fixtures/minivan.jpg +0 -0
- data/spec/fixtures/test_12.foxml.xml +121 -0
- data/spec/integration/base_file_management_spec.rb +20 -0
- data/spec/integration/base_spec.rb +196 -0
- data/spec/integration/bug_spec.rb +57 -0
- data/spec/integration/datastream_spec.rb +60 -0
- data/spec/integration/datastreams_crud_spec.rb +208 -0
- data/spec/integration/fedora_object_spec.rb +77 -0
- data/spec/integration/full_featured_model_spec.rb +207 -0
- data/spec/integration/model_spec.rb +54 -0
- data/spec/integration/rels_ext_datastream_spec.rb +67 -0
- data/spec/integration/repository_spec.rb +297 -0
- data/spec/integration/rf_fedora_object_spec.rb +95 -0
- data/spec/integration/semantic_node_spec.rb +95 -0
- data/spec/integration/solr_service_spec.rb +33 -0
- data/spec/samples/models/audio_record.rb +29 -0
- data/spec/samples/models/image.rb +5 -0
- data/spec/samples/models/oral_history.rb +50 -0
- data/spec/samples/models/seminar.rb +29 -0
- data/spec/samples/models/seminar_audio_file.rb +34 -0
- data/spec/samples/oh_qdc.xml +32 -0
- data/spec/samples/oral_history_sample.xml +38 -0
- data/spec/samples/oral_history_sample_model.rb +39 -0
- data/spec/samples/oral_history_xml.xml +35 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +41 -0
- data/spec/unit/active_fedora_spec.rb +15 -0
- data/spec/unit/base_cma_spec.rb +25 -0
- data/spec/unit/base_datastream_management_spec.rb +119 -0
- data/spec/unit/base_extra_spec.rb +108 -0
- data/spec/unit/base_file_management_spec.rb +90 -0
- data/spec/unit/base_loader_spec.rb +43 -0
- data/spec/unit/base_spec.rb +584 -0
- data/spec/unit/connection_spec.rb +25 -0
- data/spec/unit/content_model_spec.rb +51 -0
- data/spec/unit/datastream_concurrency_spec.rb +59 -0
- data/spec/unit/datastream_spec.rb +85 -0
- data/spec/unit/fedora_object_spec.rb +66 -0
- data/spec/unit/inheritance_spec.rb +46 -0
- data/spec/unit/metadata_datastream_spec.rb +290 -0
- data/spec/unit/model_spec.rb +186 -0
- data/spec/unit/property_spec.rb +50 -0
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +177 -0
- data/spec/unit/relationship_spec.rb +77 -0
- data/spec/unit/rels_ext_datastream_spec.rb +99 -0
- data/spec/unit/repository_spec.rb +136 -0
- data/spec/unit/rf_datastream_spec.rb +49 -0
- data/spec/unit/semantic_node_spec.rb +354 -0
- data/spec/unit/solr_config_options_spec.rb +98 -0
- data/spec/unit/solr_mapper_spec.rb +31 -0
- data/spec/unit/solr_service_spec.rb +83 -0
- data/tasks/hoe.rake +0 -0
- data/tasks/rspec.rake +29 -0
- metadata +373 -55
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
|
2
|
+
|
|
3
|
+
require 'active_resource'
|
|
4
|
+
require 'fedora/repository'
|
|
5
|
+
|
|
6
|
+
describe Fedora::Connection do
|
|
7
|
+
it "should be creatable w/ a surrogate id" do
|
|
8
|
+
c = Fedora::Connection.new('http://127.0.0.1/fedora', 'fubar', 'bob')
|
|
9
|
+
c.site.to_s.should == "http://127.0.0.1/fedora"
|
|
10
|
+
c.format.should == 'fubar'
|
|
11
|
+
c.surrogate.should == 'bob'
|
|
12
|
+
end
|
|
13
|
+
it "should set a from header if surrogate defined." do
|
|
14
|
+
c = Fedora::Connection.new('http://127.0.0.1/fedora', ActiveResource::Formats[:xml], 'bob')
|
|
15
|
+
h = Hash.new
|
|
16
|
+
r= c.send(:build_request_headers,h)
|
|
17
|
+
r['From'].should == 'bob'
|
|
18
|
+
end
|
|
19
|
+
it "should not set a from header if surrogate undefined." do
|
|
20
|
+
c = Fedora::Connection.new('http://127.0.0.1/fedora' )
|
|
21
|
+
h = Hash.new
|
|
22
|
+
r= c.send(:build_request_headers,h)
|
|
23
|
+
r['From'].should be_nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
|
2
|
+
|
|
3
|
+
require 'active_fedora'
|
|
4
|
+
require 'mocha'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe ActiveFedora::ContentModel do
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
Fedora::Repository.instance.stubs(:nextid).returns("_nextid_")
|
|
11
|
+
@test_cmodel = ActiveFedora::ContentModel.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should provide #new" do
|
|
15
|
+
ActiveFedora::ContentModel.should respond_to(:new)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "#new" do
|
|
19
|
+
it "should create a kind of ActiveFedora::Base object" do
|
|
20
|
+
@test_cmodel.should be_kind_of(ActiveFedora::Base)
|
|
21
|
+
end
|
|
22
|
+
it "should set pid_suffix to empty string unless overriden in options hash" do
|
|
23
|
+
@test_cmodel.pid_suffix.should == ""
|
|
24
|
+
boo_model = ActiveFedora::ContentModel.new(:pid_suffix => "boo")
|
|
25
|
+
boo_model.pid_suffix.should == "boo"
|
|
26
|
+
end
|
|
27
|
+
it "should set namespace to cmodel unless overriden in options hash" do
|
|
28
|
+
@test_cmodel.namespace.should == "afmodel"
|
|
29
|
+
boo_model = ActiveFedora::ContentModel.new(:namespace => "boo")
|
|
30
|
+
boo_model.namespace.should == "boo"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should provide @pid_suffix" do
|
|
35
|
+
@test_cmodel.should respond_to(:pid_suffix)
|
|
36
|
+
@test_cmodel.should respond_to(:pid_suffix=)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'should provide #pid_from_ruby_class' do
|
|
40
|
+
ActiveFedora::ContentModel.should respond_to(:pid_from_ruby_class)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "#pid_from_ruby_class" do
|
|
44
|
+
it "should construct pids" do
|
|
45
|
+
ActiveFedora::ContentModel.pid_from_ruby_class(@test_cmodel.class).should == "afmodel:ActiveFedora_ContentModel"
|
|
46
|
+
ActiveFedora::ContentModel.pid_from_ruby_class(@test_cmodel.class, :namespace => "foo", :pid_suffix => "BarBar").should == "foo:ActiveFedora_ContentModelBarBar"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
Fedora::Repository.instance.expects(:nextid).returns("foo")
|
|
11
|
+
@test_object = ActiveFedora::Base.new
|
|
12
|
+
@test_datastream = ActiveFedora::Datastream.new(:pid=>@test_object.pid, :dsid=>'abcd', :blob=>StringIO.new("hi there"))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should provide #last_modified_in_repository" do
|
|
16
|
+
@test_datastream.should respond_to(:last_modified_in_repository)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should update @last_modified when #save or #content is called' do
|
|
20
|
+
pending
|
|
21
|
+
Fedora::Repository.any_instance.stubs(:save)
|
|
22
|
+
Fedora::Repository.any_instance.stubs(:fetch_custom)
|
|
23
|
+
@test_datastream.expects(:last_modified=).times(2)
|
|
24
|
+
@test_datastream.expects(:last_modified_in_repository).times(3)
|
|
25
|
+
@test_datastream.save
|
|
26
|
+
@test_datastream.content
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#save' do
|
|
30
|
+
it 'should not save to fedora if @last_modified does not match the datetime from fedora'
|
|
31
|
+
it 'should save to fedora if @last_modified matches the datetime from fedora'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#last_modified_in_repository' do
|
|
35
|
+
it "should retrieve a datetime from fedora"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should provide #check_concurrency' do
|
|
39
|
+
@test_datastream.should respond_to(:check_concurrency)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#check_concurrency' do
|
|
43
|
+
it 'should return true if @last_modified matches the datetime from fedora' do
|
|
44
|
+
pending
|
|
45
|
+
@test_datastream.expects(:last_modified_in_repository).returns("2008-10-17T00:17:18.194Z")
|
|
46
|
+
@test_datastream.last_modified = "2008-10-17T00:17:18.194Z"
|
|
47
|
+
@test_datastream.check_concurrency.should == true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should raise an error if @last_modified does not match the datetime from fedora' do
|
|
51
|
+
pending
|
|
52
|
+
@test_datastream.expects(:last_modified_in_repository).returns("blah blah blah")
|
|
53
|
+
@test_datastream.last_modified = "2008-10-17T00:17:18.194Z"
|
|
54
|
+
@test_datastream.check_concurrency.should raise_error()
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
Fedora::Repository.instance.expects(:nextid).returns("foo")
|
|
11
|
+
@test_object = ActiveFedora::Base.new
|
|
12
|
+
@test_datastream = ActiveFedora::Datastream.new(:pid=>@test_object.pid, :dsid=>'abcd', :blob=>StringIO.new("hi there"))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should implement delete" do
|
|
16
|
+
Fedora::Repository.instance.expects(:delete).with('foo/datastreams/abcd').returns(true).times(2)
|
|
17
|
+
@test_datastream.delete.should == true
|
|
18
|
+
ActiveFedora::Datastream.delete('foo', 'abcd').should == true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should set control_group" do
|
|
22
|
+
xml=<<-EOF
|
|
23
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
24
|
+
<foxml:datastream xmlns:foxml="foo" ID="Addelson_Frances19971114_FINAL.doc" STATE="A" CONTROL_GROUP="M" VERSIONABLE="true">
|
|
25
|
+
<foxml:datastreamVersion ID="Addelson_Frances19971114_FINAL.doc.0" LABEL="Addelson_Frances19971114_FINAL.doc" CREATED="2008-11-19T18:18:46.631Z" MIMETYPE="application/msword">
|
|
26
|
+
<foxml:contentLocation TYPE="INTERNAL_ID" REF="changeme:551+Addelson_Frances19971114_FINAL.doc+Addelson_Frances19971114_FINAL.doc.0"/>
|
|
27
|
+
</foxml:datastreamVersion>
|
|
28
|
+
</foxml:datastream>
|
|
29
|
+
EOF
|
|
30
|
+
n = ActiveFedora::Datastream.from_xml(ActiveFedora::Datastream.new, REXML::Document.new(xml).elements.first)
|
|
31
|
+
n.control_group.should == 'M'
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should escape dots in to_param" do
|
|
36
|
+
@test_datastream.stubs(:dsid).returns('foo.bar')
|
|
37
|
+
@test_datastream.to_param.should == 'foo%2ebar'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'should provide #save, #before_save and #after_save' do
|
|
41
|
+
@test_datastream.should respond_to(:save)
|
|
42
|
+
@test_datastream.should respond_to(:before_save)
|
|
43
|
+
@test_datastream.should respond_to(:after_save)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#save' do
|
|
47
|
+
it 'should call #before_save and #after_save' do
|
|
48
|
+
Fedora::Repository.instance.stubs(:save)
|
|
49
|
+
@test_datastream.stubs(:last_modified_in_repository)
|
|
50
|
+
@test_datastream.expects(:before_save)
|
|
51
|
+
@test_datastream.expects(:after_save)
|
|
52
|
+
@test_datastream.save
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should set @dirty to false" do
|
|
56
|
+
Fedora::Repository.instance.stubs(:save)
|
|
57
|
+
#@test_datastream.stubs(:last_modified_in_repository)
|
|
58
|
+
@test_datastream.expects(:dirty=).with(false)
|
|
59
|
+
@test_datastream.save
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe ".dirty?" do
|
|
64
|
+
it "should return the value of the @dirty attribute" do
|
|
65
|
+
@test_datastream.dirty.should equal(@test_datastream.dirty?)
|
|
66
|
+
@test_datastream.dirty = "boo"
|
|
67
|
+
@test_datastream.dirty?.should == "boo"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe ".dsid=" do
|
|
72
|
+
it "should set the datastream's dsid" do
|
|
73
|
+
@test_datastream.dsid = "foodsid"
|
|
74
|
+
@test_datastream.dsid.should == "foodsid"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should have mime_type accessors and should allow you to pass :mime_type OR :mimeType as an argument to initialize block" do
|
|
79
|
+
ds1 = ActiveFedora::Datastream.new(:mime_type=>"text/foo")
|
|
80
|
+
ds1.mime_type.should == "text/foo"
|
|
81
|
+
ds2 = ActiveFedora::Datastream.new(:mime_type=>"text/bar")
|
|
82
|
+
ds2.mime_type.should == "text/bar"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
|
2
|
+
|
|
3
|
+
describe Fedora::FedoraObject do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
Fedora::Repository.register(ActiveFedora.fedora_config[:url])
|
|
7
|
+
@test_object = Fedora::FedoraObject.new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should respond to #object_xml' do
|
|
11
|
+
Fedora::FedoraObject.should respond_to(:object_xml)
|
|
12
|
+
end
|
|
13
|
+
it 'hash should not have to_query) on it' do
|
|
14
|
+
Fedora::BaseObject.new
|
|
15
|
+
{:foo=>:bar}.to_fedora_query.should == 'foo=bar'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should respond to .object_xml' do
|
|
19
|
+
@test_object.should respond_to(:object_xml)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should provide .url" do
|
|
23
|
+
@test_object.should respond_to(:url)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe ".url" do
|
|
27
|
+
it "should return the Repository fedora_url with /objects/pid appended" do
|
|
28
|
+
Fedora::Repository.instance.expects(:fedora_url).returns(mock("fedora url", :scheme => "_scheme_", :host => "_host_", :port => "_port_", :path => "_path_"))
|
|
29
|
+
@test_object.expects(:pid).returns("_PID_")
|
|
30
|
+
@test_object.url.should == "_scheme_://_host_:_port__path_/objects/_PID_"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe ".label" do
|
|
35
|
+
before(:all) do
|
|
36
|
+
@properties = [:label, :state, :modified_date, :create_date, :owner_id]
|
|
37
|
+
@sample_attributes = {:label => "label", :state => "state", :modified_date => "modified_date", :create_date => "create_date", :owner_id => "owner_id"}
|
|
38
|
+
end
|
|
39
|
+
it "should give preference to pulling from attributes hash" do
|
|
40
|
+
@test_object.expects(:attributes).times(@properties.length*2).returns(@sample_attributes)
|
|
41
|
+
@properties.each do |p|
|
|
42
|
+
@test_object.send(p)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should rely solely on attributes hash if new_object" do
|
|
47
|
+
@test_object.new_object = true
|
|
48
|
+
@test_object.expects(:properties_from_fedora).never
|
|
49
|
+
@test_object.expects(:attributes).times(@properties.length*2).returns(@sample_attributes)
|
|
50
|
+
@properties.each do |p|
|
|
51
|
+
@test_object.send(p)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should call properties_from_fedora if not a new_object" do
|
|
56
|
+
@test_object.new_object = false
|
|
57
|
+
@test_object.expects(:properties_from_fedora).times(@properties.length).returns(@sample_attributes)
|
|
58
|
+
@test_object.expects(:attributes).times(@properties.length).returns({})
|
|
59
|
+
@properties.each do |p|
|
|
60
|
+
@test_object.send(p)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
|
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
|
+
describe ActiveFedora::Base do
|
|
9
|
+
before(:each) do
|
|
10
|
+
Fedora::Repository.instance.stubs(:nextid).returns("_nextid_")
|
|
11
|
+
class Foo < ActiveFedora::Base
|
|
12
|
+
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"foostream" do|m|
|
|
13
|
+
m.field "foostream", :string
|
|
14
|
+
end
|
|
15
|
+
has_metadata :type=>ActiveFedora::QualifiedDublinCoreDatastream, :name=>"dcstream" do|m|
|
|
16
|
+
m.field "fz", :string
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
class Bar < ActiveFedora::Base
|
|
20
|
+
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"barstream" do |m|
|
|
21
|
+
m.field "barfield", :string
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "doesn't overwrite stream specs" do
|
|
27
|
+
f = Foo.new
|
|
28
|
+
f.datastreams.size.should == 2 #doesn't get dc until saved
|
|
29
|
+
streams = f.datastreams.values.map(&:class).sort
|
|
30
|
+
# streams.pop.name.should == "ActiveFedora::Datastream" #dc isn't here till saved
|
|
31
|
+
streams.pop.name.should == "ActiveFedora::MetadataDatastream"
|
|
32
|
+
streams.pop.name.should == "ActiveFedora::QualifiedDublinCoreDatastream"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should work for multiple types" do
|
|
36
|
+
b = Foo.new
|
|
37
|
+
f = Bar.new
|
|
38
|
+
b.class.ds_specs.should_not == f.class.ds_specs
|
|
39
|
+
end
|
|
40
|
+
after do
|
|
41
|
+
Object.send(:remove_const, :Bar)
|
|
42
|
+
Object.send(:remove_const, :Foo)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
|
2
|
+
|
|
3
|
+
require 'active_fedora'
|
|
4
|
+
require 'active_fedora/metadata_datastream'
|
|
5
|
+
|
|
6
|
+
# include ActiveFedora::Datastream
|
|
7
|
+
|
|
8
|
+
describe ActiveFedora::MetadataDatastream do
|
|
9
|
+
|
|
10
|
+
before(:all) do
|
|
11
|
+
@sample_fields = {:publisher => {:values => ["publisher1"], :type => :string},
|
|
12
|
+
:coverage => {:values => ["coverage1", "coverage2"], :type => :text},
|
|
13
|
+
:creation_date => {:values => "fake-date", :type => :date},
|
|
14
|
+
:mydate => {:values => "fake-date", :type => :date},
|
|
15
|
+
:empty_field => {:values => {}}
|
|
16
|
+
}
|
|
17
|
+
@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>")
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
before(:each) do
|
|
22
|
+
@test_ds = ActiveFedora::MetadataDatastream.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
after(:each) do
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#new' do
|
|
29
|
+
it 'should provide #new' do
|
|
30
|
+
ActiveFedora::MetadataDatastream.should respond_to(:new)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
it 'should provide .fields' do
|
|
36
|
+
@test_ds.should respond_to(:fields)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '.save' do
|
|
40
|
+
it "should provide .save" do
|
|
41
|
+
@test_ds.should respond_to(:save)
|
|
42
|
+
end
|
|
43
|
+
it "should persist the product of .to_xml in fedora" do
|
|
44
|
+
Fedora::Repository.instance.expects(:save)
|
|
45
|
+
@test_ds.expects(:to_xml).returns("fake xml")
|
|
46
|
+
@test_ds.expects(:blob=).with("fake xml")
|
|
47
|
+
@test_ds.save
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe '.to_xml' do
|
|
52
|
+
it "should provide .to_xml" do
|
|
53
|
+
@test_ds.should respond_to(:to_xml)
|
|
54
|
+
end
|
|
55
|
+
it 'should output the fields hash as XML' do
|
|
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
|
+
returned_xml = XmlSimple.xml_in(@test_ds.to_xml)
|
|
61
|
+
returned_xml.should == @sample_xml
|
|
62
|
+
end
|
|
63
|
+
|
|
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)
|
|
69
|
+
end
|
|
70
|
+
it 'should accept an optional REXML Document as an argument and insert its fields into that' do
|
|
71
|
+
@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
|
|
75
|
+
XmlSimple.xml_in(result).should == @sample_xml
|
|
76
|
+
end
|
|
77
|
+
|
|
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)
|
|
84
|
+
@test_ds.to_xml(doc)
|
|
85
|
+
@test_ds.to_xml(el)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe '.set_blob_for_save' do
|
|
91
|
+
it "should provide .set_blob_for_save" do
|
|
92
|
+
@test_ds.should respond_to(:set_blob_for_save)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should set the blob to to_xml" do
|
|
96
|
+
@test_ds.expects(:blob=).with(@test_ds.to_xml)
|
|
97
|
+
@test_ds.set_blob_for_save
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe '#field' do
|
|
102
|
+
|
|
103
|
+
before(:each) do
|
|
104
|
+
class SpecDatastream < ActiveFedora::MetadataDatastream
|
|
105
|
+
def initialize
|
|
106
|
+
super
|
|
107
|
+
field :publisher, :string
|
|
108
|
+
field :coverage, :text
|
|
109
|
+
field :creation_date, :date
|
|
110
|
+
field :mydate, :date
|
|
111
|
+
field :mycomplicated_field, :string, :multiple=>false, :encoding=>'LCSH', :element_attrs=>{:foo=>:bar, :baz=>:bat}
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
after(:each) do
|
|
117
|
+
Object.send(:remove_const, :SpecDatastream)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'should add corresponding field to the @fields hash and set the field :type ' do
|
|
121
|
+
sds = SpecDatastream.new
|
|
122
|
+
sds.fields.should_not have_key(:bio)
|
|
123
|
+
sds.field :bio, :text
|
|
124
|
+
sds.fields.should have_key(:bio)
|
|
125
|
+
sds.fields[:bio].should have_key(:type)
|
|
126
|
+
sds.fields[:bio][:type].should == :text
|
|
127
|
+
sds.fields[:mycomplicated_field][:element_attrs].should == {:foo=>:bar, :baz=>:bat}
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it "should insert custom element attrs into the xml stream" do
|
|
131
|
+
sds = SpecDatastream.new
|
|
132
|
+
sds.mycomplicated_field_values='foo'
|
|
133
|
+
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>'
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "should add getters and setters and appenders with field name" do
|
|
138
|
+
local_test_ds = SpecDatastream.new
|
|
139
|
+
local_test_ds.should respond_to(:publisher_values)
|
|
140
|
+
local_test_ds.should respond_to(:publisher_append)
|
|
141
|
+
local_test_ds.should respond_to(:publisher_values=)
|
|
142
|
+
local_test_ds.publisher_values.class.should == Array
|
|
143
|
+
local_test_ds.should respond_to(:coverage_values)
|
|
144
|
+
local_test_ds.should respond_to(:coverage_values=)
|
|
145
|
+
local_test_ds.should respond_to(:coverage_append)
|
|
146
|
+
local_test_ds.should respond_to(:creation_date_values)
|
|
147
|
+
local_test_ds.should respond_to(:creation_date_append)
|
|
148
|
+
local_test_ds.should respond_to(:creation_date_values=)
|
|
149
|
+
local_test_ds.should respond_to(:mydate_values)
|
|
150
|
+
local_test_ds.should respond_to(:mydate_append)
|
|
151
|
+
local_test_ds.should respond_to(:mydate_values=)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "should track field values at instance level, not at class level" do
|
|
155
|
+
local_test_ds1 = SpecDatastream.new
|
|
156
|
+
local_test_ds2 = SpecDatastream.new
|
|
157
|
+
local_test_ds1.publisher_values = ["publisher1", "publisher2"]
|
|
158
|
+
local_test_ds2.publisher_values = ["publisherA", "publisherB"]
|
|
159
|
+
|
|
160
|
+
local_test_ds2.publisher_values.should == ["publisherA", "publisherB"]
|
|
161
|
+
local_test_ds1.publisher_values.should == ["publisher1", "publisher2"]
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it "should allow you to add field values using <<" do
|
|
165
|
+
local_test_ds1 = SpecDatastream.new
|
|
166
|
+
local_test_ds1.publisher_values << "publisher1"
|
|
167
|
+
local_test_ds1.publisher_values.should == ["publisher1"]
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it "should create setter that always turns non-arrays into arrays" do
|
|
171
|
+
local_test_ds = SpecDatastream.new
|
|
172
|
+
local_test_ds.publisher_values = "Foo"
|
|
173
|
+
local_test_ds.publisher_values.should == ["Foo"]
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "should create setter that sets datastream.dirty? to true" do
|
|
177
|
+
local_test_ds = SpecDatastream.new
|
|
178
|
+
local_test_ds.should_not be_dirty
|
|
179
|
+
local_test_ds.publisher_values = "Foo"
|
|
180
|
+
local_test_ds.should be_dirty
|
|
181
|
+
|
|
182
|
+
# Note: If you use << to append values, the datastream will not be marked as dirty!
|
|
183
|
+
#local_test_ds.dirty = false
|
|
184
|
+
|
|
185
|
+
#local_test_ds.should_not be_dirty
|
|
186
|
+
#local_test_ds.publisher_values << "Foo"
|
|
187
|
+
#local_test_ds.should be_dirty
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should add any extra opts to the field hash" do
|
|
191
|
+
local_test_ds = SpecDatastream.new
|
|
192
|
+
local_test_ds.field "myfield", :string, :foo => "foo", :bar => "bar"
|
|
193
|
+
local_test_ds.fields[:myfield].should have_key(:foo)
|
|
194
|
+
local_test_ds.fields[:myfield][:foo].should == "foo"
|
|
195
|
+
local_test_ds.fields[:myfield].should have_key(:bar)
|
|
196
|
+
local_test_ds.fields[:myfield][:bar].should == "bar"
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
describe ".to_solr" do
|
|
202
|
+
|
|
203
|
+
after(:all) do
|
|
204
|
+
# Revert to default mappings after running tests
|
|
205
|
+
ActiveFedora::SolrService.load_mappings
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it "should provide .to_solr and return a SolrDocument" do
|
|
209
|
+
@test_ds.should respond_to(:to_solr)
|
|
210
|
+
@test_ds.to_solr.should be_kind_of(Solr::Document)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "should optionally allow you to provide the Solr::Document to add fields to and return that document when done" do
|
|
214
|
+
doc = Solr::Document.new
|
|
215
|
+
@test_ds.to_solr(doc).should equal(doc)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "should iterate through @fields hash" do
|
|
219
|
+
@test_ds.expects(:fields).returns(@sample_fields)
|
|
220
|
+
solr_doc = @test_ds.to_solr
|
|
221
|
+
|
|
222
|
+
solr_doc[:publisher_t].should == "publisher1"
|
|
223
|
+
solr_doc[:coverage_t].should == "coverage1"
|
|
224
|
+
solr_doc[:creation_date_dt].should == "fake-date"
|
|
225
|
+
solr_doc[:mydate_dt].should == "fake-date"
|
|
226
|
+
|
|
227
|
+
solr_doc[:empty_field_t].should be_nil
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "should allow multiple values for a single field"
|
|
231
|
+
|
|
232
|
+
it 'should append create keys in format field_name + _ + field_type' do
|
|
233
|
+
@test_ds.stubs(:fields).returns(@sample_fields)
|
|
234
|
+
|
|
235
|
+
#should have these
|
|
236
|
+
|
|
237
|
+
@test_ds.to_solr[:publisher_t].should_not be_nil
|
|
238
|
+
@test_ds.to_solr[:coverage_t].should_not be_nil
|
|
239
|
+
@test_ds.to_solr[:creation_date_dt].should_not be_nil
|
|
240
|
+
|
|
241
|
+
#should NOT have these
|
|
242
|
+
@test_ds.to_solr[:narrator].should be_nil
|
|
243
|
+
@test_ds.to_solr[:title].should be_nil
|
|
244
|
+
@test_ds.to_solr[:empty_field].should be_nil
|
|
245
|
+
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
it "should use Solr mappings to generate field names" do
|
|
249
|
+
ActiveFedora::SolrService.load_mappings(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings_af_0.1.yml"))
|
|
250
|
+
@test_ds.stubs(:fields).returns(@sample_fields)
|
|
251
|
+
solr_doc = @test_ds.to_solr
|
|
252
|
+
|
|
253
|
+
#should have these
|
|
254
|
+
|
|
255
|
+
solr_doc[:publisher_field].should == "publisher1"
|
|
256
|
+
solr_doc[:coverage_field].should == "coverage1"
|
|
257
|
+
solr_doc[:creation_date_date].should == "fake-date"
|
|
258
|
+
solr_doc[:mydate_date].should == "fake-date"
|
|
259
|
+
|
|
260
|
+
solr_doc[:publisher_t].should be_nil
|
|
261
|
+
solr_doc[:coverage_t].should be_nil
|
|
262
|
+
solr_doc[:creation_date_dt].should be_nil
|
|
263
|
+
|
|
264
|
+
# Reload default mappings
|
|
265
|
+
ActiveFedora::SolrService.load_mappings
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
it 'should append _dt to dates' do
|
|
269
|
+
@test_ds.expects(:fields).returns(@sample_fields).at_least_once
|
|
270
|
+
|
|
271
|
+
#should have these
|
|
272
|
+
|
|
273
|
+
@test_ds.to_solr[:creation_date_dt].should_not be_nil
|
|
274
|
+
@test_ds.to_solr[:mydate_dt].should_not be_nil
|
|
275
|
+
|
|
276
|
+
#should NOT have these
|
|
277
|
+
|
|
278
|
+
@test_ds.to_solr[:mydate].should be_nil
|
|
279
|
+
@test_ds.to_solr[:creation_date_date].should be_nil
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
describe '.fields' do
|
|
285
|
+
it "should return a Hash" do
|
|
286
|
+
@test_ds.fields.should be_instance_of(Hash)
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
end
|