active-fedora 3.1.0.pre2 → 3.1.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "3.1.0.pre2"
2
+ VERSION = "3.1.0.pre3"
3
3
  end
@@ -18,17 +18,6 @@ APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
18
18
  require 'jettywrapper'
19
19
 
20
20
  $: << 'lib'
21
- # def jetty_params
22
- # project_root = File.expand_path("#{File.dirname(__FILE__)}/../../")
23
- # {
24
- # :quiet => false,
25
- # :jetty_home => File.join(project_root,'jetty'),
26
- # :jetty_port => 8983,
27
- # :solr_home => File.expand_path(File.join(project_root,'jetty','solr')),
28
- # :fedora_home => File.expand_path(File.join(project_root,'jetty','fedora','default')),
29
- # :startup_wait=>30
30
- # }
31
- # end
32
21
 
33
22
  desc "Run active-fedora rspec tests"
34
23
  task :spec do
@@ -44,7 +33,6 @@ task :hudson do
44
33
  jetty_params = Jettywrapper.load_config
45
34
  jetty_params[:startup_wait]= 20
46
35
  error = Jettywrapper.wrap(jetty_params) do
47
- #ENV["FEDORA_HOME"]=File.expand_path(File.join(File.dirname(__FILE__),'..','..','jetty','fedora','default'))
48
36
  Rake::Task["active_fedora:load_fixtures"].invoke
49
37
  Rake::Task["active_fedora:rspec"].invoke
50
38
  end
@@ -97,7 +97,7 @@ describe ActiveFedora::Base do
97
97
  @test_object2.save
98
98
  rexml = REXML::Document.new(@test_object2.datastreams["RELS-EXT"].content)
99
99
  # Purpose: confirm that the isMemberOf entries exist and have real RDF in them
100
- rexml.root.elements["rdf:Description/hasModel"].attributes["rdf:resource"].should == 'info:fedora/afmodel:ActiveFedora_Base'
100
+ rexml.root.elements["rdf:Description/ns0:hasModel"].attributes["rdf:resource"].should == 'info:fedora/afmodel:ActiveFedora_Base'
101
101
  end
102
102
  it "should merge attributes from fedora into attributes hash" do
103
103
  inner_object = @test_object2.inner_object
@@ -215,8 +215,9 @@ describe ActiveFedora::Base do
215
215
  @test_object.save
216
216
  rexml = REXML::Document.new(@test_object.datastreams["RELS-EXT"].content)
217
217
  # Purpose: confirm that the isMemberOf entries exist and have real RDF in them
218
- rexml.root.elements["rdf:Description/isMemberOf[@rdf:resource='info:fedora/demo:5']"].attributes["xmlns"].should == 'info:fedora/fedora-system:def/relations-external#'
219
- rexml.root.elements["rdf:Description/isMemberOf[@rdf:resource='info:fedora/demo:10']"].attributes["xmlns"].should == 'info:fedora/fedora-system:def/relations-external#'
218
+ rexml.root.attributes["xmlns:ns1"].should == 'info:fedora/fedora-system:def/relations-external#'
219
+ rexml.root.elements["rdf:Description/ns1:isMemberOf[@rdf:resource='info:fedora/demo:5']"].should_not be_nil
220
+ rexml.root.elements["rdf:Description/ns1:isMemberOf[@rdf:resource='info:fedora/demo:10']"].should_not be_nil
220
221
  end
221
222
  end
222
223
 
@@ -359,28 +360,25 @@ describe ActiveFedora::Base do
359
360
  #use dummy relationships just to get correct formatting for expected objects
360
361
  r = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>:dummy, :object=>@test_object2)
361
362
  model_rel = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>:dummy, :object=>ActiveFedora::ContentModel.pid_from_ruby_class(ActiveFedora::Base))
362
- @test_object.relationships.should == {:self=>{:has_model=>[model_rel.object],
363
- :has_part=>[r.object]}}
363
+ # @test_object.relationships.should == {:self=>{:has_model=>[model_rel.object], :has_part=>[r.object]}}
364
+ stmt = @test_object.build_statement(@test_object.internal_uri, :has_part, r.object)
365
+ @test_object.relationships.has_statement?(stmt).should be_true
364
366
  @test_object.remove_relationship(:has_part,@test_object2)
365
367
  @test_object.save
366
368
  @test_object = ActiveFedora::Base.load_instance(@pid)
