active-fedora 3.0.7 → 3.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/.rvmrc +1 -1
  2. data/Gemfile.lock +39 -10
  3. data/History.txt +0 -4
  4. data/active-fedora.gemspec +4 -3
  5. data/lib/active_fedora.rb +9 -9
  6. data/lib/active_fedora/base.rb +92 -163
  7. data/lib/active_fedora/datastream.rb +59 -60
  8. data/lib/active_fedora/datastream_hash.rb +18 -0
  9. data/lib/active_fedora/metadata_datastream.rb +3 -2
  10. data/lib/active_fedora/metadata_datastream_helper.rb +3 -15
  11. data/lib/active_fedora/model.rb +3 -3
  12. data/lib/active_fedora/nokogiri_datastream.rb +305 -302
  13. data/lib/active_fedora/qualified_dublin_core_datastream.rb +24 -19
  14. data/lib/active_fedora/rels_ext_datastream.rb +39 -37
  15. data/lib/active_fedora/rubydora_connection.rb +40 -0
  16. data/lib/active_fedora/semantic_node.rb +1 -1
  17. data/lib/active_fedora/solr_service.rb +1 -1
  18. data/lib/active_fedora/version.rb +1 -1
  19. data/lib/ruby-fedora.rb +0 -8
  20. data/lib/tasks/active_fedora.rake +14 -9
  21. data/lib/tasks/active_fedora_dev.rake +23 -40
  22. data/spec/integration/base_loader_spec.rb +4 -21
  23. data/spec/integration/base_spec.rb +300 -310
  24. data/spec/integration/bug_spec.rb +9 -10
  25. data/spec/integration/datastream_spec.rb +12 -12
  26. data/spec/integration/metadata_datastream_helper_spec.rb +7 -10
  27. data/spec/integration/model_spec.rb +3 -2
  28. data/spec/integration/rels_ext_datastream_spec.rb +9 -15
  29. data/spec/spec_helper.rb +2 -29
  30. data/spec/unit/active_fedora_spec.rb +5 -5
  31. data/spec/unit/base_cma_spec.rb +0 -7
  32. data/spec/unit/base_datastream_management_spec.rb +8 -67
  33. data/spec/unit/base_delegate_spec.rb +26 -9
  34. data/spec/unit/base_extra_spec.rb +5 -3
  35. data/spec/unit/base_file_management_spec.rb +10 -17
  36. data/spec/unit/base_named_datastream_spec.rb +76 -199
  37. data/spec/unit/base_spec.rb +152 -69
  38. data/spec/unit/content_model_spec.rb +1 -1
  39. data/spec/unit/datastream_concurrency_spec.rb +5 -4
  40. data/spec/unit/datastream_spec.rb +28 -48
  41. data/spec/unit/has_many_collection_spec.rb +2 -0
  42. data/spec/unit/inheritance_spec.rb +6 -6
  43. data/spec/unit/metadata_datastream_spec.rb +12 -28
  44. data/spec/unit/model_spec.rb +10 -10
  45. data/spec/unit/nokogiri_datastream_spec.rb +31 -33
  46. data/spec/unit/qualified_dublin_core_datastream_spec.rb +15 -15
  47. data/spec/unit/rels_ext_datastream_spec.rb +35 -29
  48. data/spec/unit/rubydora_connection_spec.rb +26 -0
  49. data/spec/unit/semantic_node_spec.rb +12 -17
  50. data/spec/unit/solr_config_options_spec.rb +13 -14
  51. data/spec/unit/solr_service_spec.rb +14 -17
  52. metadata +59 -55
  53. data/lib/fedora/base.rb +0 -38
  54. data/lib/fedora/connection.rb +0 -218
  55. data/lib/fedora/datastream.rb +0 -67
  56. data/lib/fedora/fedora_object.rb +0 -161
  57. data/lib/fedora/formats.rb +0 -30
  58. data/lib/fedora/generic_search.rb +0 -71
  59. data/lib/fedora/repository.rb +0 -298
  60. data/spec/integration/datastreams_crud_spec.rb +0 -208
  61. data/spec/integration/fedora_object_spec.rb +0 -77
  62. data/spec/integration/repository_spec.rb +0 -301
  63. data/spec/integration/rf_fedora_object_spec.rb +0 -95
  64. data/spec/unit/connection_spec.rb +0 -25
  65. data/spec/unit/fedora_object_spec.rb +0 -74
  66. data/spec/unit/repository_spec.rb +0 -143
  67. data/spec/unit/rf_datastream_spec.rb +0 -63
@@ -14,14 +14,12 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
14
14
  end
15
15
 
16
16
  before(:each) do
17
- Fedora::Repository.instance.stubs(:nextid).returns("_nextid_")
18
- @test_ds = ActiveFedora::QualifiedDublinCoreDatastream.new
17
+ ActiveFedora::RubydoraConnection.instance.stubs(:nextid).returns("_nextid_")
18
+ @test_ds = ActiveFedora::QualifiedDublinCoreDatastream.new(nil, nil)
19
19
  end
20
20
  it "from_xml should parse everything correctly" do
21
21
  #originally just tested that lcsh encoding and stuff worked, but the other stuff is worth testing
