active-fedora 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,15 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
+
|
3
|
+
# For testing Module-level methods like ActiveFedora.init
|
4
|
+
|
5
|
+
describe ActiveFedora do
|
6
|
+
|
7
|
+
describe ".push_models_to_fedora" do
|
8
|
+
it "should push the model definition for each of the ActiveFedora models into Fedora CModel objects" do
|
9
|
+
pending
|
10
|
+
# find all of the models
|
11
|
+
# create a cmodel for each model with the appropriate pid
|
12
|
+
# push the model definition into the cmodel's datastream (ie. dsname: oral_history.rb vs dsname: ruby)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
+
|
3
|
+
describe ActiveFedora::Base do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
Fedora::Repository.instance.stubs(:nextid).returns('_nextid_')
|
7
|
+
@test_object = ActiveFedora::Base.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.save' do
|
11
|
+
|
12
|
+
it "should add hasModel relationship that points to the CModel if @new_object" do
|
13
|
+
@test_object.expects(:new_object?).returns(true)
|
14
|
+
|
15
|
+
@test_object.expects(:add_relationship).with(:has_model, ActiveFedora::ContentModel.pid_from_ruby_class(@test_object.class))
|
16
|
+
mock_repo = mock("repository")
|
17
|
+
mock_repo.expects(:save).with(@test_object.inner_object)
|
18
|
+
Fedora::Repository.stubs(:instance).returns(mock_repo)
|
19
|
+
@test_object.stubs(:update_index)
|
20
|
+
@test_object.expects(:refresh)
|
21
|
+
@test_object.save
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
+
|
3
|
+
describe ActiveFedora::Base do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
Fedora::Repository.instance.expects(:nextid).returns("__nextid__")
|
7
|
+
@test_object = ActiveFedora::Base.new
|
8
|
+
#Fedora::Repository.instance.delete(@test_object.inner_object)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '.generate_dsid' do
|
12
|
+
it "should return a dsid that is not currently in use" do
|
13
|
+
dsids = Hash["DS1"=>1, "DS2"=>1]
|
14
|
+
@test_object.expects(:datastreams).returns(dsids)
|
15
|
+
generated_id = @test_object.generate_dsid
|
16
|
+
generated_id.should_not be_nil
|
17
|
+
generated_id.should == "DS3"
|
18
|
+
end
|
19
|
+
it "should accept a prefix argument, default to using DS as prefix" do
|
20
|
+
@test_object.generate_dsid("FOO").should == "FOO1"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
describe '.add_datastream' do
|
24
|
+
it "should not call Datastream.save" do
|
25
|
+
ds = ActiveFedora::Datastream.new(:dsid => 'ds_to_add')
|
26
|
+
ds.expects(:save).never
|
27
|
+
@test_object.add_datastream(ds)
|
28
|
+
end
|
29
|
+
it "should add the datastream to the datastreams_in_memory array" do
|
30
|
+
ds = ActiveFedora::Datastream.new(:dsID => 'ds_to_add')
|
31
|
+
@test_object.datastreams.should_not have_key(ds.dsid)
|
32
|
+
@test_object.add_datastream(ds)
|
33
|
+
@test_object.datastreams_in_memory.should have_key(ds.dsid)
|
34
|
+
end
|
35
|
+
it "should auto-assign dsids using auto-incremented integers if dsid is nil or an empty string" do
|
36
|
+
ds = ActiveFedora::Datastream.new()
|
37
|
+
ds.dsid.should == nil
|
38
|
+
ds_emptystringid = ActiveFedora::Datastream.new()
|
39
|
+
ds_emptystringid.dsid = ""
|
40
|
+
@test_object.expects(:generate_dsid).returns("foo").times(2)
|
41
|
+
ds.expects(:dsid=).with("foo")
|
42
|
+
@test_object.add_datastream(ds)
|
43
|
+
@test_object.add_datastream(ds_emptystringid)
|
44
|
+
end
|
45
|
+
it "should accept a prefix option and apply it to automatically assigned dsids" do
|
46
|
+
ds = ActiveFedora::Datastream.new()
|
47
|
+
ds.dsid.should == nil
|
48
|
+
@test_object.expects(:generate_dsid).with("FOO")
|
49
|
+
@test_object.add_datastream(ds, :prefix => "FOO")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '.datastreams' do
|
54
|
+
it "if the object is not new should call .datastreams_in_fedora and put the result into @datastreams" do
|
55
|
+
@test_object.instance_variable_set(:@new_object, false)
|
56
|
+
ivar_before = @test_object.instance_variable_get(:@datastreams).dup
|
57
|
+
@test_object.expects(:datastreams_in_fedora).returns({:meh=>'feh'})
|
58
|
+
datastreams = @test_object.datastreams
|
59
|
+
@test_object.instance_variable_get(:@datastreams).values.should == ['feh']
|
60
|
+
datastreams.values.should ==['feh']
|
61
|
+
@test_object.instance_variable_get(:@datastreams).should_not equal(ivar_before)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '.datastreams_in_memory' do
|
66
|
+
it "should return the @datastreams array" do
|
67
|
+
the_ivar = @test_object.instance_variable_set(:@datastreams, {})
|
68
|
+
@test_object.datastreams_in_memory.should equal(the_ivar)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '.datastreams_in_fedora' do
|
73
|
+
it "should read the datastreams list from fedora" do
|
74
|
+
@test_object.expects(:datastreams_xml).returns(Hash['datastream' => Hash[]])
|
75
|
+
@test_object.datastreams_in_fedora
|
76
|
+
end
|
77
|
+
it "should pull the dsLabel if it is set" do
|
78
|
+
@test_object.expects(:datastreams_xml).returns({"datastream"=>[
|
79
|
+
{"label"=>"Dublin Core Record for this object", "dsid"=>"DC", "mimeType"=>"text/xml"},
|
80
|
+
{"label"=>"", "dsid"=>"RELS-EXT", "mimeType"=>"text/xml"},
|
81
|
+
{"label"=>"Sample Image", "dsid"=>"IMAGE1", "mimeType"=>"image/png"}]})
|
82
|
+
result = @test_object.datastreams_in_fedora
|
83
|
+
result["DC"].label.should == "Dublin Core Record for this object"
|
84
|
+
result["RELS-EXT"].label.should == ""
|
85
|
+
result["IMAGE1"].label.should == "Sample Image"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should pull the mimeType if it is set" do
|
89
|
+
pending
|
90
|
+
# Implementing this would require re-workign the initializer in Fedora::Datastream
|
91
|
+
@test_object.expects(:datastreams_xml).returns({"datastream"=>[
|
92
|
+
{"label"=>"Dublin Core Record for this object", "dsid"=>"DC", "mimeType"=>"text/xml"},
|
93
|
+
{"label"=>"", "dsid"=>"RELS-EXT", "mimeType"=>"text/xml"},
|
94
|
+
{"label"=>"Sample Image", "dsid"=>"IMAGE1", "mimeType"=>"image/png"}]})
|
95
|
+
result = @test_object.datastreams_in_fedora
|
96
|
+
result["DC"].attributes[:mimeType].should == "text/xml"
|
97
|
+
result["RELS-EXT"].attributes[:mimeType].should == "text/xml"
|
98
|
+
result["IMAGE1"].attributes[:mimeType].should == "image/png"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'add' do
|
103
|
+
it "should call .add_datastream" do
|
104
|
+
@test_object.expects(:add_datastream)
|
105
|
+
@test_object.add(stub("datastream").stub_everything)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'refresh' do
|
110
|
+
it "should pull object attributes from Fedora then merge the contents of .datastreams_in_fedora and .datastreams_in_memory, giving preference to the ones in memory" do
|
111
|
+
@test_object.stubs(:datastreams_in_fedora).returns({:foo => "foo", :bar => "bar in fedora"})
|
112
|
+
@test_object.stubs(:datastreams_in_memory).returns({:baz => "baz", :bar => "bar in memory"})
|
113
|
+
@test_object.inner_object.expects(:load_attributes_from_fedora)
|
114
|
+
result = @test_object.refresh
|
115
|
+
result.should == {:foo => "foo", :baz => "baz", :bar => "bar in memory"}
|
116
|
+
@test_object.instance_variable_get(:@datastreams).should == result
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), "../spec_helper" )
|
2
|
+
require 'active_fedora'
|
3
|
+
require 'active_fedora/base'
|
4
|
+
require 'active_fedora/metadata_datastream'
|
5
|
+
|
6
|
+
describe ActiveFedora::Base do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
Fedora::Repository.instance.expects(:nextid).returns("__nextid__")
|
10
|
+
@test_object = ActiveFedora::Base.new
|
11
|
+
#Fedora::Repository.instance.delete(@test_object.inner_object)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".metadata_streams" do
|
15
|
+
it "should return all of the datastreams from the object that are kinds of MetadataDatastreams " do
|
16
|
+
mock_mds1 = mock("metadata ds")
|
17
|
+
mock_mds1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
18
|
+
mock_mds2 = mock("metadata ds")
|
19
|
+
mock_mds2.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
20
|
+
mock_fds = mock("file ds")
|
21
|
+
mock_fds.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
22
|
+
@test_object.expects(:datastreams).returns({:foo => mock_mds1, :bar => mock_mds2, :baz => mock_fds})
|
23
|
+
|
24
|
+
result = @test_object.metadata_streams
|
25
|
+
result.length.should == 2
|
26
|
+
result.should include(mock_mds1)
|
27
|
+
result.should include(mock_mds2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".file_streams" do
|
32
|
+
it "should return all of the datastreams from the object that are kinds of MetadataDatastreams" do
|
33
|
+
mock_fds1 = mock("file ds", :dsid => "file1")
|
34
|
+
mock_fds1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
35
|
+
mock_fds2 = mock("file ds", :dsid => "file2")
|
36
|
+
mock_fds2.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
37
|
+
mock_mds = mock("metadata ds")
|
38
|
+
mock_mds.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
39
|
+
@test_object.expects(:datastreams).returns({:foo => mock_fds1, :bar=> mock_fds2, :baz => mock_mds})
|
40
|
+
|
41
|
+
result = @test_object.file_streams
|
42
|
+
result.length.should == 2
|
43
|
+
result.should include(mock_fds1)
|
44
|
+
result.should include(mock_fds2)
|
45
|
+
|
46
|
+
end
|
47
|
+
it "should skip DC and RELS-EXT datastreams" do
|
48
|
+
mock_fds1 = mock("file ds", :dsid => "foo")
|
49
|
+
mock_fds1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
50
|
+
dc = mock("DC", :dsid => "DC")
|
51
|
+
dc.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
52
|
+
rels_ext = mock("RELS-EXT", :dsid => "RELS-EXT")
|
53
|
+
rels_ext.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
54
|
+
@test_object.expects(:datastreams).returns({:foo => mock_fds1, :dc => dc, :rels_ext => rels_ext})
|
55
|
+
|
56
|
+
result = @test_object.file_streams
|
57
|
+
result.length.should == 1
|
58
|
+
result.should include(mock_fds1)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".update_index" do
|
63
|
+
it "should call .to_solr on all MetadataDatastreams AND RelsExtDatastreams and pass the resulting document to solr" do
|
64
|
+
ActiveFedora::SolrService.expects(:instance).returns(mock("SolrService", :conn => mock("SolrConnection", :update)))
|
65
|
+
# Actually uses self.to_solr internally to gather solr info from all metadata datastreams
|
66
|
+
mock1 = mock("ds1", :to_solr)
|
67
|
+
mock2 = mock("ds2", :to_solr)
|
68
|
+
mock3 = mock("RELS-EXT", :to_solr)
|
69
|
+
mock1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
70
|
+
mock2.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
71
|
+
mock3.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
72
|
+
mock3.expects(:kind_of?).with(ActiveFedora::RelsExtDatastream).returns(true)
|
73
|
+
|
74
|
+
@test_object.expects(:datastreams).returns({:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3})
|
75
|
+
@test_object.update_index
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should retrieve a solr Connection and call Connection.update" do
|
79
|
+
ActiveFedora::SolrService.expects(:instance).returns(mock("SolrService", :conn => mock("SolrConnection", :update)))
|
80
|
+
@test_object.update_index
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
describe ".delete" do
|
86
|
+
|
87
|
+
before(:each) do
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should delete object from repository and index" do
|
91
|
+
@test_object.expects(:pid).returns("foo")
|
92
|
+
ActiveFedora::SolrService.instance.conn.expects(:delete).with("foo")
|
93
|
+
Fedora::Repository.any_instance.stubs(:delete).with(@test_object.inner_object)
|
94
|
+
@test_object.delete
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#pids_from_uris' do
|
100
|
+
it "should strip the info:fedora/ out of a given string" do
|
101
|
+
ActiveFedora::Base.pids_from_uris("info:fedora/FOOBAR").should == "FOOBAR"
|
102
|
+
end
|
103
|
+
it "should accept an array of strings"do
|
104
|
+
ActiveFedora::Base.pids_from_uris(["info:fedora/FOOBAR", "info:fedora/BAZFOO"]).should == ["FOOBAR", "BAZFOO"]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
require "active_fedora"
|
3
|
+
|
4
|
+
# Some tentative extensions to ActiveFedora::Base
|
5
|
+
|
6
|
+
describe ActiveFedora::Base do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
Fedora::Repository.stubs(:instance).returns(stub_everything())
|
10
|
+
@base = ActiveFedora::Base.new
|
11
|
+
@base.stubs(:create_date).returns("2008-07-02T05:09:42.015Z")
|
12
|
+
@base.stubs(:modified_date).returns("2008-09-29T21:21:52.892Z")
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".file_objects" do
|
16
|
+
it "should be a supported method" do
|
17
|
+
@base.should respond_to("file_objects")
|
18
|
+
end
|
19
|
+
it "should wrap .collection_members" do
|
20
|
+
@base.expects(:collection_members)
|
21
|
+
@base.file_objects
|
22
|
+
end
|
23
|
+
describe "_append" do
|
24
|
+
it "should wrap collection_members_append" do
|
25
|
+
mocko = mock("object")
|
26
|
+
@base.expects(:collection_members_append).with(mocko)
|
27
|
+
@base.file_objects_append(mocko)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
describe "_remove" do
|
31
|
+
it "should wrap collection_members_remove"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".collection_members" do
|
36
|
+
it "should return an array" do
|
37
|
+
@base.collection_members.should be_kind_of(Array)
|
38
|
+
end
|
39
|
+
it "should search for all of the :collection_members"
|
40
|
+
describe "_append" do
|
41
|
+
it "should be a supported method" do
|
42
|
+
@base.should respond_to(:collection_members_append)
|
43
|
+
end
|
44
|
+
it "should assert hasCollectionMember for the given object/pid" do
|
45
|
+
mocko = mock("object")
|
46
|
+
@base.expects(:add_relationship).with(:has_collection_member, mocko)
|
47
|
+
@base.collection_members_append(mocko)
|
48
|
+
end
|
49
|
+
it "should support << operator" do
|
50
|
+
pending
|
51
|
+
# I can't remember how to do this, and it's not a deal breaker... (MZ)
|
52
|
+
mocko = mock("object")
|
53
|
+
@base.expects(:add_relationship).with(:has_collection_member, mocko)
|
54
|
+
@base.collection_members << mocko
|
55
|
+
end
|
56
|
+
end
|
57
|
+
describe "_remove" do
|
58
|
+
it "should be a supported method" do
|
59
|
+
@base.should respond_to(:collection_members_remove)
|
60
|
+
end
|
61
|
+
it "should remove hasCollectionMember for the given object/pid"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe ".add_file_datastream" do
|
66
|
+
it "should create a new datastream with the file as its content" do
|
67
|
+
mock_file = mock("File")
|
68
|
+
mock_ds = mock("Datastream")
|
69
|
+
ActiveFedora::Datastream.expects(:new).with(:dsLabel => "", :controlGroup => 'M', :blob=>mock_file).returns(mock_ds)
|
70
|
+
@base.expects(:add_datastream).with(mock_ds)
|
71
|
+
@base.add_file_datastream(mock_file)
|
72
|
+
end
|
73
|
+
it "should apply filename argument to the datastream label if it is provided" do
|
74
|
+
mock_file = mock("File")
|
75
|
+
mock_ds = mock("Datastream")
|
76
|
+
ActiveFedora::Datastream.expects(:new).with(:dsLabel => "My Label", :controlGroup => 'M', :blob=>mock_file).returns(mock_ds)
|
77
|
+
@base.expects(:add_datastream).with(mock_ds)
|
78
|
+
@base.add_file_datastream(mock_file, :label => "My Label")
|
79
|
+
end
|
80
|
+
it "should use :dsid if provided" do
|
81
|
+
mock_file = mock("File")
|
82
|
+
mock_ds = mock("Datastream")
|
83
|
+
mock_ds.expects(:dsid=).with("__DSID__")
|
84
|
+
ActiveFedora::Datastream.expects(:new).with(:dsLabel => "My Label", :controlGroup => 'M', :blob=>mock_file).returns(mock_ds)
|
85
|
+
@base.expects(:add_datastream).with(mock_ds)
|
86
|
+
@base.add_file_datastream(mock_file, :label => "My Label", :dsid => "__DSID__")
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join( File.dirname(__FILE__), "..", "spec_helper" )
|
2
|
+
require 'active_fedora'
|
3
|
+
require 'active_fedora/base'
|
4
|
+
require 'active_fedora/metadata_datastream'
|
5
|
+
require 'ruby-debug'
|
6
|
+
|
7
|
+
# Load Sample OralHistory Model
|
8
|
+
require File.join( File.dirname(__FILE__), "..","samples","oral_history_sample_model" )
|
9
|
+
|
10
|
+
|
11
|
+
describe ActiveFedora::Base do
|
12
|
+
|
13
|
+
# before(:all) do
|
14
|
+
# require File.join( File.dirname(__FILE__), "..","samples","oral_history" )
|
15
|
+
# end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
@test_object = OralHistorySampleModel.new
|
19
|
+
@test_object.save
|
20
|
+
end
|
21
|
+
|
22
|
+
after(:each) do
|
23
|
+
@test_object.delete
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "deserialize" do
|
27
|
+
it "should return an object whose inner_object is not marked as new. The datastreams should only be marked new if the model expects a datastream that doesn't exist yet in fedora" do
|
28
|
+
#mocko = mock("object")
|
29
|
+
#ActiveFedora::Base.expects(:new).returns(mocko)
|
30
|
+
@test_object.datastreams["sensitive_passages"].delete
|
31
|
+
doc = REXML::Document.new(@test_object.inner_object.object_xml, :ignore_whitespace_nodes=>:all)
|
32
|
+
result = OralHistorySampleModel.deserialize(doc)
|
33
|
+
result.new_object?.should be_false
|
34
|
+
result.datastreams_in_memory.should have_key("dublin_core")
|
35
|
+
result.datastreams_in_memory.should have_key("properties")
|
36
|
+
result.datastreams_in_memory.each do |name,ds|
|
37
|
+
ds.new_object?.should be_false unless name == "sensitive_passages"
|
38
|
+
end
|
39
|
+
result.datastreams_in_memory["sensitive_passages"].new_object?.should be_true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,584 @@
|
|
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 'time'
|
7
|
+
require 'date'
|
8
|
+
|
9
|
+
class FooHistory < ActiveFedora::Base
|
10
|
+
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"someData" do |m|
|
11
|
+
m.field "fubar", :string
|
12
|
+
m.field "swank", :text
|
13
|
+
end
|
14
|
+
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"withText" do |m|
|
15
|
+
m.field "fubar", :text
|
16
|
+
end
|
17
|
+
has_metadata :type=>ActiveFedora::MetadataDatastream, :name=>"withText2" do |m|
|
18
|
+
m.field "fubar", :text
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ActiveFedora::Base do
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
Fedora::Repository.instance.stubs(:nextid).returns("_nextid_")
|
26
|
+
@test_object = ActiveFedora::Base.new
|
27
|
+
@test_object.new_object = true
|
28
|
+
end
|
29
|
+
|
30
|
+
after(:each) do
|
31
|
+
begin
|
32
|
+
@test_object.delete
|
33
|
+
rescue
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#new' do
|
38
|
+
it "should create a new inner object" do
|
39
|
+
Fedora::Repository.instance.expects(:save).never
|
40
|
+
result = ActiveFedora::Base.new(:pid=>"test:1")
|
41
|
+
result.inner_object.should be_kind_of(Fedora::FedoraObject)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe ".internal_uri" do
|
47
|
+
it "should return pid as fedors uri" do
|
48
|
+
@test_object.internal_uri.should eql("info:fedora/#{@test_object.pid}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have to_param" do
|
53
|
+
@test_object.to_param.should == @test_object.pid
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should respond_to has_metadata" do
|
57
|
+
ActiveFedora::Base.respond_to?(:has_metadata).should be_true
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "has_metadata" do
|
61
|
+
|
62
|
+
it "should create specified datastreams with specified fields" do
|
63
|
+
n = FooHistory.new
|
64
|
+
n.datastreams["someData"].should_not be_nil
|
65
|
+
n.datastreams["someData"].fubar_values='bar'
|
66
|
+
n.datastreams["someData"].fubar_values.should == ['bar']
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe ".fields" do
|
72
|
+
it "should provide fields" do
|
73
|
+
@test_object.should respond_to(:fields)
|
74
|
+
end
|
75
|
+
it "should add pid, system_create_date and system_modified_date from object attributes" do
|
76
|
+
cdate = "2008-07-02T05:09:42.015Z"
|
77
|
+
mdate = "2009-07-07T23:37:18.991Z"
|
78
|
+
@test_object.expects(:create_date).returns(cdate)
|
79
|
+
@test_object.expects(:modified_date).returns(mdate)
|
80
|
+
fields = @test_object.fields
|
81
|
+
fields[:system_create_date][:values].should eql([cdate])
|
82
|
+
fields[:system_modified_date][:values].should eql([mdate])
|
83
|
+
fields[:id][:values].should eql([@test_object.pid])
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should add self.class as the :active_fedora_model" do
|
87
|
+
fields = @test_object.fields
|
88
|
+
fields[:active_fedora_model][:values].should eql([@test_object.class.inspect])
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should call .fields on all MetadataDatastreams and return the resulting document" do
|
92
|
+
mock1 = mock("ds1", :fields => {})
|
93
|
+
mock2 = mock("ds2", :fields => {})
|
94
|
+
mock1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
95
|
+
mock2.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
96
|
+
|
97
|
+
@test_object.expects(:datastreams).returns({:ds1 => mock1, :ds2 => mock2})
|
98
|
+
@test_object.fields
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should provide #find' do
|
103
|
+
ActiveFedora::Base.should respond_to(:find)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should provide .create_date" do
|
107
|
+
@test_object.should respond_to(:create_date)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should provide .modified_date" do
|
111
|
+
@test_object.should respond_to(:modified_date)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should respond to .rels_ext' do
|
115
|
+
@test_object.should respond_to(:rels_ext)
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '.rels_ext' do
|
119
|
+
it 'should create the RELS-EXT datastream if it doesnt exist' do
|
120
|
+
mocker = mock("rels-ext")
|
121
|
+
ActiveFedora::RelsExtDatastream.expects(:new).returns(mocker)
|
122
|
+
@test_object.expects(:add_datastream).with(mocker)
|
123
|
+
# Make sure the RELS-EXT datastream does not exist yet
|
124
|
+
@test_object.datastreams["RELS-EXT"].should == nil
|
125
|
+
@test_object.rels_ext
|
126
|
+
# Assume that @test_object.add_datastream actually does its job and adds the datastream to the datastreams array. Not testing that here.
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should return the RelsExtDatastream object from the datastreams array' do
|
130
|
+
@test_object.expects(:datastreams).returns({"RELS-EXT" => "foo"}).at_least_once
|
131
|
+
@test_object.rels_ext.should == "foo"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should provide #add_relationship' do
|
136
|
+
@test_object.should respond_to(:add_relationship)
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#add_relationship' do
|
140
|
+
it 'should call #add_relationship on the rels_ext datastream' do
|
141
|
+
mock_relationship = mock("relationship")
|
142
|
+
mock_rels_ext = mock("rels-ext", :add_relationship)
|
143
|
+
mock_rels_ext.expects(:dirty=).with(true)
|
144
|
+
@test_object.expects(:rels_ext).returns(mock_rels_ext).times(2)
|
145
|
+
@test_object.add_relationship("predicate", "object")
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should update the RELS-EXT datastream and set the datastream as dirty when relationships are added" do
|
149
|
+
mock_ds = mock("Rels-Ext")
|
150
|
+
mock_ds.expects(:add_relationship).times(2)
|
151
|
+
mock_ds.expects(:dirty=).with(true).times(2)
|
152
|
+
@test_object.datastreams["RELS-EXT"] = mock_ds
|
153
|
+
test_relationships = [ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "info:fedora/demo:5"),
|
154
|
+
ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "info:fedora/demo:10")]
|
155
|
+
test_relationships.each do |rel|
|
156
|
+
@test_object.add_relationship(rel.predicate, rel.object)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should provide #relationships' do
|
163
|
+
@test_object.should respond_to(:relationships)
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '#relationships' do
|
167
|
+
it 'should call #relationships on the rels_ext datastream and return that' do
|
168
|
+
@test_object.expects(:rels_ext).returns(mock("rels-ext", :relationships))
|
169
|
+
@test_object.relationships
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '.save' do
|
174
|
+
|
175
|
+
|
176
|
+
it "should return true if object and datastreams all save successfully" do
|
177
|
+
@test_object.expects(:create).returns(true)
|
178
|
+
@test_object.save.should == true
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should raise an exception if object fails to save" do
|
182
|
+
server_response = mock("Server Error")
|
183
|
+
Fedora::Repository.instance.expects(:save).with(@test_object.inner_object).raises(Fedora::ServerError, server_response)
|
184
|
+
lambda {@test_object.save}.should raise_error(Fedora::ServerError)
|
185
|
+
#lambda {@test_object.save}.should raise_error(Fedora::ServerError, "Error Saving object #{@test_object.pid}. Server Error: RubyFedora Error Msg")
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should raise an exception if any of the datastreams fail to save" do
|
189
|
+
Fedora::Repository.instance.expects(:save).with(@test_object.inner_object).returns(true)
|
190
|
+
Fedora::Repository.instance.expects(:save).with(kind_of(ActiveFedora::RelsExtDatastream)).raises(Fedora::ServerError, mock("Server Error"))
|
191
|
+
lambda {@test_object.save}.should raise_error(Fedora::ServerError)
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should call .save on any datastreams that are dirty" do
|
195
|
+
to = FooHistory.new
|
196
|
+
to.expects(:update_index)
|
197
|
+
Fedora::Repository.instance.expects(:save).with(to.inner_object)
|
198
|
+
Fedora::Repository.instance.expects(:save).with(kind_of(ActiveFedora::RelsExtDatastream))
|
199
|
+
Fedora::Repository.instance.expects(:save).with(to.datastreams["withText"])
|
200
|
+
Fedora::Repository.instance.expects(:save).with(to.datastreams["withText2"])
|
201
|
+
to.datastreams["someData"].stubs(:dirty?).returns(true)
|
202
|
+
to.datastreams["someData"].stubs(:new_object?).returns(true)
|
203
|
+
to.datastreams["someData"].expects(:save)
|
204
|
+
to.expects(:refresh)
|
205
|
+
to.save
|
206
|
+
end
|
207
|
+
it "should call .save on any datastreams that are new" do
|
208
|
+
ds = ActiveFedora::Datastream.new(:dsid => 'ds_to_add')
|
209
|
+
@test_object.add_datastream(ds)
|
210
|
+
ds.expects(:save)
|
211
|
+
@test_object.instance_variable_set(:@new_object, false)
|
212
|
+
Fedora::Repository.instance.expects(:save).with(@test_object.inner_object)
|
213
|
+
#Fedora::Repository.instance.expects(:save).with(kind_of(ActiveFedora::RelsExtDatastream))
|
214
|
+
@test_object.expects(:refresh)
|
215
|
+
@test_object.save
|
216
|
+
end
|
217
|
+
it "should not call .save on any datastreams that are not dirty" do
|
218
|
+
@test_object = FooHistory.new
|
219
|
+
@test_object.expects(:update_index)
|
220
|
+
@test_object.expects(:refresh)
|
221
|
+
@test_object.dc.should be_nil #heh, haven't saved it yet!
|
222
|
+
Fedora::Repository.instance.expects(:save).with(@test_object.inner_object)
|
223
|
+
Fedora::Repository.instance.expects(:save).with(kind_of(ActiveFedora::RelsExtDatastream))
|
224
|
+
Fedora::Repository.instance.expects(:save).with(@test_object.datastreams["withText"])
|
225
|
+
Fedora::Repository.instance.expects(:save).with(@test_object.datastreams["withText2"])
|
226
|
+
@test_object.datastreams["someData"].should_not be_nil
|
227
|
+
@test_object.datastreams['someData'].stubs(:dirty?).returns(false)
|
228
|
+
@test_object.datastreams['someData'].stubs(:new_object?).returns(false)
|
229
|
+
@test_object.datastreams['someData'].expects(:save).never
|
230
|
+
@test_object.save
|
231
|
+
end
|
232
|
+
it "should update solr index with all metadata if any MetadataDatastreams have changed" do
|
233
|
+
Fedora::Repository.instance.stubs(:save)
|
234
|
+
mock1 = mock("ds1", :dirty? => true, :save => true, :kind_of? => ActiveFedora::MetadataDatastream)
|
235
|
+
mock2 = mock("ds2", :dirty? => false, :new_object? => false)
|
236
|
+
@test_object.stubs(:datastreams_in_memory).returns({:ds1 => mock1, :ds2 => mock2})
|
237
|
+
@test_object.expects(:update_index)
|
238
|
+
@test_object.expects(:refresh)
|
239
|
+
@test_object.save
|
240
|
+
end
|
241
|
+
it "should NOT update solr index if no MetadataDatastreams have changed" do
|
242
|
+
Fedora::Repository.instance.stubs(:save)
|
243
|
+
mock1 = mock("ds1", :dirty? => false, :new_object? => false)
|
244
|
+
mock2 = mock("ds2", :dirty? => false, :new_object? => false)
|
245
|
+
@test_object.stubs(:datastreams_in_memory).returns({:ds1 => mock1, :ds2 => mock2})
|
246
|
+
@test_object.expects(:update_index).never
|
247
|
+
@test_object.expects(:refresh)
|
248
|
+
@test_object.instance_variable_set(:@new_object, false)
|
249
|
+
@test_object.save
|
250
|
+
end
|
251
|
+
it "should update solr index if RELS-EXT datastream has changed" do
|
252
|
+
Fedora::Repository.instance.stubs(:save)
|
253
|
+
mock1 = mock("RELS-EXT", :dirty? => true, :save => true)
|
254
|
+
mock1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(false)
|
255
|
+
mock1.expects(:instance_of?).with(ActiveFedora::RelsExtDatastream).returns(true)
|
256
|
+
mock2 = mock("ds2", :dirty? => false, :new_object? => false)
|
257
|
+
@test_object.stubs(:datastreams_in_memory).returns({"RELS-EXT" => mock1, :ds2 => mock2})
|
258
|
+
@test_object.instance_variable_set(:@new_object, false)
|
259
|
+
@test_object.expects(:refresh)
|
260
|
+
@test_object.expects(:update_index)
|
261
|
+
@test_object.save
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
|
266
|
+
describe ".to_xml" do
|
267
|
+
it "should provide .to_xml" do
|
268
|
+
@test_object.should respond_to(:to_xml)
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should add pid, system_create_date and system_modified_date from object attributes" do
|
272
|
+
@test_object.expects(:create_date).returns("cDate")
|
273
|
+
@test_object.expects(:modified_date).returns("mDate")
|
274
|
+
solr_doc = @test_object.to_solr
|
275
|
+
solr_doc[:system_create_dt].should eql("cDate")
|
276
|
+
solr_doc[:system_modified_dt].should eql("mDate")
|
277
|
+
solr_doc[:id].should eql(@test_object.pid)
|
278
|
+
end
|
279
|
+
|
280
|
+
it "should add self.class as the :active_fedora_model" do
|
281
|
+
solr_doc = @test_object.to_solr
|
282
|
+
solr_doc[:active_fedora_model_s].should eql(@test_object.class.inspect)
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should call .to_xml on all MetadataDatastreams and return the resulting document" do
|
286
|
+
mock1 = mock("ds1", :to_xml)
|
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)
|
290
|
+
|
291
|
+
@test_object.expects(:datastreams).returns({:ds1 => mock1, :ds2 => mock2})
|
292
|
+
@test_object.to_xml
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
describe ".to_solr" do
|
297
|
+
|
298
|
+
# before(:all) do
|
299
|
+
# # Revert to default mappings after running tests
|
300
|
+
# ActiveFedora::SolrService.load_mappings
|
301
|
+
# end
|
302
|
+
|
303
|
+
after(:all) do
|
304
|
+
# Revert to default mappings after running tests
|
305
|
+
ActiveFedora::SolrService.load_mappings
|
306
|
+
end
|
307
|
+
|
308
|
+
it "should provide .to_solr" do
|
309
|
+
@test_object.should respond_to(:to_solr)
|
310
|
+
end
|
311
|
+
|
312
|
+
it "should add pid, system_create_date and system_modified_date from object attributes" do
|
313
|
+
@test_object.expects(:create_date).returns("cDate")
|
314
|
+
@test_object.expects(:modified_date).returns("mDate")
|
315
|
+
solr_doc = @test_object.to_solr
|
316
|
+
puts solr_doc.inspect
|
317
|
+
solr_doc[:system_create_dt].should eql("cDate")
|
318
|
+
solr_doc[:system_modified_dt].should eql("mDate")
|
319
|
+
solr_doc[:id].should eql(@test_object.pid)
|
320
|
+
end
|
321
|
+
|
322
|
+
it "should add self.class as the :active_fedora_model" do
|
323
|
+
solr_doc = @test_object.to_solr
|
324
|
+
solr_doc[:active_fedora_model_s].should eql(@test_object.class.inspect)
|
325
|
+
end
|
326
|
+
|
327
|
+
it "should use mappings.yml to decide names of solr fields" do
|
328
|
+
cdate = "2008-07-02T05:09:42.015Z"
|
329
|
+
mdate = "2009-07-07T23:37:18.991Z"
|
330
|
+
@test_object.stubs(:create_date).returns(cdate)
|
331
|
+
@test_object.stubs(:modified_date).returns(mdate)
|
332
|
+
solr_doc = @test_object.to_solr
|
333
|
+
solr_doc[:system_create_dt].should eql(cdate)
|
334
|
+
solr_doc[:system_modified_dt].should eql(mdate)
|
335
|
+
solr_doc[:id].should eql(@test_object.pid)
|
336
|
+
solr_doc[:active_fedora_model_s].should eql(@test_object.class.inspect)
|
337
|
+
|
338
|
+
ActiveFedora::SolrService.load_mappings(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings_af_0.1.yml"))
|
339
|
+
solr_doc = @test_object.to_solr
|
340
|
+
[:system_create_dt, :system_modified_dt, :active_fedora_model_s].each do |fn|
|
341
|
+
solr_doc[fn].should == nil
|
342
|
+
end
|
343
|
+
solr_doc[:system_create_date].should eql(cdate)
|
344
|
+
solr_doc[:system_modified_date].should eql(mdate)
|
345
|
+
solr_doc[:id].should eql(@test_object.pid)
|
346
|
+
solr_doc[:active_fedora_model_field].should eql(@test_object.class.inspect)
|
347
|
+
end
|
348
|
+
|
349
|
+
it "should call .to_solr on all MetadataDatastreams and pass the resulting document to solr" do
|
350
|
+
mock1 = mock("ds1", :to_solr)
|
351
|
+
mock2 = mock("ds2", :to_solr)
|
352
|
+
mock1.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
353
|
+
mock2.expects(:kind_of?).with(ActiveFedora::MetadataDatastream).returns(true)
|
354
|
+
|
355
|
+
@test_object.expects(:datastreams).returns({:ds1 => mock1, :ds2 => mock2})
|
356
|
+
@test_object.to_solr
|
357
|
+
end
|
358
|
+
it "should call .to_solr on the RELS-EXT datastream if it is dirty" do
|
359
|
+
@test_object.add_relationship(:has_collection_member, "foo member")
|
360
|
+
rels_ext = @test_object.datastreams_in_memory["RELS-EXT"]
|
361
|
+
rels_ext.dirty?.should == true
|
362
|
+
rels_ext.expects(:to_solr)
|
363
|
+
@test_object.to_solr
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
describe ".update_index" do
|
368
|
+
it "should provide .update_index" do
|
369
|
+
@test_object.should respond_to(:update_index)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
describe ".label" do
|
374
|
+
it "should return the label of the inner object" do
|
375
|
+
@test_object.inner_object.expects(:label).returns("foo label")
|
376
|
+
@test_object.label.should == "foo label"
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
describe ".label=" do
|
381
|
+
it "should set the label of the inner object" do
|
382
|
+
@test_object.label.should_not == "foo label"
|
383
|
+
@test_object.label = "foo label"
|
384
|
+
@test_object.label.should == "foo label"
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
it "should get a pid but not save on init" do
|
389
|
+
Fedora::Repository.instance.expects(:save).never
|
390
|
+
Fedora::Repository.instance.expects(:nextid).returns('mooshoo:24')
|
391
|
+
f = FooHistory.new
|
392
|
+
f.pid.should_not be_nil
|
393
|
+
f.pid.should == 'mooshoo:24'
|
394
|
+
end
|
395
|
+
it "should not clobber a pid if i'm creating!" do
|
396
|
+
FooHistory.any_instance.expects(:configure_defined_datastreams)
|
397
|
+
f = FooHistory.new(:pid=>'numbnuts:1')
|
398
|
+
f.pid.should == 'numbnuts:1'
|
399
|
+
|
400
|
+
end
|
401
|
+
describe "update_attributes" do
|
402
|
+
it "should be able to handle ds's without fields field" do
|
403
|
+
class Moo < ActiveFedora::Base;end
|
404
|
+
m = Moo.new
|
405
|
+
ds = mock('ds')
|
406
|
+
m.expects(:datastreams).returns({ :ds1=>ds})
|
407
|
+
ds.expects(:fields).returns(Hash.new)
|
408
|
+
m.update_attributes(:foo=>'bar')
|
409
|
+
end
|
410
|
+
it "should be able to update attr on text fields" do
|
411
|
+
m = FooHistory.new
|
412
|
+
m.should_not be_nil
|
413
|
+
m.datastreams['someData'].swank_values.should == []
|
414
|
+
m.update_attributes(:swank=>'baz')
|
415
|
+
m.should_not be_nil
|
416
|
+
m.datastreams['someData'].swank_values.should == ['baz']
|
417
|
+
end
|
418
|
+
|
419
|
+
it "should have update_attributes" do
|
420
|
+
n = FooHistory.new
|
421
|
+
n.update_attributes(:fubar=>'baz')
|
422
|
+
n.datastreams["someData"].fubar_values.should == ['baz']
|
423
|
+
n.update_attributes('fubar'=>'bak')
|
424
|
+
n.datastreams["someData"].fubar_values.should == ['bak']
|
425
|
+
#really? should it hit all matching datastreams?
|
426
|
+
n.datastreams["withText"].fubar_values.should == ['bak']
|
427
|
+
end
|
428
|
+
|
429
|
+
it "should allow deleting of values" do
|
430
|
+
n = FooHistory.new
|
431
|
+
n.datastreams["someData"].fubar_values.should == []
|
432
|
+
n.update_attributes(:fubar=>'baz')
|
433
|
+
n.datastreams["someData"].fubar_values.should == ['baz']
|
434
|
+
n.update_attributes(:fubar=>:delete)
|
435
|
+
n.datastreams["someData"].fubar_values.should == []
|
436
|
+
n.update_attributes(:fubar=>'baz')
|
437
|
+
n.datastreams["someData"].fubar_values.should == ['baz']
|
438
|
+
n.update_attributes(:fubar=>"")
|
439
|
+
n.datastreams["someData"].fubar_values.should == []
|
440
|
+
end
|
441
|
+
|
442
|
+
it "should take a :datastreams argument" do
|
443
|
+
m = FooHistory.new
|
444
|
+
m.should_not be_nil
|
445
|
+
m.datastreams['someData'].fubar_values.should == []
|
446
|
+
m.datastreams['withText'].fubar_values.should == []
|
447
|
+
m.datastreams['withText2'].fubar_values.should == []
|
448
|
+
|
449
|
+
m.update_attributes({:fubar=>'baz'}, :datastreams=>"someData")
|
450
|
+
m.should_not be_nil
|
451
|
+
m.datastreams['someData'].fubar_values.should == ['baz']
|
452
|
+
m.datastreams["withText"].fubar_values.should == []
|
453
|
+
m.datastreams['withText2'].fubar_values.should == []
|
454
|
+
|
455
|
+
m.update_attributes({:fubar=>'baz'}, :datastreams=>["someData", "withText2"])
|
456
|
+
m.should_not be_nil
|
457
|
+
m.datastreams['someData'].fubar_values.should == ['baz']
|
458
|
+
m.datastreams["withText"].fubar_values.should == []
|
459
|
+
m.datastreams['withText2'].fubar_values.should == ['baz']
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
describe "update_indexed_attributes" do
|
464
|
+
it "should work for text fields" do
|
465
|
+
att= {"swank"=>{"-1"=>"mork", "1"=>"york"}}
|
466
|
+
n = FooHistory.new
|
467
|
+
result = n.update_indexed_attributes(att)
|
468
|
+
result.should == {"swank"=>{"1"=>"york", "0"=>"mork"}}
|
469
|
+
n.datastreams["someData"].swank_values.should == ['mork', 'york']
|
470
|
+
n.datastreams["someData"].swank_values.should == ['mork', 'york']
|
471
|
+
att= {"swank"=>{"-1"=>"dork"}}
|
472
|
+
result2 = n.update_indexed_attributes(att)
|
473
|
+
result2.should == {"swank"=>{"2"=>"dork"}}
|
474
|
+
n.datastreams["someData"].swank_values.should == ['mork', 'york', 'dork']
|
475
|
+
end
|
476
|
+
|
477
|
+
it "should return the new index of any added values" do
|
478
|
+
n = FooHistory.new
|
479
|
+
n.datastreams["someData"].swank_values = ["my_val1","my_val2"]
|
480
|
+
result = n.update_indexed_attributes "swank"=>{"-1"=>"mork"}
|
481
|
+
result.should == {"swank"=>{"2"=>"mork"}}
|
482
|
+
end
|
483
|
+
|
484
|
+
it "should return accurate response when multiple values have been added in a single run" do
|
485
|
+
pending
|
486
|
+
att= {"swank"=>{"-1"=>"mork", "0"=>"york"}}
|
487
|
+
n = FooHistory.new
|
488
|
+
n.update_indexed_attributes(att).should == {"swank"=>{"0"=>"york", "1"=>"mork"}}
|
489
|
+
end
|
490
|
+
|
491
|
+
it "should apply submitted hash to corresponding datastream values" do
|
492
|
+
att= {"fubar"=>{"-1"=>"mork", "0"=>"york"}}
|
493
|
+
n = FooHistory.new
|
494
|
+
n.update_indexed_attributes(att)
|
495
|
+
n.datastreams["someData"].fubar_values.should == ['mork', 'york']
|
496
|
+
n.datastreams["someData"].fubar_values.should == ['mork', 'york']
|
497
|
+
|
498
|
+
att= {"fubar"=>{"0"=>"zork", "1"=>"tork", "2"=>'mangle'}}
|
499
|
+
n.update_indexed_attributes(att)
|
500
|
+
n.datastreams["someData"].fubar_values.should == ['zork', 'tork', 'mangle']
|
501
|
+
|
502
|
+
att= {"fubar"=>{"0"=>"hork", "1"=>"tork", '-1'=>'dang'}}
|
503
|
+
result = n.update_indexed_attributes(att)
|
504
|
+
result.should == {"fubar"=>{"0"=>"hork", "1"=>"tork", '3'=>'dang'}}
|
505
|
+
n.datastreams["someData"].fubar_values.should == ['hork', 'tork', 'mangle', 'dang']
|
506
|
+
|
507
|
+
#really? should it hit all matching datastreams?
|
508
|
+
n.datastreams["withText"].fubar_values.should == ['hork', 'tork', 'mangle', 'dang']
|
509
|
+
end
|
510
|
+
|
511
|
+
it "should deal gracefully with adding new values at explicitly declared indexes" do
|
512
|
+
n = FooHistory.new
|
513
|
+
n.datastreams["someData"].fubar_values = ["all", "for", "the"]
|
514
|
+
att = {"fubar"=>{"3"=>'glory'}}
|
515
|
+
result = n.update_indexed_attributes(att)
|
516
|
+
result.should == {"fubar"=>{"3"=>"glory"}}
|
517
|
+
n.datastreams["someData"].fubar_values.should == ["all", "for", "the", "glory"]
|
518
|
+
|
519
|
+
n.datastreams["withText"].fubar_values.should == ["glory"]
|
520
|
+
end
|
521
|
+
|
522
|
+
it "should allow deleting of values and should delete values so that to_xml does not return emtpy nodes" do
|
523
|
+
att= {"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}
|
524
|
+
n = FooHistory.new
|
525
|
+
n.update_indexed_attributes(att)
|
526
|
+
n.datastreams["someData"].fubar_values.should == ['mork', 'york', 'mangle']
|
527
|
+
rexml = REXML::Document.new(n.datastreams["someData"].to_xml)
|
528
|
+
#puts rexml.root.elements.each {|el| el.to_s}
|
529
|
+
#puts rexml.root.elements.to_a.inspect
|
530
|
+
rexml.root.elements.to_a.length.should == 3
|
531
|
+
n.update_indexed_attributes({"fubar"=>{"1"=>""}})
|
532
|
+
n.datastreams["someData"].fubar_values.should == ['mork', 'mangle']
|
533
|
+
rexml = REXML::Document.new(n.datastreams["someData"].to_xml)
|
534
|
+
rexml.root.elements.to_a.length.should == 2
|
535
|
+
n.update_indexed_attributes({"fubar"=>{"0"=>:delete}})
|
536
|
+
n.datastreams["someData"].fubar_values.should == ['mangle']
|
537
|
+
rexml = REXML::Document.new(n.datastreams["someData"].to_xml)
|
538
|
+
rexml.root.elements.to_a.length.should == 1
|
539
|
+
|
540
|
+
n.datastreams["someData"].fubar_values = ["val1", nil, "val2"]
|
541
|
+
n.update_indexed_attributes({"fubar"=>{"1"=>""}})
|
542
|
+
n.datastreams["someData"].fubar_values.should == ["val1", "val2"]
|
543
|
+
end
|
544
|
+
|
545
|
+
|
546
|
+
it "should take a :datastreams argument" do
|
547
|
+
att= {"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}
|
548
|
+
m = FooHistory.new
|
549
|
+
|
550
|
+
m.update_indexed_attributes(att, :datastreams=>"withText")
|
551
|
+
m.should_not be_nil
|
552
|
+
m.datastreams['someData'].fubar_values.should == []
|
553
|
+
m.datastreams["withText"].fubar_values.should == ['mork', 'york', 'mangle']
|
554
|
+
m.datastreams['withText2'].fubar_values.should == []
|
555
|
+
|
556
|
+
att= {"fubar"=>{"-1"=>"tork", "0"=>"work", "1"=>"bork"}}
|
557
|
+
m.update_indexed_attributes(att, :datastreams=>["someData", "withText2"])
|
558
|
+
m.should_not be_nil
|
559
|
+
m.datastreams['someData'].fubar_values.should == ['tork', 'work', 'bork']
|
560
|
+
m.datastreams["withText"].fubar_values.should == ['mork', 'york', 'mangle']
|
561
|
+
m.datastreams['withText2'].fubar_values.should == ['tork', 'work', 'bork']
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
it "should expose solr for real." do
|
566
|
+
sinmock = mock('solr instance')
|
567
|
+
conmock = mock("solr conn")
|
568
|
+
sinmock.expects(:conn).returns(conmock)
|
569
|
+
conmock.expects(:query).with('pid: foobar', {}).returns({:baz=>:bif})
|
570
|
+
ActiveFedora::SolrService.expects(:instance).returns(sinmock)
|
571
|
+
FooHistory.solr_search("pid: foobar").should == {:baz=>:bif}
|
572
|
+
end
|
573
|
+
it "should expose solr for real. and pass args through" do
|
574
|
+
sinmock = mock('solr instance')
|
575
|
+
conmock = mock("solr conn")
|
576
|
+
sinmock.expects(:conn).returns(conmock)
|
577
|
+
conmock.expects(:query).with('pid: foobar', {:ding, :dang}).returns({:baz=>:bif})
|
578
|
+
ActiveFedora::SolrService.expects(:instance).returns(sinmock)
|
579
|
+
FooHistory.solr_search("pid: foobar", {:ding=>:dang}).should == {:baz=>:bif}
|
580
|
+
end
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
end
|