367
- @test_object.relationships.should == {:self=>{:has_model=>[model_rel.object]}}
369
+ @test_object.relationships.has_statement?(stmt).should be_false
368
370
  end
369
371
  end
370
372
 
371
373
  describe '#relationships' do
372
374
  it 'should return internal relationships with no parameters and include inbound if false passed in' do
373
375
  @test_object2 = MockAFBaseRelationship.new
374
- # @test_object2.new_object = true
375
376
  @test_object2.save
376
377
  @test_object3 = MockAFBaseRelationship.new
377
- # @test_object3.new_object = true
378
378
  @test_object3.save
379
379
  @test_object4 = MockAFBaseRelationship.new
380
- # @test_object4.new_object = true
381
380
  @test_object4.save
382
381
  @test_object5 = MockAFBaseRelationship.new
383
- # @test_object5.new_object = true
384
382
  @test_object5.save
385
383
  #append to named relationship 'testing'
386
384
  @test_object2.testing_append(@test_object3)
@@ -397,32 +395,42 @@ describe ActiveFedora::Base do
397
395
  r5 = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>:dummy, :object=>@test_object5)
398
396
  model_rel = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>:dummy, :object=>ActiveFedora::ContentModel.pid_from_ruby_class(MockAFBaseRelationship))
399
397
  #check inbound correct, testing goes to :has_part and testing2 goes to :has_member
400
- @test_object2.relationships(false).should == {:self=>{:has_model=>[model_rel.object],
401
- :has_part=>[r3.object],
402
- :has_member=>[r4.object],
403
- :is_member_of_collection=>[r5.object]},
404
- :inbound=>{:has_part=>[r5.object]}}
405
- @test_object3.relationships(false).should == {:self=>{:has_model=>[model_rel.object]},
406
- :inbound=>{:has_part=>[r2.object],
407
- :has_member=>[r5.object]}}
408
- @test_object4.relationships(false).should == {:self=>{:has_model=>[model_rel.object]},
409
- :inbound=>{:has_member=>[r2.object],:has_collection_member=>[r5.object]}}
410
- @test_object5.relationships(false).should == {:self=>{:has_model=>[model_rel.object],
411
- :has_part=>[r2.object],
412
- :has_member=>[r3.object],
413
- :has_collection_member=>[r4.object]},
414
- :inbound=>{:is_member_of_collection=>[r2.object]}}
415
- #all inbound should now be empty if no parameter supplied to relationships
416
- @test_object2.relationships.should == {:self=>{:has_model=>[model_rel.object],
417
- :has_part=>[r3.object],
418
- :has_member=>[r4.object],
419
- :is_member_of_collection=>[r5.object]}}
420
- @test_object3.relationships.should == {:self=>{:has_model=>[model_rel.object]}}
421
- @test_object4.relationships.should == {:self=>{:has_model=>[model_rel.object]}}
422
- @test_object5.relationships.should == {:self=>{:has_model=>[model_rel.object],
423
- :has_part=>[r2.object],
424
- :has_member=>[r3.object],
425
- :has_collection_member=>[r4.object]}}
398
+ stmt = @test_object2.build_statement(@test_object2.internal_uri, :has_model, model_rel.object)
399
+ @test_object2.relationships.has_statement?(stmt).should be_true
400
+ stmt = @test_object2.build_statement(@test_object2.internal_uri, :has_part, r3.object)
401
+ @test_object2.relationships.has_statement?(stmt).should be_true
402
+ stmt = @test_object2.build_statement(@test_object2.internal_uri, :has_member, r4.object)
403
+ @test_object2.relationships.has_statement?(stmt).should be_true
404
+ stmt = @test_object2.build_statement(@test_object2.internal_uri, :is_member_of_collection, r5.object)
405
+ @test_object2.relationships.has_statement?(stmt).should be_true
406
+ @test_object2.inbound_relationships.should == {:has_part=>[r5.object]}
407
+ stmt = @test_object3.build_statement(@test_object3.internal_uri, :has_model, model_rel.object)
408
+ @test_object3.relationships.has_statement?(stmt).should be_true
409
+ @test_object3.inbound_relationships.should == {:has_part=>[r2.object],
410
+ :has_member=>[r5.object]}
411
+ stmt = @test_object4.build_statement(@test_object4.internal_uri, :has_model, model_rel.object)
412
+ @test_object4.relationships.has_statement?(stmt).should be_true
413
+ @test_object4.inbound_relationships.should == {:has_member=>[r2.object],:has_collection_member=>[r5.object]}
414
+
415
+ stmt = @test_object5.build_statement(@test_object5.internal_uri, :has_model, model_rel.object)
416
+ @test_object5.relationships.has_statement?(stmt).should be_true
417
+ stmt = @test_object5.build_statement(@test_object5.internal_uri, :has_part, r2.object)
418
+ @test_object5.relationships.has_statement?(stmt).should be_true
419
+ stmt = @test_object5.build_statement(@test_object5.internal_uri, :has_member, r3.object)
420
+ @test_object5.relationships.has_statement?(stmt).should be_true
421
+ stmt = @test_object5.build_statement(@test_object5.internal_uri, :has_collection_member, r4.object)
422
+ @test_object5.relationships.has_statement?(stmt).should be_true
423
+ @test_object5.inbound_relationships.should == {:is_member_of_collection=>[r2.object]}
424
+ # @test_object2.outbound_relationships.should == {:has_model=>[model_rel.object],
425
+ # :has_part=>[r3.object],
426
+ # :has_member=>[r4.object],
427
+ # :is_member_of_collection=>[r5.object]}
428
+ # @test_object3.outbound_relationships.should == {:has_model=>[model_rel.object]}
429
+ # @test_object4.outbound_relationships.should == {:has_model=>[model_rel.object]}
430
+ # @test_object5.outbound_relationships.should == {:has_model=>[model_rel.object],
431
+ # :has_part=>[r2.object],
432
+ # :has_member=>[r3.object],
433
+ # :has_collection_member=>[r4.object]}
426
434
  end