22
- mockr= mock('repo')
23
- mockr.expects(:nextid).returns("meh:leh")
24
- Fedora::Repository.stubs(:instance).returns(mockr)
22
+ ActiveFedora::RubydoraConnection.instance.expects(:nextid).returns("meh:leh")
25
23
  tmpl = OralHistorySampleModel.new.datastreams['dublin_core']
26
24
 
27
25
  tmpl.expects(:subject_append).with('sh1')
@@ -46,9 +44,9 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
46
44
  tmpl.expects(:description_append).with('desc')
47
45
 
48
46
  sample_xml = fixture('oh_qdc.xml')
49
- sample_ds_xml = Nokogiri::XML::Document.parse(sample_xml).xpath('//foxml:datastream').first
47
+ sample_ds_xml = Nokogiri::XML::Document.parse(sample_xml).xpath('//foxml:datastream/foxml:datastreamVersion/foxml:xmlContent/dc').first
50
48
 
51
- z = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(tmpl, sample_ds_xml)
49
+ z = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(sample_ds_xml.to_s, tmpl)
52
50
  z.should === tmpl
53
51
  end
54
52
 
@@ -64,8 +62,9 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
64
62
  it "should have identity in and out" do
65
63
  sample = fixture('oh_qdc.xml')
66
64
  tmpl = OralHistorySampleModel.new.datastreams['dublin_core']
67
- z = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(tmpl, Nokogiri::XML::Document.parse(sample).root.children.first)
68
- y = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(tmpl, Nokogiri::XML::Document.parse(z.to_dc_xml))
65
+ x1 = Nokogiri::XML::Document.parse(sample).xpath('/wrapper/foxml:datastream/foxml:datastreamVersion/foxml:xmlContent/dc').first.to_xml
66
+ z = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(x1, tmpl)
67
+ y = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(z.to_dc_xml, tmpl)
69
68
  y.to_dc_xml.should == z.to_dc_xml
70
69
  end
71
70
 
@@ -81,8 +80,8 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
81
80
 
82
81
  it "should parse dcterms and dcelements from xml" do
83
82
  doc = Nokogiri::XML::Document.parse(File.open( File.dirname(__FILE__)+'/../fixtures/changeme155.xml') )
84
- stream = doc.xpath('//foxml:datastream[@ID=\'dublin_core\']')
85
- n = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(ActiveFedora::QualifiedDublinCoreDatastream.new, stream)
83
+ stream = doc.xpath('//foxml:datastream[@ID=\'dublin_core\']/foxml:datastreamVersion/foxml:xmlContent/dc')
84
+ n = ActiveFedora::QualifiedDublinCoreDatastream.from_xml(stream.to_xml, ActiveFedora::QualifiedDublinCoreDatastream.new(nil, nil))
86
85
  n.spatial_values.should == ["Boston [7013445]", "Dorchester [7013575]", "Roxbury [7015002]"]
87
86
  n.title_values.should == ["Oral history with Frances Addelson, 1997 November 14"]
88
87
  n.dirty?.should == false
@@ -122,10 +121,11 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
122
121
 
123
122
  end
124
123
 
125
- describe '.set_blob_for_save' do
126
- it "should call .blob= with to_dc_xml" do
127
- @test_ds.expects(:blob=).with(@test_ds.to_dc_xml)
128
- @test_ds.set_blob_for_save
124
+ describe 'serialize!' do
125
+ it "should call .content= with to_dc_xml" do
126
+ result = @test_ds.to_dc_xml
127
+ @test_ds.expects(:content=).with(result)
128
+ @test_ds.serialize!
129
129
  end
130
130
  end
131
131
 
@@ -18,39 +18,24 @@ describe ActiveFedora::RelsExtDatastream do
18
18
  end
19
19
 
20
20
  before(:each) do
21
- @test_ds = ActiveFedora::RelsExtDatastream.new(:pid => @pid)
22
- end
23
-
24
- it "should respond to #new" do
25
- ActiveFedora::RelsExtDatastream.should respond_to(:new)
26
- end
27
-
28
- describe "#new" do
29
- it "should create a datastream with DSID of RELS-EXT" do
30
- test_datastream = ActiveFedora::RelsExtDatastream.new
31
- test_datastream.dsid.should eql("RELS-EXT")
32
- end
21
+ mock_inner = mock('inner object')
22
+ @mock_repo = mock('repository')
23
+ @mock_repo.stubs(:datastream_dissemination=>'My Content')
24
+ mock_inner.stubs(:repository).returns(@mock_repo)
25
+ mock_inner.stubs(:pid).returns(@pid)
26
+ @test_ds = ActiveFedora::RelsExtDatastream.new(mock_inner, "RELS-EXT")
33
27
  end
34
28
 
35
29
  it 'should respond to #save' do
36
30
  @test_ds.should respond_to(:save)
37
31
  end
38
32
 
39
- describe '#save' do
40
-
41
- it "should call super.save" do
42
- # Funny jiggering to mock super when RelsExt datstream calls super.save
43
- Fedora::Repository.instance.expects(:save).returns(mock("boo"))
44
- @test_ds.save
45
- end
33
+ describe '#serialize!' do
46
34
 
