active-fedora 5.1.0 → 5.2.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/active-fedora.gemspec +1 -2
- data/lib/active_fedora/datastreams.rb +14 -14
- data/lib/active_fedora/file_management.rb +5 -3
- data/lib/active_fedora/metadata_datastream_helper.rb +5 -1
- data/lib/active_fedora/nokogiri_datastream.rb +17 -4
- data/lib/active_fedora/rdf_datastream.rb +59 -36
- data/lib/active_fedora/relationships.rb +28 -11
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +3 -3
- data/spec/integration/base_spec.rb +15 -3
- data/spec/integration/bug_spec.rb +0 -3
- data/spec/integration/datastream_collections_spec.rb +9 -9
- data/spec/integration/datastream_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +3 -4
- data/spec/integration/ntriples_datastream_spec.rb +0 -1
- data/spec/integration/rels_ext_datastream_spec.rb +12 -1
- data/spec/integration/semantic_node_spec.rb +10 -0
- data/spec/integration/solr_service_spec.rb +2 -2
- data/spec/spec_helper.rb +4 -7
- data/spec/support/mock_fedora.rb +10 -10
- data/spec/unit/active_fedora_spec.rb +8 -8
- data/spec/unit/association_proxy_spec.rb +2 -1
- data/spec/unit/base_cma_spec.rb +2 -2
- data/spec/unit/base_datastream_management_spec.rb +9 -9
- data/spec/unit/base_extra_spec.rb +25 -25
- data/spec/unit/base_file_management_spec.rb +32 -23
- data/spec/unit/base_spec.rb +94 -151
- data/spec/unit/callback_spec.rb +16 -11
- data/spec/unit/code_configurator_spec.rb +4 -4
- data/spec/unit/content_model_spec.rb +8 -8
- data/spec/unit/datastream_collections_spec.rb +23 -23
- data/spec/unit/datastream_spec.rb +7 -7
- data/spec/unit/datastreams_spec.rb +189 -304
- data/spec/unit/file_configurator_spec.rb +56 -56
- data/spec/unit/has_many_collection_spec.rb +1 -1
- data/spec/unit/model_spec.rb +51 -56
- data/spec/unit/nokogiri_datastream_spec.rb +24 -25
- data/spec/unit/ntriples_datastream_spec.rb +18 -27
- data/spec/unit/property_spec.rb +0 -2
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -2
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +1 -1
- data/spec/unit/relationship_graph_spec.rb +1 -1
- data/spec/unit/relationships_spec.rb +64 -52
- data/spec/unit/rels_ext_datastream_spec.rb +7 -7
- data/spec/unit/semantic_node_spec.rb +5 -5
- data/spec/unit/service_definitions_spec.rb +18 -16
- data/spec/unit/solr_config_options_spec.rb +6 -6
- data/spec/unit/solr_service_spec.rb +16 -16
- metadata +5 -21
data/spec/config_helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
def mock_yaml(hash, path)
|
2
2
|
mock_file = mock(path.split("/")[-1])
|
3
|
-
File.
|
4
|
-
File.
|
5
|
-
YAML.
|
3
|
+
File.stub(:exist?).with(path).and_return(true)
|
4
|
+
File.stub(:open).with(path).and_return(mock_file)
|
5
|
+
YAML.stub(:load).and_return(hash)
|
6
6
|
end
|
7
7
|
|
8
8
|
def default_predicate_mapping_file
|
@@ -108,7 +108,7 @@ describe "A base object with metadata" do
|
|
108
108
|
it 'should raise an error if not persisted' do
|
109
109
|
@object = MockAFBaseRelationship.new
|
110
110
|
# You will want this stub or else it will be really chatty in your STDERR
|
111
|
-
@object.inner_object.logger.
|
111
|
+
@object.inner_object.logger.stub(:error)
|
112
112
|
expect {
|
113
113
|
@object.reload
|
114
114
|
}.to raise_error(ActiveFedora::ObjectNotFoundError)
|
@@ -144,6 +144,18 @@ end
|
|
144
144
|
|
145
145
|
|
146
146
|
describe ActiveFedora::Base do
|
147
|
+
before(:all) do
|
148
|
+
@behavior = ActiveFedora::Relationships.deprecation_behavior
|
149
|
+
@c_behavior = ActiveFedora::Relationships::ClassMethods.deprecation_behavior
|
150
|
+
ActiveFedora::Relationships.deprecation_behavior = :silence
|
151
|
+
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = :silence
|
152
|
+
end
|
153
|
+
|
154
|
+
after :all do
|
155
|
+
ActiveFedora::Relationships.deprecation_behavior = @behavior
|
156
|
+
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = @c_behavior
|
157
|
+
end
|
158
|
+
|
147
159
|
before :all do
|
148
160
|
class MockAFBaseRelationship < ActiveFedora::Base
|
149
161
|
include ActiveFedora::FileManagement
|
@@ -280,7 +292,7 @@ describe ActiveFedora::Base do
|
|
280
292
|
it "should initialize the datastream pointers with @new_object=false" do
|
281
293
|
datastreams = @test_object.datastreams
|
282
294
|
datastreams.each_value do |ds|
|
283
|
-
ds.
|
295
|
+
ds.should_not be_new
|
284
296
|
end
|
285
297
|
end
|
286
298
|
end
|
@@ -427,7 +439,7 @@ describe ActiveFedora::Base do
|
|
427
439
|
@test_object3 = MockAFBaseRelationship.create
|
428
440
|
@test_object4 = MockAFBaseRelationship.create
|
429
441
|
@test_object5 = MockAFBaseRelationship.create
|
430
|
-
Deprecation.
|
442
|
+
Deprecation.stub(:warn)
|
431
443
|
#append to relationship by 'testing'
|
432
444
|
@test_object2.add_relationship_by_name("testing",@test_object3)
|
433
445
|
@test_object2.add_relationship_by_name("testing2",@test_object4)
|
@@ -17,8 +17,8 @@ describe ActiveFedora::DatastreamCollections do
|
|
17
17
|
@test_object2 = MockAFBaseDatastream.new
|
18
18
|
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
19
19
|
f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
|
20
|
-
f2.
|
21
|
-
f.
|
20
|
+
f2.stub(:original_filename).and_return("dino.jpg")
|
21
|
+
f.stub(:content_type).and_return("image/jpeg")
|
22
22
|
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
|
23
23
|
@test_object2.add_named_datastream("high",{:content_type=>"image/jpeg",:blob=>f2})
|
24
24
|
ds = @test_object2.thumbnail.first
|
@@ -50,7 +50,7 @@ describe ActiveFedora::DatastreamCollections do
|
|
50
50
|
@test_object2 = MockAFBaseDatastream.new
|
51
51
|
# @test_object2.new_object = true
|
52
52
|
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
53
|
-
f.
|
53
|
+
f.stub(:content_type).and_return("image/jpeg")
|
54
54
|
@test_object2.add_named_file_datastream("thumbnail",f)
|
55
55
|
ds = @test_object2.thumbnail.first
|
56
56
|
@test_object2.save
|
@@ -79,10 +79,10 @@ describe ActiveFedora::DatastreamCollections do
|
|
79
79
|
f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
|
80
80
|
dino = f2.read
|
81
81
|
f2.rewind
|
82
|
-
f.
|
83
|
-
f.
|
84
|
-
f2.
|
85
|
-
f2.
|
82
|
+
f.stub(:content_type).and_return("image/jpeg")
|
83
|
+
f.stub(:original_filename).and_return("minivan.jpg")
|
84
|
+
f2.stub(:content_type).and_return("image/jpeg")
|
85
|
+
f2.stub(:original_filename).and_return("dino.jpg")
|
86
86
|
#check raise exception if dsid not supplied
|
87
87
|
@test_object2.add_named_datastream("thumbnail",{:file=>f})
|
88
88
|
@test_object2.save
|
@@ -119,8 +119,8 @@ describe ActiveFedora::DatastreamCollections do
|
|
119
119
|
# @test_object2.new_object = true
|
120
120
|
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
121
121
|
f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
|
122
|
-
f2.
|
123
|
-
f.
|
122
|
+
f2.stub(:original_filename).and_return("dino.jpg")
|
123
|
+
f.stub(:content_type).and_return("image/jpeg")
|
124
124
|
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f, :label=>"testDS"})
|
125
125
|
@test_object2.add_named_datastream("thumbnail",{:content_type=>"image/jpeg",:blob=>f2})
|
126
126
|
@test_object2.save
|
@@ -34,7 +34,7 @@ describe ActiveFedora::Datastream do
|
|
34
34
|
title.namespace = xml_content.xpath('//oai_dc:dc/dc:identifier').first.namespace
|
35
35
|
xml_content.root.add_child title
|
36
36
|
|
37
|
-
@test_object.datastreams["DC"].
|
37
|
+
@test_object.datastreams["DC"].stub(:before_save)
|
38
38
|
@test_object.datastreams["DC"].content = xml_content.to_s
|
39
39
|
@test_object.datastreams["DC"].save
|
40
40
|
|
@@ -9,10 +9,9 @@ describe ActiveFedora::Base do
|
|
9
9
|
class OralHistory < ActiveFedora::Base
|
10
10
|
include ActiveFedora::Relationships
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
Deprecation.silence(ActiveFedora::Relationships::ClassMethods) do
|
13
|
+
has_relationship "parts", :is_part_of, :inbound => true
|
14
|
+
end
|
16
15
|
# These are all the properties that don't quite fit into Qualified DC
|
17
16
|
# Put them on the object itself (in the properties datastream) for now.
|
18
17
|
has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
|
@@ -43,7 +43,6 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
43
43
|
@subject.related_url = "http://en.wikipedia.org/wiki/War_and_Peace"
|
44
44
|
@subject.part = "this is a part"
|
45
45
|
@subject.save
|
46
|
-
|
47
46
|
loaded = RdfTest.find(@subject.pid)
|
48
47
|
loaded.title.should == 'War and Peace'
|
49
48
|
loaded.based_near.should == ['Moscow, Russia']
|
@@ -77,7 +77,18 @@ describe ActiveFedora::RelsExtDatastream do
|
|
77
77
|
new_rels.should == @test_object.relationships
|
78
78
|
end
|
79
79
|
|
80
|
-
describe '#from_solr' do
|
80
|
+
describe '#from_solr' do
|
81
|
+
before(:all) do
|
82
|
+
@behavior = ActiveFedora::Relationships.deprecation_behavior
|
83
|
+
@c_behavior = ActiveFedora::Relationships::ClassMethods.deprecation_behavior
|
84
|
+
ActiveFedora::Relationships.deprecation_behavior = :silence
|
85
|
+
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = :silence
|
86
|
+
end
|
87
|
+
|
88
|
+
after :all do
|
89
|
+
ActiveFedora::Relationships.deprecation_behavior = @behavior
|
90
|
+
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = @c_behavior
|
91
|
+
end
|
81
92
|
before do
|
82
93
|
class MockAFRelsSolr < ActiveFedora::Base
|
83
94
|
include ActiveFedora::FileManagement
|
@@ -3,7 +3,17 @@ require 'spec_helper'
|
|
3
3
|
require 'active_fedora'
|
4
4
|
|
5
5
|
describe ActiveFedora::SemanticNode do
|
6
|
+
before(:all) do
|
7
|
+
@behavior = ActiveFedora::Relationships.deprecation_behavior
|
8
|
+
@c_behavior = ActiveFedora::Relationships::ClassMethods.deprecation_behavior
|
9
|
+
ActiveFedora::Relationships.deprecation_behavior = :silence
|
10
|
+
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = :silence
|
11
|
+
end
|
6
12
|
|
13
|
+
after :all do
|
14
|
+
ActiveFedora::Relationships.deprecation_behavior = @behavior
|
15
|
+
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = @c_behavior
|
16
|
+
end
|
7
17
|
before(:all) do
|
8
18
|
class SNSpecNode < ActiveFedora::Base
|
9
19
|
include ActiveFedora::FileManagement
|
@@ -108,8 +108,8 @@ describe ActiveFedora::SolrService do
|
|
108
108
|
it 'should call load_instance_from_solr if :load_from_solr option passed in' do
|
109
109
|
query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
|
110
110
|
solr_result = ActiveFedora::SolrService.query(query)
|
111
|
-
ActiveFedora::Base.
|
112
|
-
FooObject.
|
111
|
+
ActiveFedora::Base.should_receive(:load_instance_from_solr).once
|
112
|
+
FooObject.should_receive(:load_instance_from_solr).once
|
113
113
|
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
114
114
|
end
|
115
115
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
ENV["environment"] ||= 'test'
|
2
2
|
require "bundler/setup"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
require 'simplecov-rcov'
|
4
|
+
require 'simplecov'
|
5
|
+
require 'simplecov-rcov'
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
8
|
+
SimpleCov.start
|
11
9
|
|
12
10
|
require 'active-fedora'
|
13
11
|
require 'rspec'
|
@@ -31,7 +29,6 @@ restore_spec_configuration
|
|
31
29
|
ActiveSupport::Deprecation.behavior= Proc.new { |message, callstack| }
|
32
30
|
|
33
31
|
RSpec.configure do |config|
|
34
|
-
config.mock_with :mocha
|
35
32
|
config.color_enabled = true
|
36
33
|
end
|
37
34
|
|
data/spec/support/mock_fedora.rb
CHANGED
@@ -2,44 +2,44 @@ def mock_client
|
|
2
2
|
return @mock_client if @mock_client
|
3
3
|
@mock_client = mock("client")
|
4
4
|
@getter = mock("getter")
|
5
|
-
@getter.
|
6
|
-
@mock_client.
|
5
|
+
@getter.stub(:get).and_return('')
|
6
|
+
@mock_client.stub(:[]).with("describe?xml=true").and_return('')
|
7
7
|
@mock_client
|
8
8
|
end
|
9
9
|
|
10
10
|
def stub_get(pid, datastreams=nil, record_exists=false)
|
11
11
|
pid.gsub!(/:/, '%3A')
|
12
12
|
if record_exists
|
13
|
-
mock_client.
|
13
|
+
mock_client.stub(:[]).with("objects/#{pid}?format=xml").and_return(stub('get getter', :get=>'foobar'))
|
14
14
|
else
|
15
|
-
mock_client.
|
15
|
+
mock_client.stub(:[]).with("objects/#{pid}?format=xml").and_raise(RestClient::ResourceNotFound)
|
16
16
|
end
|
17
|
-
mock_client.
|
17
|
+
mock_client.stub(:[]).with("objects/#{pid}/datastreams?format=xml").and_return(@getter)
|
18
18
|
datastreams ||= ['someData', 'withText', 'withText2', 'RELS-EXT']
|
19
19
|
datastreams.each do |dsid|
|
20
|
-
mock_client.
|
20
|
+
mock_client.stub(:[]).with("objects/#{pid}/datastreams/#{dsid}?format=xml").and_return(@getter)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def stub_ingest(pid=nil)
|
25
25
|
n = pid ? pid.gsub(/:/, '%3A') : nil
|
26
|
-
mock_client.
|
26
|
+
mock_client.should_receive(:[]).with("objects/#{n || 'new'}").and_return(stub("ingester", :post=>pid))
|
27
27
|
end
|
28
28
|
|
29
29
|
def stub_add_ds(pid, dsids)
|
30
30
|
pid.gsub!(/:/, '%3A')
|
31
31
|
dsids.each do |dsid|
|
32
|
-
client = mock_client.
|
32
|
+
client = mock_client.stub(:[]).with do |params|
|
33
33
|
/objects\/#{pid}\/datastreams\/#{dsid}/.match(params)
|
34
34
|
end
|
35
|
-
client.
|
35
|
+
client.and_return(stub("ds_adder", :post=>pid, :get=>''))
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def stub_get_content(pid, dsids)
|
40
40
|
pid.gsub!(/:/, '%3A')
|
41
41
|
dsids.each do |dsid|
|
42
|
-
mock_client.
|
42
|
+
mock_client.stub(:[]).with { |params| /objects\/#{pid}\/datastreams\/#{dsid}\/content/.match(params)}.and_return(stub("content_accessor", :post=>pid, :get=>''))
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -14,20 +14,20 @@ describe ActiveFedora do
|
|
14
14
|
describe "initialization methods" do
|
15
15
|
describe "environment" do
|
16
16
|
it "should use config_options[:environment] if set" do
|
17
|
-
ActiveFedora.
|
17
|
+
ActiveFedora.stub(:config_options => {:environment=>"ballyhoo"})
|
18
18
|
ActiveFedora.environment.should eql("ballyhoo")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should use Rails.env if no config_options and Rails.env is set" do
|
22
22
|
stub_rails(:env => "bedbugs")
|
23
|
-
ActiveFedora.
|
23
|
+
ActiveFedora.stub(:config_options => {})
|
24
24
|
ActiveFedora.environment.should eql("bedbugs")
|
25
25
|
unstub_rails
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should use ENV['environment'] if neither config_options nor Rails.env are set" do
|
29
29
|
ENV['environment'] = "wichita"
|
30
|
-
ActiveFedora.
|
30
|
+
ActiveFedora.stub(:config_options => {})
|
31
31
|
ActiveFedora.environment.should eql("wichita")
|
32
32
|
ENV['environment']='test'
|
33
33
|
end
|
@@ -42,7 +42,7 @@ describe ActiveFedora do
|
|
42
42
|
it "should be development if none of the above are present" do
|
43
43
|
ENV['environment']=nil
|
44
44
|
ENV['RAILS_ENV'] = nil
|
45
|
-
ActiveFedora.
|
45
|
+
ActiveFedora.stub(:config_options => {})
|
46
46
|
ActiveFedora.environment.should == 'development'
|
47
47
|
ENV['environment']="test"
|
48
48
|
end
|
@@ -79,12 +79,12 @@ describe ActiveFedora do
|
|
79
79
|
solr_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/solr.yml"))
|
80
80
|
pred_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/predicate_mappings.yml"))
|
81
81
|
|
82
|
-
File.
|
83
|
-
File.
|
84
|
-
ActiveFedora::SolrService.
|
82
|
+
File.stub(:open).with(fedora_config_path).and_return(fedora_config)
|
83
|
+
File.stub(:open).with(solr_config_path).and_return(solr_config)
|
84
|
+
ActiveFedora::SolrService.stub(:load_mappings) #For the solrizer solr_mappings.yml
|
85
85
|
|
86
86
|
|
87
|
-
# ActiveSupport::Deprecation.
|
87
|
+
# ActiveSupport::Deprecation.should_receive(:warn).with("Configuring fedora with \":url\" without :user and :password is no longer supported.")
|
88
88
|
ActiveFedora.init(:fedora_config_path=>fedora_config_path,:solr_config_path=>solr_config_path)
|
89
89
|
ActiveFedora.solr.class.should == ActiveFedora::SolrService
|
90
90
|
end
|
@@ -2,9 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Associations::AssociationProxy do
|
4
4
|
it "should delegate to_param" do
|
5
|
+
pending
|
5
6
|
@owner = stub(:new_record? => false)
|
6
7
|
@assoc = ActiveFedora::Associations::AssociationProxy.new(@owner, @reflection)
|
7
|
-
@assoc.
|
8
|
+
@assoc.should_receive(:find_target).and_return(stub(:to_param => '1234'))
|
8
9
|
@assoc.send(:load_target)
|
9
10
|
@assoc.to_param.should == '1234'
|
10
11
|
|
data/spec/unit/base_cma_spec.rb
CHANGED
@@ -9,8 +9,8 @@ describe ActiveFedora::Base do
|
|
9
9
|
describe '.save' do
|
10
10
|
|
11
11
|
it "should add hasModel relationship that points to the CModel if @new_object" do
|
12
|
-
@test_object.
|
13
|
-
@test_object.
|
12
|
+
@test_object.stub(:update_index)
|
13
|
+
@test_object.should_receive(:refresh)
|
14
14
|
@test_object.save
|
15
15
|
end
|
16
16
|
end
|
@@ -9,7 +9,7 @@ describe ActiveFedora::Base do
|
|
9
9
|
describe '.generate_dsid' do
|
10
10
|
it "should return a dsid that is not currently in use" do
|
11
11
|
dsids = Hash["DS1"=>1, "DS2"=>1]
|
12
|
-
@test_object.
|
12
|
+
@test_object.should_receive(:datastreams).and_return(dsids)
|
13
13
|
generated_id = @test_object.generate_dsid
|
14
14
|
generated_id.should_not be_nil
|
15
15
|
generated_id.should == "DS3"
|
@@ -20,7 +20,7 @@ describe ActiveFedora::Base do
|
|
20
20
|
|
21
21
|
it "if delete a datastream it should still use next index for a prefix" do
|
22
22
|
dsids = Hash["DS2"=>1]
|
23
|
-
@test_object.
|
23
|
+
@test_object.should_receive(:datastreams).and_return(dsids)
|
24
24
|
generated_id = @test_object.generate_dsid
|
25
25
|
generated_id.should_not be_nil
|
26
26
|
generated_id.should == "DS3"
|
@@ -29,7 +29,7 @@ describe ActiveFedora::Base do
|
|
29
29
|
describe '.add_datastream' do
|
30
30
|
it "should not call Datastream.save" do
|
31
31
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
|
32
|
-
ds.
|
32
|
+
ds.should_receive(:save).never
|
33
33
|
@test_object.add_datastream(ds)
|
34
34
|
end
|
35
35
|
it "should add the datastream to the datastreams_in_memory array" do
|
@@ -42,16 +42,16 @@ describe ActiveFedora::Base do
|
|
42
42
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil)
|
43
43
|
ds.dsid.should == nil
|
44
44
|
ds_emptystringid = ActiveFedora::Datastream.new(@test_object.inner_object, '')
|
45
|
-
@test_object.
|
46
|
-
# ds.
|
47
|
-
@test_object.add_datastream(ds)
|
48
|
-
@test_object.add_datastream(ds_emptystringid)
|
45
|
+
@test_object.stub(:generate_dsid => 'foo')
|
46
|
+
# ds.should_receive(:dsid=).with("foo")
|
47
|
+
@test_object.add_datastream(ds).should == 'foo'
|
48
|
+
@test_object.add_datastream(ds_emptystringid).should == 'foo'
|
49
49
|
end
|
50
50
|
it "should accept a prefix option and apply it to automatically assigned dsids" do
|
51
51
|
ds = ActiveFedora::Datastream.new(@test_object.inner_object, nil)
|
52
52
|
ds.dsid.should == nil
|
53
|
-
@test_object.
|
54
|
-
@test_object.add_datastream(ds, :prefix => "FOO")
|
53
|
+
@test_object.stub(:generate_dsid => "FOO")
|
54
|
+
@test_object.add_datastream(ds, :prefix => "FOO").should == 'FOO'
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -9,40 +9,40 @@ describe ActiveFedora::Base do
|
|
9
9
|
describe ".update_index" do
|
10
10
|
before do
|
11
11
|
mock_conn = mock("SolrConnection")
|
12
|
-
mock_conn.
|
13
|
-
mock_conn.
|
12
|
+
mock_conn.should_receive(:add)
|
13
|
+
mock_conn.should_receive(:commit)
|
14
14
|
mock_ss = mock("SolrService")
|
15
|
-
mock_ss.
|
16
|
-
ActiveFedora::SolrService.
|
15
|
+
mock_ss.stub(:conn).and_return(mock_conn)
|
16
|
+
ActiveFedora::SolrService.stub(:instance).and_return(mock_ss)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should call .to_solr on all SimpleDatastreams AND RelsExtDatastreams and pass the resulting document to solr" do
|
20
20
|
# Actually uses self.to_solr internally to gather solr info from all metadata datastreams
|
21
|
-
mock1 = mock("ds1", :to_solr)
|
22
|
-
mock2 = mock("ds2", :to_solr)
|
23
|
-
mock3 = mock("RELS-EXT", :to_solr)
|
21
|
+
mock1 = mock("ds1", :to_solr => {})
|
22
|
+
mock2 = mock("ds2", :to_solr => {})
|
23
|
+
mock3 = mock("RELS-EXT", :to_solr => {})
|
24
24
|
|
25
25
|
mock_datastreams = {:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3}
|
26
|
-
mock1.
|
27
|
-
mock2.
|
28
|
-
mock3.
|
29
|
-
@test_object.
|
30
|
-
@test_object.
|
26
|
+
mock1.should_receive(:solrize_profile).and_return({})
|
27
|
+
mock2.should_receive(:solrize_profile).and_return({})
|
28
|
+
mock3.should_receive(:solrize_profile).and_return({})
|
29
|
+
@test_object.should_receive(:datastreams).twice.and_return(mock_datastreams)
|
30
|
+
@test_object.should_receive(:solrize_relationships)
|
31
31
|
@test_object.update_index
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should call .to_solr on all RDFDatastreams and pass the resulting document to solr" do
|
35
35
|
# Actually uses self.to_solr internally to gather solr info from all metadata datastreams
|
36
|
-
mock1 = mock("ds1", :to_solr)
|
37
|
-
mock2 = mock("ds2", :to_solr)
|
38
|
-
mock3 = mock("RELS-EXT", :to_solr)
|
36
|
+
mock1 = mock("ds1", :to_solr => {})
|
37
|
+
mock2 = mock("ds2", :to_solr => {})
|
38
|
+
mock3 = mock("RELS-EXT", :to_solr => {})
|
39
39
|
|
40
40
|
mock_datastreams = {:ds1 => mock1, :ds2 => mock2, :rels_ext => mock3}
|
41
|
-
mock1.
|
42
|
-
mock2.
|
43
|
-
mock3.
|
44
|
-
@test_object.
|
45
|
-
@test_object.
|
41
|
+
mock1.should_receive(:solrize_profile).and_return({})
|
42
|
+
mock2.should_receive(:solrize_profile).and_return({})
|
43
|
+
mock3.should_receive(:solrize_profile).and_return({})
|
44
|
+
@test_object.should_receive(:datastreams).twice.and_return(mock_datastreams)
|
45
|
+
@test_object.should_receive(:solrize_relationships)
|
46
46
|
@test_object.update_index
|
47
47
|
end
|
48
48
|
|
@@ -58,13 +58,13 @@ describe ActiveFedora::Base do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should delete object from repository and index" do
|
61
|
-
@test_object.inner_object.
|
61
|
+
@test_object.inner_object.stub(:delete)
|
62
62
|
mock_conn = mock("SolrConnection")
|
63
|
-
mock_conn.
|
64
|
-
mock_conn.
|
63
|
+
mock_conn.should_receive(:delete_by_id).with("__DO_NOT_USE__")
|
64
|
+
mock_conn.should_receive(:commit)
|
65
65
|
mock_ss = mock("SolrService")
|
66
|
-
mock_ss.
|
67
|
-
ActiveFedora::SolrService.
|
66
|
+
mock_ss.stub(:conn).and_return(mock_conn)
|
67
|
+
ActiveFedora::SolrService.stub(:instance).and_return(mock_ss)
|
68
68
|
@test_object.delete
|
69
69
|
end
|
70
70
|
|