427
435
  end
428
436
 
@@ -621,16 +629,12 @@ describe ActiveFedora::Base do
621
629
  describe '#find_relationship_by_name' do
622
630
  it 'should find relationships based on name passed in for inbound or outbound' do
623
631
  @test_object2 = MockAFBaseRelationship.new
624
- # @test_object2.new_object = true
625
632
  @test_object2.save
626
633
  @test_object3 = MockAFBaseRelationship.new
627
- # @test_object3.new_object = true
628
634
  @test_object3.save
629
635
  @test_object4 = MockAFBaseRelationship.new
630
- # @test_object4.new_object = true
631
636
  @test_object4.save
632
637
  @test_object5 = MockAFBaseRelationship.new
633
- # @test_object5.new_object = true
634
638
  @test_object5.save
635
639
  #append to named relationship 'testing'
636
640
  @test_object2.add_relationship_by_name("testing",@test_object3)
@@ -30,6 +30,7 @@ describe ActiveFedora::RelsExtDatastream do
30
30
  before(:each) do
31
31
  @test_object = ActiveFedora::Base.new
32
32
  @test_datastream = ActiveFedora::RelsExtDatastream.new(@test_object.inner_object, 'RELS-EXT')
33
+ @test_datastream.model = @test_object
33
34
  @test_object.save
34
35
  @test_relationships = [ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "info:fedora/demo:5"),
35
36
  ActiveFedora::Relationship.new(:subject => :self, :predicate => :is_member_of, :object => "info:fedora/demo:10")]
@@ -64,9 +65,9 @@ describe ActiveFedora::RelsExtDatastream do
64
65
  it "should generate new rdf/xml as the datastream content" do
65
66
  @test_object.add_datastream(@test_datastream)
66
67
  @test_relationships.each do |rel|
67
- @test_datastream.add_relationship(rel)
68
+ @test_object.add_relationship(rel.predicate, rel.object)
68
69
  end
69
- rexml1 = REXML::Document.new(@test_datastream.to_rels_ext(@test_object.pid))
70
+ rexml1 = REXML::Document.new(@test_datastream.to_rels_ext())
70
71
  @test_datastream.serialize!
71
72
  rexml2 = REXML::Document.new(@test_object.datastreams["RELS-EXT"].content)
72
73
  rexml1.root.elements["rdf:Description"].inspect.should eql(rexml2.root.elements["rdf:Description"].inspect)
@@ -81,9 +82,10 @@ describe ActiveFedora::RelsExtDatastream do
81
82
  end
82
83
  @test_object.save
83
84
  # make sure that _something_ was actually added to the object's relationships hash
84
- @test_object.relationships[:self].should have_key(:is_member_of)
85
+ @test_object.ids_for_outbound(:is_member_of).size.should == 1
85
86
  o = ActiveFedora::Base.load_instance(@test_object.pid)