47
35
  it "should generate new rdf/xml as the datastream content if the object has been changed" do
48
- @test_ds.dirty = true
49
- @test_ds.expects(:to_rels_ext)
50
- @test_ds.expects(:content=)
51
- # Funny jiggering to mock super when RelsExt datstream calls super.save
52
- Fedora::Repository.instance.expects(:save).returns(mock("boo"))
53
- @test_ds.save
36
+ @test_ds.register_triple(:self, :is_member_of, "demo:10")
37
+ @test_ds.serialize!
38
+ @test_ds.content.should == " <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n <rdf:Description rdf:about='info:fedora/test:sample_pid'>\n <isMemberOf rdf:resource='demo:10' xmlns='info:fedora/fedora-system:def/relations-external#'/></rdf:Description>\n </rdf:RDF>\n"
54
39
  end
55
40
 
56
41
  end
@@ -68,11 +53,9 @@ describe ActiveFedora::RelsExtDatastream do
68
53
  end
69
54
  it "should load RELS-EXT relationships into relationships hash" do
70
55
  @test_obj.relationships.should == {:self=>{:is_member_of=>["info:fedora/demo:10"], :is_part_of=>["info:fedora/demo:11"], :has_model=>["info:fedora/afmodel:ActiveFedora_Base"], :conforms_to=>["AnInterface"]}}
71
- doc = Nokogiri::XML::Document.parse(@test_obj.inner_object.object_xml)
72
- el = doc.xpath("/foxml:digitalObject//foxml:datastream[@ID='RELS-EXT']").first
73
- new_ds = ActiveFedora::RelsExtDatastream.new
56
+ new_ds = ActiveFedora::RelsExtDatastream.new(nil, nil)
74
57
  new_ds.relationships.should == {:self=>{}}
75
- ActiveFedora::RelsExtDatastream.from_xml(new_ds,el)
58
+ ActiveFedora::RelsExtDatastream.from_xml(@test_obj.rels_ext.content,new_ds)
76
59
  new_ds.relationships.should == @test_obj.relationships
77
60
  end
78
61
  it "should handle un-mapped predicates gracefully" do
@@ -81,6 +64,29 @@ describe ActiveFedora::RelsExtDatastream do
81
64
  @test_obj.save
82
65
  @test_obj.relationships.should == {:self=>{:is_part_of=>["info:fedora/demo:11"], "foo"=>["info:fedora/foo:bar"], :has_model=>["info:fedora/afmodel:ActiveFedora_Base"], :is_member_of=>["info:fedora/demo:10"], :conforms_to=>["AnInterface"]}}
83
66
  end
67
+ it "should handle un-mapped literals" do
68
+ pending
69
+ xml = "
70
+ <foxml:datastream ID=\"RELS-EXT\" STATE=\"A\" CONTROL_GROUP=\"X\" VERSIONABLE=\"true\" xmlns:foxml=\"info:fedora/fedora-system:def/foxml#\">
71
+ <foxml:datastreamVersion ID=\"RELS-EXT.0\" LABEL=\"\" CREATED=\"2011-09-20T19:48:43.714Z\" MIMETYPE=\"text/xml\" SIZE=\"622\">
72
+ <foxml:xmlContent>
73
+ <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">
74
+ <rdf:Description rdf:about=\"info:fedora/changeme:3489\">
75
+ <hasModel xmlns=\"info:fedora/fedora-system:def/model#\" rdf:resource=\"info:fedora/afmodel:ActiveFedora_Base\"/>
76
+ <isPartOf xmlns=\"info:fedora/fedora-system:def/relations-external#\" rdf:resource=\"info:fedora/demo:11\"/>
77
+ <isMemberOf xmlns=\"info:fedora/fedora-system:def/relations-external#\" rdf:resource=\"info:fedora/demo:10\"/>
78
+ <hasMetadata xmlns=\"info:fedora/fedora-system:def/relations-external#\">oai:hull.ac.uk:hull:2708</hasMetadata>
79
+ </rdf:Description>
80
+ </rdf:RDF>
81
+ </foxml:xmlContent>
82
+ </foxml:datastreamVersion>\n</foxml:datastream>\n"
83
+ doc = Nokogiri::XML::Document.parse(xml)
84
+ new_ds = ActiveFedora::RelsExtDatastream.new
85
+ ActiveFedora::RelsExtDatastream.from_xml(new_ds,doc.root)
86
+ new_ext = new_ds.to_rels_ext('changeme:3489')
87
+ new_ext.should match "<hasMetadata xmlns=\"info:fedora/fedora-system:def/relations-external#\">oai:hull.ac.uk:hull:2708</hasMetadata>"
88
+
89
+ end
84
90
  end
85
91
 
86
92
 
@@ -0,0 +1,26 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+ require 'active_fedora/rubydora_connection'
3
+
4
+ describe ActiveFedora::RubydoraConnection do
5
+
6
+ describe 'nextid' do
7
+ before do
8
+ @instance = ActiveFedora::RubydoraConnection.instance
9
+ end
10
+ it "should get nextid" do
11
+ one = @instance.nextid
12
+ two = @instance.nextid
13
+ one = one.gsub('changeme:', '').to_i
14
+ two = two.gsub('changeme:', '').to_i
15
+ two.should == one + 1
16
+ end
17
+ end
18
+
19
+ describe 'find_model' do
20
+
21
+ end
22
+
23
+
24
+ end
25
+
26
+
@@ -1,11 +1,6 @@
1
1
  require File.join( File.dirname(__FILE__), "../spec_helper" )