86
- ActiveFedora::Base.load_instance(@test_object.pid).relationships.should == @test_object.relationships
87
+ new_rels = ActiveFedora::Base.load_instance(@test_object.pid).relationships
88
+ new_rels.should == @test_object.relationships
87
89
  end
88
90
 
89
91
  describe '#from_solr' do
@@ -132,15 +134,34 @@ describe ActiveFedora::RelsExtDatastream do
132
134
  test_from_solr_object5 = MockAFRelsSolr.new
133
135
  test_from_solr_object5.rels_ext.from_solr(solr_doc)
134
136
 
135
- test_from_solr_object2.relationships.should == {:self=>{:has_part=>[r3.object],:has_member=>[r4.object],:has_model=>[model_rel.object]}}
137
+ stmt = test_from_solr_object2.build_statement(test_from_solr_object2.internal_uri, :has_part, r3.object)
138
+ test_from_solr_object2.relationships.has_statement?(stmt).should be_true
139
+ stmt = test_from_solr_object2.build_statement(test_from_solr_object2.internal_uri, :has_member, r4.object)
140
+ test_from_solr_object2.relationships.has_statement?(stmt).should be_true
141
+ stmt = test_from_solr_object2.build_statement(test_from_solr_object2.internal_uri, :has_model, model_rel.object)
142
+ test_from_solr_object2.relationships.has_statement?(stmt).should be_true
143
+
144
+ # test_from_solr_object2.relationships.should == {:self=>{:has_part=>[r3.object],:has_member=>[r4.object],:has_model=>[model_rel.object]}}
136
145
  test_from_solr_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[r4.object], "collection_members"=>[], "part_of"=>[], "parts_outbound"=>[r3.object]}}
137
- test_from_solr_object3.relationships.should == {:self=>{:has_model=>[model_rel.object]}}
146
+ #test_from_solr_object3.relationships.should == {:self=>{:has_model=>[model_rel.object]}}
147
+ stmt = test_from_solr_object3.build_statement(test_from_solr_object3.internal_uri, :has_model, model_rel.object)
148
+ test_from_solr_object3.relationships.has_statement?(stmt).should be_true
138
149
  test_from_solr_object3.relationships_by_name.should == {:self=>{"testing2"=>[], "collection_members"=>[], "part_of"=>[], "testing"=>[], "parts_outbound"=>[]}}
139
- test_from_solr_object4.relationships.should == {:self=>{:has_model=>[model_rel.object]}}
150
+ #test_from_solr_object4.relationships.should == {:self=>{:has_model=>[model_rel.object]}}
151
+ stmt = test_from_solr_object4.build_statement(test_from_solr_object4.internal_uri, :has_model, model_rel.object)
152
+ test_from_solr_object4.relationships.has_statement?(stmt).should be_true
140
153
  test_from_solr_object4.relationships_by_name.should == {:self=>{"testing2"=>[], "collection_members"=>[], "part_of"=>[], "testing"=>[], "parts_outbound"=>[]}}
141
- test_from_solr_object5.relationships.should == {:self=>{:has_model=>[model_rel.object],
142
- :has_part=>[r2.object],
143
- :has_member=>[r3.object]}}
154
+
155
+ stmt = test_from_solr_object5.build_statement(test_from_solr_object5.internal_uri, :has_model, model_rel.object)
156
+ test_from_solr_object5.relationships.has_statement?(stmt).should be_true
157
+ stmt = test_from_solr_object5.build_statement(test_from_solr_object5.internal_uri, :has_part, r2.object)
158
+ test_from_solr_object5.relationships.has_statement?(stmt).should be_true
159
+ stmt = test_from_solr_object5.build_statement(test_from_solr_object5.internal_uri, :has_member, r3.object)
160
+ test_from_solr_object5.relationships.has_statement?(stmt).should be_true
161
+
162
+ # test_from_solr_object5.relationships.should == {:self=>{:has_model=>[model_rel.object],
163
+ # :has_part=>[r2.object],
164
+ # :has_member=>[r3.object]}}
144
165
  test_from_solr_object5.relationships_by_name.should == {:self=>{"testing2"=>[r3.object], "collection_members"=>[], "part_of"=>[], "testing"=>[r2.object], "parts_outbound"=>[r2.object]}}
145
166
  end
146
167
  end
@@ -9,6 +9,11 @@ describe ActiveFedora::SemanticNode do
9
9
  include ActiveFedora::RelationshipsHelper
10
10
  include ActiveFedora::SemanticNode
11
11
  has_relationship "collection_members", :has_collection_member