2
2
 
3
- require 'active_fedora'
4
3
  require 'xmlsimple'
5
- #require 'mocha'
6
-
7
- #include ActiveFedora::SemanticNode
8
- #include Mocha::API
9
4
 
10
5
  @@last_pid = 0
11
6
 
@@ -36,6 +31,16 @@ describe ActiveFedora::SemanticNode do
36
31
  include ActiveFedora::SemanticNode
37
32
 
38
33
  attr_accessor :pid
34
+ def initialize (params={})
35
+ self.pid = params[:pid]
36
+ end
37
+ end
38
+
39
+ class AudioRecord
40
+ attr_accessor :pid
41
+ def initialize (params={})
42
+ self.pid = params[:pid]
43
+ end
39
44
  end
40
45
 
41
46
  @node = SpecNode.new
@@ -268,18 +273,12 @@ describe ActiveFedora::SemanticNode do
268
273
 
269
274
  it "resulting finder should search against solr and use Model#load_instance to build an array of objects" do
270
275
  solr_result = (mock("solr result", :is_a? => true, :hits => @sample_solr_hits))
271
- mock_repo = mock("repo")
272
- mock_repo.expects(:find_model).with("_PID1_", "AudioRecord").returns("AR1")
273
- mock_repo.expects(:find_model).with("_PID2_", "AudioRecord").returns("AR2")
274
- mock_repo.expects(:find_model).with("_PID3_", "AudioRecord").returns("AR3")
275
276
  SpecNode.create_inbound_relationship_finders("parts", :is_part_of, :inbound => true)
276
277
  local_node = SpecNode.new()
277
278
  local_node.expects(:pid).returns("test:sample_pid")
278
279
  SpecNode.expects(:relationships_desc).returns({:inbound=>{"parts"=>{:predicate=>:is_part_of}}}).at_least_once()
279
280
  ActiveFedora::SolrService.instance.conn.expects(:query).with("is_part_of_s:info\\:fedora/test\\:sample_pid", :rows=>25).returns(solr_result)
280
- Fedora::Repository.expects(:instance).returns(mock_repo).times(3)
281
- Kernel.expects(:const_get).with("AudioRecord").returns("AudioRecord").times(3)
282
- local_node.parts.should == ["AR1", "AR2", "AR3"]
281
+ local_node.parts.map(&:pid).should == ["_PID1_", "_PID2_", "_PID3_"]
283
282
  end
284
283
 
285
284
  it "resulting finder should accept :solr as :response_format value and return the raw Solr Result" do
@@ -353,11 +352,7 @@ describe ActiveFedora::SemanticNode do
353
352
  {"id"=> "my:_PID3_", "has_model_s"=>["info:fedora/afmodel:SpecNode"]}])
354
353
 
355
354
  ActiveFedora::SolrService.instance.conn.expects(:query).with("id:my\\:_PID1_ OR id:my\\:_PID2_ OR id:my\\:_PID3_").returns(solr_result)
356
- mock_repo.expects(:find_model).with("my:_PID1_", SpecNode).returns("AR1")
357
- mock_repo.expects(:find_model).with("my:_PID2_", SpecNode).returns("AR2")
358
- mock_repo.expects(:find_model).with("my:_PID3_", SpecNode).returns("AR3")
359
- Fedora::Repository.expects(:instance).returns(mock_repo).times(3)
360
- local_node.containers.should == ["AR1", "AR2", "AR3"]
355
+ local_node.containers.map(&:pid).should == ["my:_PID1_", "my:_PID2_", "my:_PID3_"]
361
356
  end
362
357
 
363
358
  it "should accept :solr as :response_format value and return the raw Solr Result" do
@@ -1,21 +1,21 @@
1
1
  require File.join( File.dirname(__FILE__), "../spec_helper" )
2
2
 
3
- require 'active_fedora/solr_service'
4
3
 
5
- include ActiveFedora
4
+ #include ActiveFedora
6
5
 
7
6
  describe ActiveFedora do
8
7
 
9
8
  before(:all) do
10
- module SpecModel
9
+ module SolrSpecModel
11
10
  class Basic
12
11
  include ActiveFedora::Model
12
+ def initialize(opts)
13
+ end
13
14
  end
14
15
  end
15
16
  end
16
17
 
17
18
  before(:each) do
18
- Fedora::Repository.instance.stubs(:nextid).returns("_nextid_")
19
19
  @test_object = ActiveFedora::Base.new
20
20
  end
21
21
 
@@ -53,11 +53,11 @@ describe ActiveFedora do
53
53
  mock_result = mock("MockResult")
54
54
  mock_result.expects(:hits).returns([{SOLR_DOCUMENT_ID => "changeme:30"}])
55
55
  mock_solr.expects(:query).with(SOLR_DOCUMENT_ID + ':changeme\:30').returns(mock_result)
56
- Fedora::Repository.instance.expects(:find_model).with("changeme:30", SpecModel::Basic).returns("fake object")
56
+ #Fedora::Repository.instance.expects(:find_model).with("changeme:30", SolrSpecModel::Basic).returns("fake object")
57
57
 
58
58
  ActiveFedora::SolrService.expects(:instance).returns(mock("SolrService", :conn => mock_solr))
59
59
 
60
- res = SpecModel::Basic.find("changeme:30")
60
+ res = SolrSpecModel::Basic.find("changeme:30")
61
61
  end
62
62
  it "should be used by ActiveFedora::Base#find_by_solr" do
63
63
  mock_solr = mock("SolrConnection")
@@ -65,7 +65,7 @@ describe ActiveFedora do
65
65
  mock_solr.expects(:query).with(SOLR_DOCUMENT_ID + ':changeme\:30', {}).returns(mock_response)
66
66
  ActiveFedora::SolrService.expects(:instance).returns(mock("SolrService", :conn => mock_solr))
67
67
 
68
- SpecModel::Basic.find_by_solr("changeme:30").should equal(mock_response)
68
+ SolrSpecModel::Basic.find_by_solr("changeme:30").should equal(mock_response)
69
69
  end
70
70
  end
71
71
 
@@ -79,18 +79,17 @@ describe ActiveFedora do
79
79
  end
80
80
 
81
81
  it "should prevent Base.save from calling update_index if false" do
82
- Fedora::Repository.instance.stubs(:save)
83
- dirty_ds = ActiveFedora::MetadataDatastream.new
84
- dirty_ds.expects(:dirty?).returns(true)
85
- dirty_ds.expects(:save).returns(true)
86
- @test_object.instance_variable_set(:@metadata_is_dirty, true)
87
- @test_object.stubs(:datastreams_in_memory).returns({:ds1 => dirty_ds})
82
+ dirty_ds = ActiveFedora::MetadataDatastream.new(@test_object.inner_object, 'ds1')
83
+ repo = @test_object.inner_object.repository
84
+ repo.expects(:add_datastream).twice
85
+ repo.expects(:ingest)
86
+ @test_object.stubs(:datastreams).returns({:ds1 => dirty_ds})
88
87
  @test_object.expects(:update_index).never
89
88
  @test_object.expects(:refresh)
90
89
  @test_object.save
91
90
  end
92
91
  it "should prevent Base.delete from deleting the corresponding Solr document if false" do
93
- Fedora::Repository.instance.expects(:delete)
92
+ Rubydora::DigitalObject.any_instance.expects(:delete)
94
93
  ActiveFedora::SolrService.instance.conn.expects(:delete).with(@test_object.pid).never
95
94
  @test_object.delete
96
95
  end
@@ -1,8 +1,5 @@
1
1
  require File.join( File.dirname(__FILE__), "../spec_helper" )
2
2
 
3
- require 'active_fedora/solr_service'
4
-
5
- include ActiveFedora
6
3
 
7
4
  describe ActiveFedora::SolrService do
8
5
  after(:all) do
@@ -12,34 +9,34 @@ describe ActiveFedora::SolrService do
12
9
  it "should take a narg constructor and configure for localhost" do
13
10
  mconn = mock('conn')
14
11
  Solr::Connection.expects(:new).with('http://localhost:8080/solr', {:autocommit=>:on}).returns(mconn)
15
- ss = SolrService.register
12
+ ss = ActiveFedora::SolrService.register
16
13
  end
17
14
  it "should accept host arg into constructor" do
18
15
  mconn = mock('conn')
19
16
  Solr::Connection.expects(:new).with('http://fubar', {:autocommit=>:on}).returns(mconn)
20
- ss = SolrService.register('http://fubar')
17
+ ss = ActiveFedora::SolrService.register('http://fubar')
21
18
  end
22
19
  it "should merge options" do
23
20
  mconn = mock('conn')
24
21
  Solr::Connection.expects(:new).with('http://localhost:8080/solr', {:autocommit=>:on, :foo=>'bar'}).returns(mconn)
25
- ss = SolrService.register(nil, {:foo=>'bar'})
22
+ ss = ActiveFedora::SolrService.register(nil, {:foo=>'bar'})
26
23
  end
27
24
  it "should clobber options" do
28
25
  mconn = mock('conn')
29
26
  Solr::Connection.expects(:new).with('http://localhost:8080/solr', {:autocommit=>:off, :foo=>:bar}).returns(mconn)
30
- ss = SolrService.register(nil, {:autocommit=>:off, :foo=>:bar})
27
+ ss = ActiveFedora::SolrService.register(nil, {:autocommit=>:off, :foo=>:bar})
31
28
  end
32
29
 
33
30
  it "should set the threadlocal solr service" do
34
31
  mconn = mock('conn')
35
32
  Solr::Connection.expects(:new).with('http://localhost:8080/solr', {:autocommit=>:off, :foo=>:bar}).returns(mconn)
36
- ss = SolrService.register(nil, {:autocommit=>:off, :foo=>:bar})
33
+ ss = ActiveFedora::SolrService.register(nil, {:autocommit=>:off, :foo=>:bar})
37
34
  Thread.current[:solr_service].should == ss