12
+ attr_accessor :rels_ext
13
+ def initialize
14
+ self.rels_ext = ActiveFedora::RelsExtDatastream.new(nil, nil)
15
+ rels_ext.model = self
16
+ end
12
17
  end
13
18
  @node = SpecNode.new
14
19
  class SNSpecModel < ActiveFedora::Base
@@ -18,11 +23,11 @@ describe ActiveFedora::SemanticNode do
18
23
  end
19
24
  class SpecNodeSolrFilterQuery < ActiveFedora::Base
20
25
  has_relationship("parts", :is_part_of, :inbound => true)
21
- has_relationship("special_parts", :is_part_of, :inbound => true, :solr_fq=>"has_model_s:info\\:fedora/SpecialPart")
26
+ has_relationship("special_parts", :is_part_of, :inbound => true, :solr_fq=>"has_model_s:info\\:fedora/afmodel\\:SpecialPart")
22
27
  has_relationship("containers", :is_member_of)
23
- has_relationship("special_containers", :is_member_of, :solr_fq=>"has_model_s:info\\:fedora/SpecialContainer")
28
+ has_relationship("special_containers", :is_member_of, :solr_fq=>"has_model_s:info\\:fedora/afmodel\\:SpecialContainer")
24
29
  has_bidirectional_relationship("bi_containers", :is_member_of, :has_member)
25
- has_bidirectional_relationship("bi_special_containers", :is_member_of, :has_member, :solr_fq=>"has_model_s:info\\:fedora/SpecialContainer")
30
+ has_bidirectional_relationship("bi_special_containers", :is_member_of, :has_member, :solr_fq=>"has_model_s:info\\:fedora/afmodel\\:SpecialContainer")
26
31
  end
27
32
 
28
33
  @test_object = SNSpecModel.new
@@ -53,16 +58,18 @@ describe ActiveFedora::SemanticNode do
53
58
  @container4.add_relationship(:has_member,@test_object)
54
59
  @container4.save
55
60
 
61
+ class SpecialContainer; end;
62
+ class SpecialPart; end;
56
63
  @special_container = ActiveFedora::Base.new()
57
- @special_container.add_relationship(:has_model,"SpecialContainer")
64
+ @special_container.add_relationship(:has_model, ActiveFedora::ContentModel.pid_from_ruby_class(SpecialContainer))
58
65
  @special_container.save
59
66
 
60
67
  @special_container3 = ActiveFedora::Base.new()
61
- @special_container3.add_relationship(:has_model,"SpecialContainer")
68
+ @special_container3.add_relationship(:has_model, ActiveFedora::ContentModel.pid_from_ruby_class(SpecialContainer))
62
69
  @special_container3.save
63
70
 
64
71
  @special_container4 = ActiveFedora::Base.new()
65
- @special_container4.add_relationship(:has_model,"SpecialContainer")
72
+ @special_container4.add_relationship(:has_model, ActiveFedora::ContentModel.pid_from_ruby_class(SpecialContainer))
66
73
  @special_container4.save
67
74
 
68
75
  #even though adding container3 and 3 special containers, it should only include the special containers when returning via relationship name finder methods
@@ -75,8 +82,8 @@ describe ActiveFedora::SemanticNode do
75
82
  @test_object_query.save
76
83
 
77
84
  @special_container2 = ActiveFedora::Base.new()
78
- @special_container2.add_relationship(:has_model,"SpecialContainer")
79
- @special_container2.add_relationship(:has_member,@test_object_query.pid)
85
+ @special_container2.add_relationship(:has_model, ActiveFedora::ContentModel.pid_from_ruby_class(SpecialContainer))
86
+ @special_container2.add_relationship(:has_member, 'info:fedora/'+@test_object_query.pid)
80
87
  @special_container2.save
81
88
 
82
89
  @part3 = ActiveFedora::Base.new()
@@ -84,7 +91,7 @@ describe ActiveFedora::SemanticNode do
84
91
  @part3.save
85
92
 
86
93
  @special_part = ActiveFedora::Base.new()
87
- @special_part.add_relationship(:has_model,"SpecialPart")
94
+ @special_part.add_relationship(:has_model, ActiveFedora::ContentModel.pid_from_ruby_class(SpecialPart))
88
95
  @special_part.add_relationship(:is_part_of, @test_object_query)
89
96
  @special_part.save
90
97
 
@@ -144,7 +151,8 @@ describe ActiveFedora::SemanticNode do
144
151
  spec_node = SpecNode.new