38
- SolrService.instance.should == ss
35
+ ActiveFedora::SolrService.instance.should == ss
39
36
  end
40
37
  it "should fail fast if solr service not initialized" do
41
38
  Thread.current[:solr_service].should be_nil
42
- proc{SolrService.instance}.should raise_error(SolrNotInitialized)
39
+ proc{ActiveFedora::SolrService.instance}.should raise_error(ActiveFedora::SolrNotInitialized)
43
40
  end
44
41
  before do
45
42
  Thread.current[:solr_service]=nil
@@ -47,6 +44,12 @@ describe ActiveFedora::SolrService do
47
44
 
48
45
  describe "#reify_solr_results" do
49
46
  before(:each) do
47
+ class AudioRecord
48
+ attr_accessor :pid
49
+ def initialize (params={})
50
+ self.pid = params[:pid]
51
+ end
52
+ end
50
53
  @sample_solr_hits = [{"id"=>"my:_PID1_", "has_model_s"=>["info:fedora/afmodel:AudioRecord"]},
51
54
  {"id"=>"my:_PID2_", "has_model_s"=>["info:fedora/afmodel:AudioRecord"]},
52
55
  {"id"=>"my:_PID3_", "has_model_s"=>["info:fedora/afmodel:AudioRecord"]}]
@@ -58,13 +61,7 @@ describe ActiveFedora::SolrService do
58
61
  it "should use Repository.find_model to instantiate objects" do
59
62
  solr_result = mock("solr result", :is_a? => true)
60
63
  solr_result.expects(:hits).returns(@sample_solr_hits)
61
- Kernel.expects(:const_get).with("AudioRecord").returns("AudioRecord").times(3)
62
- mock_repo = mock("repo")
63
- mock_repo.expects(:find_model).with("my:_PID1_", "AudioRecord").returns("AR1")
64
- mock_repo.expects(:find_model).with("my:_PID2_", "AudioRecord").returns("AR2")
65
- mock_repo.expects(:find_model).with("my:_PID3_", "AudioRecord").returns("AR3")
66
- Fedora::Repository.expects(:instance).returns(mock_repo).times(3)
67
- ActiveFedora::SolrService.reify_solr_results(solr_result).should == ["AR1", "AR2", "AR3"]
64
+ ActiveFedora::SolrService.reify_solr_results(solr_result).map(&:pid).should == ["my:_PID1_", "my:_PID2_", "my:_PID3_"]
68
65
  end
69
66
  end
70
67
 
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
5
- prerelease:
4
+ hash: 1923832027
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
+ - 1
8
9
  - 0
9
- - 7
10
- version: 3.0.7
10
+ - pre
11
+ - 1
12
+ version: 3.1.0.pre1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Matt Zumwalt
@@ -16,7 +18,7 @@ autorequire:
16
18
  bindir: bin
17
19
  cert_chain: []
18
20
 
19
- date: 2011-10-20 00:00:00 -05:00
21
+ date: 2011-10-11 00:00:00 -05:00
20
22
  default_executable:
21
23
  dependencies:
22
24
  - !ruby/object:Gem::Dependency
@@ -104,12 +106,11 @@ dependencies:
104
106
  requirements:
105
107
  - - ">="
106
108
  - !ruby/object:Gem::Version
107
- hash: 1
109
+ hash: 15
108
110
  segments:
109
111
  - 1
110
- - 4
111
- - 3
112
- version: 1.4.3
112
+ - 0
113
+ version: "1.0"
113
114
  type: :runtime
114
115
  version_requirements: *id006
115
116
  - !ruby/object:Gem::Dependency
@@ -203,21 +204,23 @@ dependencies:
203
204
  type: :runtime
204
205
  version_requirements: *id012
205
206
  - !ruby/object:Gem::Dependency
206
- name: yard
207
+ name: rubydora
207
208
  prerelease: false
208
209
  requirement: &id013 !ruby/object:Gem::Requirement
209
210
  none: false
210
211
  requirements:
211
- - - ">="
212
+ - - ~>
212
213
  - !ruby/object:Gem::Version
213
- hash: 3
214
+ hash: 23
214
215
  segments:
215
216
  - 0
216
- version: "0"
217
- type: :development
217
+ - 1
218
+ - 6
219
+ version: 0.1.6
220
+ type: :runtime
218
221
  version_requirements: *id013
219
222
  - !ruby/object:Gem::Dependency
220
- name: RedCloth
223
+ name: yard
221
224
  prerelease: false
222
225
  requirement: &id014 !ruby/object:Gem::Requirement
223
226
  none: false
@@ -231,7 +234,7 @@ dependencies:
231
234
  type: :development
232
235
  version_requirements: *id014
233
236
  - !ruby/object:Gem::Dependency
234
- name: rake
237
+ name: RedCloth
235
238
  prerelease: false
236
239
  requirement: &id015 !ruby/object:Gem::Requirement
237
240
  none: false
@@ -245,7 +248,7 @@ dependencies:
245
248
  type: :development
246
249
  version_requirements: *id015