145
152
  spec_node.collection_members.should == []
146
153
  rel = ActiveFedora::Relationship.new(:subject => :self, :predicate => :has_collection_member, :object => @test_object.pid)
147
- spec_node.add_relationship(rel)
154
+
155
+ spec_node.add_relationship(rel.predicate, rel.object)
148
156
  collection_members = spec_node.collection_members
149
157
  collection_members.length.should == 1
150
158
  collection_members.first.pid.should == @test_object.pid
@@ -255,13 +263,13 @@ describe ActiveFedora::SemanticNode do
255
263
  end
256
264
 
257
265
  it "should return a solr query for an inbound relationship" do
258
- @test_object_query.special_parts_query.should == "#{@test_object_query.relationship_predicates[:inbound]['special_parts']}_s:#{@test_object_query.internal_uri.gsub(/(:)/, '\\:')} AND has_model_s:info\\:fedora/SpecialPart"
266
+ @test_object_query.special_parts_query.should == "#{@test_object_query.relationship_predicates[:inbound]['special_parts']}_s:#{@test_object_query.internal_uri.gsub(/(:)/, '\\:')} AND has_model_s:info\\:fedora/afmodel\\:SpecialPart"
259
267
  end
260
268
  end
261
269
 
262
270
  describe "inbound relationship query" do
263
271
  it "should return a properly formatted query for a relationship that has a solr filter query defined" do
264
- SpecNodeSolrFilterQuery.inbound_relationship_query(@test_object_query.pid,"special_parts").should == "#{@test_object_query.relationship_predicates[:inbound]['special_parts']}_s:#{@test_object_query.internal_uri.gsub(/(:)/, '\\:')} AND has_model_s:info\\:fedora/SpecialPart"
272
+ SpecNodeSolrFilterQuery.inbound_relationship_query(@test_object_query.pid,"special_parts").should == "#{@test_object_query.relationship_predicates[:inbound]['special_parts']}_s:#{@test_object_query.internal_uri.gsub(/(:)/, '\\:')} AND has_model_s:info\\:fedora/afmodel\\:SpecialPart"
265
273
  end
266
274
 
267
275
  it "should return a properly formatted query for a relationship that does not have a solr filter query defined" do
@@ -274,7 +282,7 @@ describe ActiveFedora::SemanticNode do
274
282
  expected_string = ""
275
283
  @test_object_query.containers_ids.each_with_index do |id,index|
276
284
  expected_string << " OR " if index > 0
277
- expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/SpecialContainer)"
285
+ expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/afmodel\\:SpecialContainer)"
278
286
  end
279
287
  SpecNodeSolrFilterQuery.outbound_relationship_query("special_containers",@test_object_query.containers_ids).should == expected_string
280
288
  end
@@ -294,10 +302,10 @@ describe ActiveFedora::SemanticNode do
294
302
  expected_string = ""
295
303
  @test_object_query.bi_containers_outbound_ids.each_with_index do |id,index|
296
304
  expected_string << " OR " if index > 0
297
- expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/SpecialContainer)"
305
+ expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/afmodel\\:SpecialContainer)"
298
306
  end
299
307
  expected_string << " OR "
300
- expected_string << "(#{@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound']}_s:#{@test_object_query.internal_uri.gsub(/(:)/, '\\:')} AND has_model_s:info\\:fedora/SpecialContainer)"
308
+ expected_string << "(#{@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound']}_s:#{@test_object_query.internal_uri.gsub(/(:)/, '\\:')} AND has_model_s:info\\:fedora/afmodel\\:SpecialContainer)"
301
309
  SpecNodeSolrFilterQuery.bidirectional_relationship_query(@test_object_query.pid,"bi_special_containers",@test_object_query.bi_containers_outbound_ids).should == expected_string
302
310
  end
303
311
 
@@ -371,7 +379,7 @@ describe ActiveFedora::SemanticNode do
371
379
  expected_string = ""
372
380
  @test_object_query.containers_ids.each_with_index do |id,index|
373
381
  expected_string << " OR " if index > 0
374
- expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/SpecialContainer)"
382
+ expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/afmodel\\:SpecialContainer)"
375
383
  end
376
384
  @test_object_query.special_containers_query.should == expected_string
377
385
  end
@@ -407,23 +415,19 @@ describe ActiveFedora::SemanticNode do
407
415
  end
408
416
 