247
250
  - !ruby/object:Gem::Dependency
248
- name: rcov
251
+ name: rake
249
252
  prerelease: false
250
253
  requirement: &id016 !ruby/object:Gem::Requirement
251
254
  none: false
@@ -259,7 +262,7 @@ dependencies:
259
262
  type: :development
260
263
  version_requirements: *id016
261
264
  - !ruby/object:Gem::Dependency
262
- name: solrizer-fedora
265
+ name: rcov
263
266
  prerelease: false
264
267
  requirement: &id017 !ruby/object:Gem::Requirement
265
268
  none: false
@@ -273,23 +276,41 @@ dependencies:
273
276
  type: :development
274
277
  version_requirements: *id017
275
278
  - !ruby/object:Gem::Dependency
276
- name: jettywrapper
279
+ name: solrizer-fedora
277
280
  prerelease: false
278
281
  requirement: &id018 !ruby/object:Gem::Requirement
279
282
  none: false
280
283
  requirements:
281
284
  - - ">="
282
285
  - !ruby/object:Gem::Version
283
- hash: 3
286
+ hash: 23
284
287
  segments:
285
- - 0
286
- version: "0"
288
+ - 1
289
+ - 1
290
+ - 2
291
+ version: 1.1.2
287
292
  type: :development
288
293
  version_requirements: *id018
289
294
  - !ruby/object:Gem::Dependency
290
- name: rspec
295
+ name: jettywrapper
291
296
  prerelease: false
292
297
  requirement: &id019 !ruby/object:Gem::Requirement
298
+ none: false
299
+ requirements:
300
+ - - ">="
301
+ - !ruby/object:Gem::Version
302
+ hash: 23
303
+ segments:
304
+ - 1
305
+ - 0
306
+ - 0
307
+ version: 1.0.0
308
+ type: :development
309
+ version_requirements: *id019
310
+ - !ruby/object:Gem::Dependency
311
+ name: rspec
312
+ prerelease: false
313
+ requirement: &id020 !ruby/object:Gem::Requirement
293
314
  none: false
294
315
  requirements:
295
316
  - - <
@@ -301,11 +322,11 @@ dependencies:
301
322
  - 0
302
323
  version: 2.0.0
303
324
  type: :development
304
- version_requirements: *id019
325
+ version_requirements: *id020
305
326
  - !ruby/object:Gem::Dependency
306
327
  name: mocha
307
328
  prerelease: false
308
- requirement: &id020 !ruby/object:Gem::Requirement
329
+ requirement: &id021 !ruby/object:Gem::Requirement
309
330
  none: false
310
331
  requirements:
311
332
  - - ">="
@@ -317,11 +338,11 @@ dependencies:
317
338
  - 8
318
339
  version: 0.9.8
319
340
  type: :development
320
- version_requirements: *id020
341
+ version_requirements: *id021
321
342
  - !ruby/object:Gem::Dependency
322
343
  name: ruby-debug
323
344
  prerelease: false
324
- requirement: &id021 !ruby/object:Gem::Requirement
345
+ requirement: &id022 !ruby/object:Gem::Requirement
325
346
  none: false
326
347
  requirements:
327
348
  - - ">="
@@ -331,7 +352,7 @@ dependencies:
331
352
  - 0
332
353
  version: "0"
333
354
  type: :development
334
- version_requirements: *id021
355
+ version_requirements: *id022
335
356
  description: ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.
336
357
  email:
337
358
  - matt.zumwalt@yourmediashelf.com
@@ -527,6 +548,7 @@ files:
527
548
  - lib/active_fedora/base.rb
528
549
  - lib/active_fedora/content_model.rb
529
550
  - lib/active_fedora/datastream.rb
551
+ - lib/active_fedora/datastream_hash.rb
530
552
  - lib/active_fedora/delegating.rb
531
553
  - lib/active_fedora/fedora_object.rb
532
554
  - lib/active_fedora/metadata_datastream.rb
@@ -541,6 +563,7 @@ files:
541
563
  - lib/active_fedora/relationship.rb
542
564
  - lib/active_fedora/relationships_helper.rb
543
565
  - lib/active_fedora/rels_ext_datastream.rb
566
+ - lib/active_fedora/rubydora_connection.rb
544
567
  - lib/active_fedora/samples.rb
545
568
  - lib/active_fedora/samples/hydra-mods_article_datastream.rb
546
569
  - lib/active_fedora/samples/hydra-rights_metadata_datastream.rb
@@ -549,13 +572,6 @@ files:
549
572
  - lib/active_fedora/semantic_node.rb
550
573
  - lib/active_fedora/solr_service.rb
551
574
  - lib/active_fedora/version.rb
552
- - lib/fedora/base.rb
553
- - lib/fedora/connection.rb
554
- - lib/fedora/datastream.rb
555
- - lib/fedora/fedora_object.rb
556
- - lib/fedora/formats.rb
557
- - lib/fedora/generic_search.rb
558
- - lib/fedora/repository.rb
559
575
  - lib/ruby-fedora.rb
560
576
  - lib/tasks/active_fedora.rake
561
577
  - lib/tasks/active_fedora_dev.rake