409
417
  it "should return an array of all Base objects with relationship if not using solr_fq" do
410
- ids = @test_object_query.bi_containers_ids
411
- ids.size.should == 5
412
- ids.include?(@container3.pid).should == true
413
- ids.include?(@special_container.pid).should == true
414
- ids.include?(@special_container2.pid).should == true
415
- ids.include?(@special_container3.pid).should == true
416
- ids.include?(@special_container4.pid).should == true
418
+ @test_object_query.bi_containers_ids.should include @container3.pid, @special_container.pid, @special_container2.pid, @special_container3.pid, @special_container4.pid
419
+
420
+ @test_object_query.bi_containers_ids.size.should == 5
417
421
  end
418
422
 
419
423
  it "should return a solr query for a bidirectional relationship" do
420
424
  expected_string = ""
421
425
  @test_object_query.bi_containers_outbound_ids.each_with_index do |id,index|
422
426
  expected_string << " OR " if index > 0
423
- expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/SpecialContainer)"
427
+ expected_string << "(id:" + id.gsub(/(:)/, '\\:') + " AND has_model_s:info\\:fedora/afmodel\\:SpecialContainer)"
424
428
  end
425
429
  expected_string << " OR "
426
- expected_string << "(#{@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound']}_s:#{@test_object_query.internal_uri.gsub(/(:)/, '\\:')} AND has_model_s:info\\:fedora/SpecialContainer)"
430
+ expected_string << "(#{@test_object_query.relationship_predicates[:inbound]['bi_special_containers_inbound']}_s:#{@test_object_query.internal_uri.gsub(/(:)/, '\\:')} AND has_model_s:info\\:fedora/afmodel\\:SpecialContainer)"
427
431
  @test_object_query.bi_special_containers_query.should == expected_string
428
432
  end
429
433
  end
@@ -436,20 +440,25 @@ describe ActiveFedora::SemanticNode do
436
440
  has_relationship "testing", :has_part
437
441
  has_relationship "testing2", :has_member
438
442
  has_relationship "testing_inbound", :has_part, :inbound=>true
443
+ attr_accessor :rels_ext
444
+ def initialize
445
+ self.rels_ext = ActiveFedora::RelsExtDatastream.new(nil, nil)
446
+ rels_ext.model = self
447
+ end
439
448
  end
440
449
 
441
450
  it 'should automatically update the relationships_by_name if relationships has changed (no refresh of relationships_by_name hash unless relationships hash has changed' do
442
451
  @test_object2 = MockSemNamedRelationships.new
443
452
  r = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_model,:object=>ActiveFedora::ContentModel.pid_from_ruby_class(MockSemNamedRelationships)})
444
- @test_object2.add_relationship(r)
453
+ @test_object2.add_relationship(r.predicate, r.object)
445
454
  #should return expected named relationships
446
- @test_object2.relationships_by_name.should == {:self=>{"testing"=>[],"testing2"=>[]},:inbound=>{"testing_inbound"=>[]}}
455
+ @test_object2.relationships_by_name.should == {:self=>{"testing"=>[],"testing2"=>[]}}
447
456
  r3 = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_part,:object=>@test_object})
448
- @test_object2.add_relationship(r3)
449
- @test_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[]},:inbound=>{"testing_inbound"=>[]}}
457
+ @test_object2.add_relationship(r3.predicate, r3.object)
458
+ @test_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[]}}
450
459
  r4 = ActiveFedora::Relationship.new({:subject=>:self,:predicate=>:has_member,:object=>"3"})
451
- @test_object2.add_relationship(r4)
452
- @test_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[r4.object]},:inbound=>{"testing_inbound"=>[]}}
460
+ @test_object2.add_relationship(r4.predicate, r4.object)
461
+ @test_object2.relationships_by_name.should == {:self=>{"testing"=>[r3.object],"testing2"=>[r4.object]}}
453
462
  end
454
463
  end
455
464
  end
@@ -1,13 +1,15 @@
1
- ENV["RAILS_ENV"] ||= 'test'
1
+ ENV["environment"] ||= 'test'
2
2
  require 'active-fedora'
3
3
  require 'spec'
4
4
 
5
+ logger.level = Logger::WARN if logger.respond_to? :level ###MediaShelf StubLogger doesn't have a level= method
6
+
5
7
  $:.unshift(File.dirname(__FILE__) + '/../lib')
6
8
  $VERBOSE=nil
7
9
 
8
10
  # This loads the Fedora and Solr config info from /config/fedora.yml
9
11
  # You can load it from a different location by passing a file path as an argument.
10
- ActiveFedora.init(File.join(File.dirname(__FILE__), "..", "config", "fedora.yml"))
12
+ ActiveFedora.init(:fedora_config_path=>File.join(File.dirname(__FILE__), "..", "config", "fedora.yml"))
11
13
 
12
14
  Spec::Runner.configure do |config|
13
15
  config.mock_with :mocha
@@ -1,5 +1,4 @@
1
1
  require File.join( File.dirname(__FILE__), "../spec_helper" )
2
- require 'equivalent-xml'
3
2
 
4
3
  # For testing Module-level methods like ActiveFedora.init
5
4
 
@@ -10,7 +9,7 @@ describe ActiveFedora do
10
9
  unstub_blacklight
11
10
  # Restore to default fedora configs
12
11
  fedora_config_path = File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml")
13
- ActiveFedora.init(:environment=>"test", :fedora_config=>fedora_config_path)
12
+ ActiveFedora.init(:environment=>"test", :fedora_config_path=>fedora_config_path)
14
13
  end
15
14
 
16
15
  before(:each) do
@@ -237,13 +236,11 @@ describe ActiveFedora do
237
236
  ActiveFedora.fedora_config_path.should eql(expected_config+'/fedora.yml')
238
237
  ActiveFedora.solr_config_path.should eql(expected_config+'/solr.yml')
239
238
  end
240
- it "overrides any other config file when a file is passed in explicitly" do
241
- ActiveFedora.init("#{@fake_rails_root}/config/fake_fedora.yml")
242
- ActiveFedora.fedora_config_path.should eql("#{@fake_rails_root}/config/fake_fedora.yml")
243
- #ActiveFedora.config_path.should eql("#{@fake_rails_root}/config/fake_fedora.yml")
239
+ it "raises an error if you pass in a string" do
240
+ lambda{ ActiveFedora.init("#{@fake_rails_root}/config/fake_fedora.yml") }.should raise_exception(ArgumentError)
244
241
  end
245
242
  it "raises an error if you pass in a non-existant config file" do
246
- lambda{ ActiveFedora.init("really_fake_fedora.yml") }.should raise_exception(ActiveFedora::ActiveFedoraConfigurationException)
243
+ lambda{ ActiveFedora.init(:fedora_config_path=>"really_fake_fedora.yml") }.should raise_exception(ActiveFedora::ActiveFedoraConfigurationException)
247
244
  end
248
245
 
249
246
  describe "within Rails" do
@@ -310,7 +307,7 @@ describe ActiveFedora do
310
307
  mock_file = mock("fedora.yml")
311
308
  File.expects(:open).returns(mock_file)
312
309
  YAML.expects(:load).returns({"test"=>{"solr"=>{"url"=>"http://127.0.0.1:8983/solr/development"}, "fedora"=>{"url"=>"http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora"}}})
313
- ActiveFedora.init("/path/to/my/files/fedora.yml")
310
+ ActiveFedora.init(:fedora_config_path => "/path/to/my/files/fedora.yml")
314
311
  ActiveFedora.predicate_config.should == "/path/to/my/files/predicate_mappings.yml"
315
312
  end
316
313
  end
@@ -342,7 +339,7 @@ describe ActiveFedora do
342
339
 
343
340
  after(:all) do
344
341
  # Restore to default fedora configs
345
- ActiveFedora.init(File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml"))
342
+ ActiveFedora.init(:fedora_config_path => File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml"))
346
343
 
347
344
  end
348
345
 
@@ -351,10 +348,6 @@ describe ActiveFedora do
351
348
  ActiveFedora.init()
352
349
  ActiveFedora.fedora.options[:url].to_s.should == "http://127.0.0.1:8983/fedora"
353
350
  end
354
- it "should load the passed config if explicit config passed in as a string" do
355
- ActiveFedora.init('./spec/fixtures/rails_root/config/fedora.yml')
356
- ActiveFedora.fedora_config[:url].should == "http://fedoraAdmin:fedoraAdmin@testhost.com:8983/fedora"
357
- end
358
351
  it "should load the passed config if explicit config passed in as a string" do
359
352
  ActiveFedora.init(:fedora_config_path=>'./spec/fixtures/rails_root/config/fedora.yml')
360
353
  ActiveFedora.fedora_config[:url].should == "http://fedoraAdmin:fedoraAdmin@testhost.com:8983/fedora"