@@ -590,8 +606,6 @@ files:
590
606
  - spec/integration/base_spec.rb
591
607
  - spec/integration/bug_spec.rb
592
608
  - spec/integration/datastream_spec.rb
593
- - spec/integration/datastreams_crud_spec.rb
594
- - spec/integration/fedora_object_spec.rb
595
609
  - spec/integration/full_featured_model_spec.rb
596
610
  - spec/integration/metadata_datastream_helper_spec.rb
597
611
  - spec/integration/model_spec.rb
@@ -599,8 +613,6 @@ files:
599
613
  - spec/integration/nested_attribute_spec.rb
600
614
  - spec/integration/nokogiri_datastream_spec.rb
601
615
  - spec/integration/rels_ext_datastream_spec.rb
602
- - spec/integration/repository_spec.rb
603
- - spec/integration/rf_fedora_object_spec.rb
604
616
  - spec/integration/semantic_node_spec.rb
605
617
  - spec/integration/solr_service_spec.rb
606
618
  - spec/rails3_test_app/.gitignore
@@ -654,11 +666,9 @@ files:
654
666
  - spec/unit/base_file_management_spec.rb
655
667
  - spec/unit/base_named_datastream_spec.rb
656
668
  - spec/unit/base_spec.rb
657
- - spec/unit/connection_spec.rb
658
669
  - spec/unit/content_model_spec.rb
659
670
  - spec/unit/datastream_concurrency_spec.rb
660
671
  - spec/unit/datastream_spec.rb
661
- - spec/unit/fedora_object_spec.rb
662
672
  - spec/unit/has_many_collection_spec.rb
663
673
  - spec/unit/inheritance_spec.rb
664
674
  - spec/unit/metadata_datastream_spec.rb
@@ -669,8 +679,7 @@ files:
669
679
  - spec/unit/relationship_spec.rb
670
680
  - spec/unit/relationships_helper_spec.rb
671
681
  - spec/unit/rels_ext_datastream_spec.rb
672
- - spec/unit/repository_spec.rb
673
- - spec/unit/rf_datastream_spec.rb
682
+ - spec/unit/rubydora_connection_spec.rb
674
683
  - spec/unit/semantic_node_spec.rb
675
684
  - spec/unit/solr_config_options_spec.rb
676
685
  - spec/unit/solr_service_spec.rb
@@ -695,12 +704,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
695
704
  required_rubygems_version: !ruby/object:Gem::Requirement
696
705
  none: false
697
706
  requirements:
698
- - - ">="
707
+ - - ">"
699
708
  - !ruby/object:Gem::Version
700
- hash: 3
709
+ hash: 25
701
710
  segments:
702
- - 0
703
- version: "0"
711
+ - 1
712
+ - 3
713
+ - 1
714
+ version: 1.3.1
704
715
  requirements: []
705
716
 
706
717
  rubyforge_project: rubyfedora
@@ -732,8 +743,6 @@ test_files:
732
743
  - spec/integration/base_spec.rb
733
744
  - spec/integration/bug_spec.rb
734
745
  - spec/integration/datastream_spec.rb
735
- - spec/integration/datastreams_crud_spec.rb
736
- - spec/integration/fedora_object_spec.rb
737
746
  - spec/integration/full_featured_model_spec.rb
738
747
  - spec/integration/metadata_datastream_helper_spec.rb
739
748
  - spec/integration/model_spec.rb
@@ -741,8 +750,6 @@ test_files:
741
750
  - spec/integration/nested_attribute_spec.rb
742
751
  - spec/integration/nokogiri_datastream_spec.rb
743
752
  - spec/integration/rels_ext_datastream_spec.rb
744
- - spec/integration/repository_spec.rb
745
- - spec/integration/rf_fedora_object_spec.rb
746
753
  - spec/integration/semantic_node_spec.rb
747
754
  - spec/integration/solr_service_spec.rb
748
755
  - spec/rails3_test_app/.gitignore
@@ -796,11 +803,9 @@ test_files:
796
803
  - spec/unit/base_file_management_spec.rb
797
804
  - spec/unit/base_named_datastream_spec.rb
798
805
  - spec/unit/base_spec.rb
799
- - spec/unit/connection_spec.rb
800
806
  - spec/unit/content_model_spec.rb
801
807
  - spec/unit/datastream_concurrency_spec.rb
802
808
  - spec/unit/datastream_spec.rb
803
- - spec/unit/fedora_object_spec.rb
804
809
  - spec/unit/has_many_collection_spec.rb
805
810
  - spec/unit/inheritance_spec.rb
806
811
  - spec/unit/metadata_datastream_spec.rb
@@ -811,8 +816,7 @@ test_files:
811
816
  - spec/unit/relationship_spec.rb
812
817
  - spec/unit/relationships_helper_spec.rb
813
818
  - spec/unit/rels_ext_datastream_spec.rb
814
- - spec/unit/repository_spec.rb
815
- - spec/unit/rf_datastream_spec.rb
819
+ - spec/unit/rubydora_connection_spec.rb
816
820
  - spec/unit/semantic_node_spec.rb
817
821
  - spec/unit/solr_config_options_spec.rb
818
822
  - spec/unit/solr_service_spec.rb