active-fedora 5.7.1 → 6.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +1 -1
- data/Gemfile +2 -1
- data/History.txt +0 -14
- data/Rakefile +1 -2
- data/active-fedora.gemspec +2 -2
- data/lib/active_fedora.rb +1 -16
- data/lib/active_fedora/associations.rb +8 -11
- data/lib/active_fedora/associations/association_collection.rb +2 -4
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +3 -12
- data/lib/active_fedora/associations/has_many_association.rb +0 -4
- data/lib/active_fedora/base.rb +6 -6
- data/lib/active_fedora/config.rb +0 -7
- data/lib/active_fedora/datastream.rb +0 -37
- data/lib/active_fedora/datastream_collections.rb +0 -10
- data/lib/active_fedora/datastreams.rb +0 -17
- data/lib/active_fedora/digital_object.rb +1 -1
- data/lib/active_fedora/file_configurator.rb +0 -22
- data/lib/active_fedora/fixture_loader.rb +1 -1
- data/lib/active_fedora/nokogiri_datastream.rb +9 -51
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
- data/lib/active_fedora/querying.rb +8 -4
- data/lib/active_fedora/rdf_datastream.rb +10 -9
- data/lib/active_fedora/rdf_node.rb +1 -1
- data/lib/active_fedora/rdf_node/term_proxy.rb +9 -5
- data/lib/active_fedora/relation.rb +1 -1
- data/lib/active_fedora/rels_ext_datastream.rb +1 -8
- data/lib/active_fedora/semantic_node.rb +0 -35
- data/lib/active_fedora/simple_datastream.rb +1 -1
- data/lib/active_fedora/solr_service.rb +6 -8
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora_dev.rake +11 -3
- data/solr/conf/schema.xml +10 -1
- data/spec/integration/base_spec.rb +2 -347
- data/spec/integration/complex_rdf_datastream_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +1 -9
- data/spec/integration/ntriples_datastream_spec.rb +4 -4
- data/spec/integration/om_datastream_spec.rb +2 -1
- data/spec/integration/rels_ext_datastream_spec.rb +1 -89
- data/spec/integration/scoped_query_spec.rb +4 -4
- data/spec/samples/hydra-mods_article_datastream.rb +2 -2
- data/spec/spec_helper.rb +3 -0
- data/spec/unit/base_spec.rb +7 -81
- data/spec/unit/datastream_spec.rb +0 -25
- data/spec/unit/has_many_collection_spec.rb +2 -27
- data/spec/unit/ntriples_datastream_spec.rb +28 -39
- data/spec/unit/om_datastream_spec.rb +13 -13
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/query_spec.rb +1 -24
- data/spec/unit/semantic_node_spec.rb +0 -2
- data/spec/unit/simple_datastream_spec.rb +2 -2
- data/spec/unit/solr_config_options_spec.rb +1 -1
- metadata +76 -57
- checksums.yaml +0 -7
- data/.travis.yml +0 -8
- data/lib/active_fedora/file_management.rb +0 -81
- data/lib/active_fedora/metadata_datastream_helper.rb +0 -43
- data/lib/active_fedora/named_relationships.rb +0 -99
- data/lib/active_fedora/relationships.rb +0 -663
- data/spec/integration/base_file_management_spec.rb +0 -24
- data/spec/integration/has_many_associations_spec.rb +0 -64
- data/spec/integration/metadata_datastream_helper_spec.rb +0 -100
- data/spec/integration/semantic_node_spec.rb +0 -457
- data/spec/unit/base_file_management_spec.rb +0 -95
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +0 -59
- data/spec/unit/relationships_spec.rb +0 -871
@@ -68,15 +68,15 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
68
68
|
subject.date_uploaded = Date.parse('2012-11-02')
|
69
69
|
subject.date_uploaded.first.should be_kind_of Date
|
70
70
|
solr_document = subject.to_solr
|
71
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', :
|
71
|
+
solr_document[ActiveFedora::SolrService.solr_name('rdf__date_uploaded', type: :date)].should == ['2012-11-02T00:00:00Z']
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should produce a solr document" do
|
75
75
|
@subject = RdfTest.new(title: "War and Peace")
|
76
76
|
solr_document = @subject.to_solr
|
77
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :
|
78
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :
|
79
|
-
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :
|
77
|
+
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :displayable)].should == ["War and Peace"]
|
78
|
+
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', :facetable)].should == ["War and Peace"]
|
79
|
+
solr_document[ActiveFedora::SolrService.solr_name('rdf__title', type: :string)].should == ["War and Peace"]
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should set and recall values" do
|
@@ -26,6 +26,7 @@ describe ActiveFedora::OmDatastream do
|
|
26
26
|
@test_object = HydrangeaArticle2.find(@pid)
|
27
27
|
|
28
28
|
@test_object.descMetadata.ng_xml = @test_object.descMetadata.ng_xml
|
29
|
+
|
29
30
|
@test_object.descMetadata.should_not be_changed
|
30
31
|
end
|
31
32
|
|
@@ -118,7 +119,7 @@ describe ActiveFedora::OmDatastream do
|
|
118
119
|
|
119
120
|
end
|
120
121
|
it "should solrize terms with :type=>'date' to *_dt solr terms" do
|
121
|
-
@test_object.to_solr[ActiveFedora::SolrService.solr_name('mods_journal_issue_publication_date', :date)].should == ['2012-11-02T00:00:00Z']
|
122
|
+
@test_object.to_solr[ActiveFedora::SolrService.solr_name('mods_journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
|
122
123
|
end
|
123
124
|
end
|
124
125
|
end
|
@@ -74,95 +74,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
74
74
|
# make sure that _something_ was actually added to the object's relationships hash
|
75
75
|
@test_object.ids_for_outbound(:is_member_of).size.should == 1
|
76
76
|
new_rels = ActiveFedora::Base.find(@test_object.pid).relationships
|
77
|
-
|
78
|
-
new_rels.to_a.each do |stmt|
|
79
|
-
@test_object.relationships.should have_statement(stmt)
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
@test_object.relationships.to_a.each do |stmt|
|
84
|
-
new_rels.should have_statement(stmt)
|
85
|
-
end
|
86
|
-
|
87
|
-
# new_rels.should == @test_object.relationships
|
77
|
+
new_rels.should == @test_object.relationships
|
88
78
|
end
|
89
79
|
|
90
|
-
describe '#from_solr' do
|
91
|
-
before(:all) do
|
92
|
-
@behavior = ActiveFedora::Relationships.deprecation_behavior
|
93
|
-
@c_behavior = ActiveFedora::Relationships::ClassMethods.deprecation_behavior
|
94
|
-
ActiveFedora::Relationships.deprecation_behavior = :silence
|
95
|
-
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = :silence
|
96
|
-
end
|
97
|
-
|
98
|
-
after :all do
|
99
|
-
ActiveFedora::Relationships.deprecation_behavior = @behavior
|
100
|
-
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = @c_behavior
|
101
|
-
end
|
102
|
-
before do
|
103
|
-
class MockAFRelsSolr < ActiveFedora::Base
|
104
|
-
include ActiveFedora::FileManagement
|
105
|
-
has_relationship "testing", :has_part, :type=>MockAFRelsSolr
|
106
|
-
has_relationship "testing2", :has_member, :type=>MockAFRelsSolr
|
107
|
-
has_relationship "testing_inbound", :has_part, :type=>MockAFRelsSolr, :inbound=>true
|
108
|
-
has_relationship "testing_inbound2", :has_member, :type=>MockAFRelsSolr, :inbound=>true
|
109
|
-
end
|
110
|
-
end
|
111
|
-
it "should respond_to from_solr" do
|
112
|
-
@test_datastream.respond_to?(:from_solr).should be_true
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'should populate the relationships hash based on data in solr only for any possible fedora predicates' do
|
116
|
-
@test_object2 = MockAFRelsSolr.new
|
117
|
-
#@test_object2.new_object = true
|
118
|
-
@test_object2.save
|
119
|
-
@test_object3 = MockAFRelsSolr.new
|
120
|
-
#@test_object3.new_object = true
|
121
|
-
@test_object3.save
|
122
|
-
@test_object4 = MockAFRelsSolr.new
|
123
|
-
#@test_object4.new_object = true
|
124
|
-
@test_object4.save
|
125
|
-
@test_object5 = MockAFRelsSolr.new
|
126
|
-
#@test_object5.new_object = true
|
127
|
-
@test_object5.save
|
128
|
-
#append to named relationship 'testing'
|
129
|
-
@test_object2.testing_append(@test_object3)
|
130
|
-
@test_object2.testing2_append(@test_object4)
|
131
|
-
@test_object5.testing_append(@test_object2)
|
132
|
-
@test_object5.testing2_append(@test_object3)
|
133
|
-
@test_object2.save
|
134
|
-
@test_object5.save
|
135
|
-
model_rel = MockAFRelsSolr.to_class_uri
|
136
|
-
#check inbound correct, testing goes to :has_part and testing2 goes to :has_member
|
137
|
-
#get solr doc for @test_object2
|
138
|
-
solr_doc = MockAFRelsSolr.find_with_conditions(:id=>@test_object2.pid).first
|
139
|
-
test_from_solr_object2 = MockAFRelsSolr.new
|
140
|
-
test_from_solr_object2.rels_ext.from_solr(solr_doc)
|
141
|
-
solr_doc = MockAFRelsSolr.find_with_conditions(:id=>@test_object3.pid).first
|
142
|
-
test_from_solr_object3 = MockAFRelsSolr.new
|
143
|
-
test_from_solr_object3.rels_ext.from_solr(solr_doc)
|
144
|
-
solr_doc = MockAFRelsSolr.find_with_conditions(:id=>@test_object4.pid).first
|
145
|
-
test_from_solr_object4 = MockAFRelsSolr.new
|
146
|
-
test_from_solr_object4.rels_ext.from_solr(solr_doc)
|
147
|
-
solr_doc = MockAFRelsSolr.find_with_conditions(:id=>@test_object5.pid).first
|
148
|
-
test_from_solr_object5 = MockAFRelsSolr.new
|
149
|
-
test_from_solr_object5.rels_ext.from_solr(solr_doc)
|
150
|
-
|
151
|
-
test_from_solr_object2.object_relations[:has_part].should include @test_object3.internal_uri
|
152
|
-
test_from_solr_object2.object_relations[:has_member].should include @test_object4.internal_uri
|
153
|
-
test_from_solr_object2.object_relations[:has_model].should include model_rel
|
154
|
-
|
155
|
-
test_from_solr_object2.relationships_by_name.should == {:self=>{"testing"=>[@test_object3.internal_uri],"testing2"=>[@test_object4.internal_uri], "collection_members"=>[], "part_of"=>[], "parts_outbound"=>[@test_object3.internal_uri]}}
|
156
|
-
test_from_solr_object3.object_relations[:has_model].should include model_rel
|
157
|
-
test_from_solr_object3.relationships_by_name.should == {:self=>{"testing2"=>[], "collection_members"=>[], "part_of"=>[], "testing"=>[], "parts_outbound"=>[]}}
|
158
|
-
test_from_solr_object4.object_relations[:has_model].should include model_rel
|
159
|
-
test_from_solr_object4.relationships_by_name.should == {:self=>{"testing2"=>[], "collection_members"=>[], "part_of"=>[], "testing"=>[], "parts_outbound"=>[]}}
|
160
|
-
|
161
|
-
test_from_solr_object5.object_relations[:has_model].should include model_rel
|
162
|
-
test_from_solr_object5.object_relations[:has_part].should include @test_object2.internal_uri
|
163
|
-
test_from_solr_object5.object_relations[:has_member].should include @test_object3.internal_uri
|
164
|
-
|
165
|
-
test_from_solr_object5.relationships_by_name.should == {:self=>{"testing2"=>[@test_object3.internal_uri], "collection_members"=>[], "part_of"=>[], "testing"=>[@test_object2.internal_uri], "parts_outbound"=>[@test_object2.internal_uri]}}
|
166
|
-
end
|
167
|
-
end
|
168
80
|
end
|
@@ -15,7 +15,7 @@ describe ActiveFedora::Model do
|
|
15
15
|
|
16
16
|
def to_solr(doc = {})
|
17
17
|
doc = super
|
18
|
-
doc[ActiveFedora::SolrService.solr_name('foo', :
|
18
|
+
doc[ActiveFedora::SolrService.solr_name('foo', :sortable)] = doc[ActiveFedora::SolrService.solr_name('foo', type: :string)]
|
19
19
|
doc
|
20
20
|
end
|
21
21
|
|
@@ -71,18 +71,18 @@ describe ActiveFedora::Model do
|
|
71
71
|
@test_instance3.delete
|
72
72
|
end
|
73
73
|
it "should query" do
|
74
|
-
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', :
|
74
|
+
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta').should == [@test_instance1]
|
75
75
|
ModelIntegrationSpec::Basic.where('foo' => 'Beta').should == [@test_instance1]
|
76
76
|
end
|
77
77
|
it "should order" do
|
78
|
-
ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :
|
78
|
+
ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').should == [@test_instance2, @test_instance1, @test_instance3]
|
79
79
|
end
|
80
80
|
it "should limit" do
|
81
81
|
ModelIntegrationSpec::Basic.limit(1).should == [@test_instance1]
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should chain them" do
|
85
|
-
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', :
|
85
|
+
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1).should == [@test_instance2]
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -508,8 +508,8 @@ module Hydra
|
|
508
508
|
def to_solr(solr_doc=Hash.new)
|
509
509
|
super(solr_doc)
|
510
510
|
|
511
|
-
::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('object_type', :
|
512
|
-
::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('mods_journal_title_info', :
|
511
|
+
::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('object_type', :facetable), "Article")
|
512
|
+
::Solrizer::Extractor.insert_solr_field_value(solr_doc, Solrizer.default_field_mapper.solr_name('mods_journal_title_info', :facetable), "Unknown") if solr_doc["mods_journal_title_info_facet"].nil?
|
513
513
|
|
514
514
|
solr_doc
|
515
515
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/base_spec.rb
CHANGED
@@ -392,16 +392,16 @@ describe ActiveFedora::Base do
|
|
392
392
|
@test_object.should_receive(:create_date).and_return("2012-03-04T03:12:02Z")
|
393
393
|
@test_object.should_receive(:modified_date).and_return("2012-03-07T03:12:02Z")
|
394
394
|
solr_doc = @test_object.to_solr
|
395
|
-
solr_doc[ActiveFedora::SolrService.solr_name("system_create", :
|
396
|
-
solr_doc[ActiveFedora::SolrService.solr_name("system_modified", :
|
395
|
+
solr_doc[ActiveFedora::SolrService.solr_name("system_create", type: :date)].should eql("2012-03-04T03:12:02Z")
|
396
|
+
solr_doc[ActiveFedora::SolrService.solr_name("system_modified", type: :date)].should eql("2012-03-07T03:12:02Z")
|
397
397
|
solr_doc[:id].should eql("#{@test_object.pid}")
|
398
398
|
end
|
399
399
|
|
400
400
|
it "should omit base metadata and RELS-EXT if :model_only==true" do
|
401
401
|
@test_object.add_relationship(:has_part, "foo", true)
|
402
402
|
solr_doc = @test_object.to_solr(Hash.new, :model_only => true)
|
403
|
-
solr_doc[ActiveFedora::SolrService.solr_name("system_create", :
|
404
|
-
solr_doc[ActiveFedora::SolrService.solr_name("system_modified", :
|
403
|
+
solr_doc[ActiveFedora::SolrService.solr_name("system_create", type: :date)].should be_nil
|
404
|
+
solr_doc[ActiveFedora::SolrService.solr_name("system_modified", type: :date)].should be_nil
|
405
405
|
solr_doc["id"].should be_nil
|
406
406
|
solr_doc[ActiveFedora::SolrService.solr_name("has_part", :symbol)].should be_nil
|
407
407
|
end
|
@@ -540,87 +540,13 @@ pending "This is broken, and deprecated. I don't want to fix it - jcoyne"
|
|
540
540
|
end
|
541
541
|
|
542
542
|
describe '#relationships_by_name' do
|
543
|
-
before(:all) do
|
544
|
-
@behavior = ActiveFedora::Relationships.deprecation_behavior
|
545
|
-
@c_behavior = ActiveFedora::Relationships::ClassMethods.deprecation_behavior
|
546
|
-
ActiveFedora::Relationships.deprecation_behavior = :silence
|
547
|
-
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = :silence
|
548
|
-
end
|
549
|
-
|
550
|
-
after :all do
|
551
|
-
ActiveFedora::Relationships.deprecation_behavior = @behavior
|
552
|
-
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = @c_behavior
|
553
|
-
end
|
554
|
-
|
555
543
|
before do
|
556
544
|
class MockNamedRelationships < ActiveFedora::Base
|
557
|
-
|
558
|
-
has_relationship "
|
559
|
-
has_relationship "
|
560
|
-
has_relationship "testing_inbound", :has_part, :type=>ActiveFedora::Base, :inbound=>true
|
545
|
+
# has_relationship "testing", :has_part, :type=>ActiveFedora::Base
|
546
|
+
# has_relationship "testing2", :has_member, :type=>ActiveFedora::Base
|
547
|
+
# has_relationship "testing_inbound", :has_part, :type=>ActiveFedora::Base, :inbound=>true
|
561
548
|
end
|
562
549
|
end
|
563
|
-
|
564
|
-
it 'should return current relationships by name' do
|
565
|
-
next_pid = increment_pid.to_s
|
566
|
-
ActiveFedora::Base.stub(:assign_pid).and_return(next_pid)
|
567
|
-
stub_get(next_pid)
|
568
|
-
@test_object2 = MockNamedRelationships.new
|
569
|
-
@test_object2.add_relationship(:has_model, MockNamedRelationships.to_class_uri)
|
570
|
-
@test_object.add_relationship(:has_model, ActiveFedora::Base.to_class_uri)
|
571
|
-
#should return expected named relationships
|
572
|
-
@test_object2.relationships_by_name
|
573
|
-
@test_object2.relationships_by_name[:self]["testing"].should == []
|
574
|
-
@test_object2.relationships_by_name[:self]["testing2"].should == []
|
575
|
-
@test_object2.relationships_by_name[:self]["parts_outbound"].should == []
|
576
|
-
@test_object2.add_relationship_by_name("testing",@test_object)
|
577
|
-
# @test_object2.relationships_by_name.should == {:self=>{"testing"=>[@test_object.internal_uri],"testing2"=>[],"part_of"=>[], "parts_outbound"=>[@test_object.internal_uri], "collection_members"=>[]}}
|
578
|
-
|
579
|
-
@test_object2.relationships_by_name[:self]["testing"].should == [@test_object.internal_uri]
|
580
|
-
@test_object2.relationships_by_name[:self]["testing2"].should == []
|
581
|
-
@test_object2.relationships_by_name[:self]["parts_outbound"].should == [@test_object.internal_uri]
|
582
|
-
end
|
583
|
-
end
|
584
|
-
|
585
|
-
|
586
|
-
describe '#create_relationship_name_methods' do
|
587
|
-
before(:all) do
|
588
|
-
@behavior = ActiveFedora::Relationships.deprecation_behavior
|
589
|
-
@c_behavior = ActiveFedora::Relationships::ClassMethods.deprecation_behavior
|
590
|
-
ActiveFedora::Relationships.deprecation_behavior = :silence
|
591
|
-
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = :silence
|
592
|
-
end
|
593
|
-
|
594
|
-
after :all do
|
595
|
-
ActiveFedora::Relationships.deprecation_behavior = @behavior
|
596
|
-
ActiveFedora::Relationships::ClassMethods.deprecation_behavior = @c_behavior
|
597
|
-
end
|
598
|
-
|
599
|
-
before do
|
600
|
-
class MockCreateNamedRelationshipMethodsBase < ActiveFedora::Base
|
601
|
-
include ActiveFedora::Relationships
|
602
|
-
register_relationship_desc :self, "testing", :is_part_of, :type=>ActiveFedora::Base
|
603
|
-
create_relationship_name_methods "testing"
|
604
|
-
end
|
605
|
-
end
|
606
|
-
|
607
|
-
it 'should append and remove using helper methods for each outbound relationship' do
|
608
|
-
next_pid = increment_pid.to_s
|
609
|
-
ActiveFedora::Base.stub(:assign_pid).and_return(next_pid)
|
610
|
-
stub_get(next_pid)
|
611
|
-
@test_object2 = MockCreateNamedRelationshipMethodsBase.new
|
612
|
-
@test_object2.should respond_to(:testing_append)
|
613
|
-
@test_object2.should respond_to(:testing_remove)
|
614
|
-
#test executing each one to make sure code added is correct
|
615
|
-
model_pid =ActiveFedora::Base.to_class_uri
|
616
|
-
@test_object.add_relationship(:has_model,model_pid)
|
617
|
-
@test_object2.add_relationship(:has_model,model_pid)
|
618
|
-
@test_object2.testing_append(@test_object)
|
619
|
-
#create relationship to access generate_uri method for an object
|
620
|
-
@test_object2.relationships_by_name[:self]["testing"].should == [@test_object.internal_uri]
|
621
|
-
@test_object2.testing_remove(@test_object)
|
622
|
-
@test_object2.relationships_by_name[:self]["testing"].should == []
|
623
|
-
end
|
624
550
|
end
|
625
551
|
|
626
552
|
describe ".solrize_relationships" do
|
@@ -107,29 +107,4 @@ describe ActiveFedora::Datastream do
|
|
107
107
|
@test_datastream.size.should be_nil
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
111
|
-
describe ".from_xml" do
|
112
|
-
it "should load a FOXML datastream node" do
|
113
|
-
ds_xml = <<-EOS
|
114
|
-
<foxml:datastream ID="DC" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true" xmlns:foxml="info:fedora/fedora-system:def/foxml#">
|
115
|
-
<foxml:xmlContent>
|
116
|
-
<datastream ID="DC" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
117
|
-
<datastreamVersion ID="DC.1" LABEL="Dublin Core Record for this object" CREATED="2011-09-28T22:50:18.626Z" MIMETYPE="text/xml" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/" SIZE="526">
|
118
|
-
<xmlContent>
|
119
|
-
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
|
120
|
-
<dc:title>Title</dc:title>
|
121
|
-
<dc:identifier>0123456789</dc:identifier>
|
122
|
-
</oai_dc:dc>
|
123
|
-
</xmlContent>
|
124
|
-
</datastreamVersion>
|
125
|
-
</datastream>
|
126
|
-
</foxml:xmlContent>
|
127
|
-
</foxml:datastream>
|
128
|
-
EOS
|
129
|
-
ds_node = Nokogiri::XML(ds_xml).root
|
130
|
-
ds = ActiveFedora::Datastream.from_xml(@test_datastream, ds_node)
|
131
|
-
ds.should be_a(ActiveFedora::Datastream)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
110
|
end
|
@@ -1,35 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Associations::HasManyAssociation do
|
4
|
-
it "should call add_relationship" do
|
5
|
-
subject = stub("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a')
|
6
|
-
predicate = stub(:klass => mock.class, :options=>{:property=>'predicate'}, :class_name=> nil)
|
7
|
-
ActiveFedora::SolrService.stub(:query).and_return([])
|
8
|
-
ac = ActiveFedora::Associations::HasManyAssociation.new(subject, predicate)
|
9
|
-
object = stub("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
10
|
-
|
11
|
-
object.should_receive(:add_relationship).with('predicate', subject)
|
12
|
-
|
13
|
-
ac << object
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should call remove_relationship" do
|
18
|
-
subject = stub("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a')
|
19
|
-
predicate = stub(:klass => mock.class, :options=>{:property=>'predicate'}, :class_name=> nil)
|
20
|
-
ActiveFedora::SolrService.stub(:query).and_return([])
|
21
|
-
ac = ActiveFedora::Associations::HasManyAssociation.new(subject, predicate)
|
22
|
-
object = stub("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
23
|
-
|
24
|
-
object.should_receive(:remove_relationship).with('predicate', subject)
|
25
|
-
|
26
|
-
ac.delete(object)
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
4
|
it "should be able to replace the collection" do
|
31
5
|
@owner = stub(:new_record? => false, :to_ary => nil, :internal_uri => 'info:fedora/changeme:99')
|
32
|
-
@reflection = stub(:klass => mock.class, :options=>{:property=>'predicate'}
|
6
|
+
@reflection = stub(:klass => mock.class, :options=>{:property=>'predicate'})
|
7
|
+
#ac = ActiveFedora::Associations::AssociationCollection.new(@owner, @reflection)
|
33
8
|
ac = ActiveFedora::Associations::HasManyAssociation.new(@owner, @reflection)
|
34
9
|
@target = [stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true), stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true), stub(:to_ary => nil, :new_record? => false, :remove_relationship=>true)]
|
35
10
|
ac.target = @target
|
@@ -9,7 +9,6 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
9
9
|
map.title(:in => RDF::DC)
|
10
10
|
map.publisher(:in => RDF::DC)
|
11
11
|
map.creator(:in => RDF::DC)
|
12
|
-
map.educationLevel(:in => RDF::DC)
|
13
12
|
map.based_near(:in => RDF::FOAF)
|
14
13
|
map.related_url(:to => "seeAlso", :in => RDF::RDFS)
|
15
14
|
end
|
@@ -40,16 +39,6 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
40
39
|
@subject.related_url.should == ["http://google.com/"]
|
41
40
|
end
|
42
41
|
|
43
|
-
it "should be able to call enumerable methods on the fields" do
|
44
|
-
@subject.title.join(', ').should == "Title of work"
|
45
|
-
@subject.title.count.should == 1
|
46
|
-
@subject.title.size.should == 1
|
47
|
-
@subject.title[0].should == "Title of work"
|
48
|
-
@subject.title.to_a.should == ["Title of work"]
|
49
|
-
val = []
|
50
|
-
@subject.title.each_with_index {|v, i| val << "#{i}. #{v}"}
|
51
|
-
val.should == ["0. Title of work"]
|
52
|
-
end
|
53
42
|
|
54
43
|
it "should return fields that are not TermProxies" do
|
55
44
|
@subject.created.should be_kind_of Array
|
@@ -184,19 +173,19 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
184
173
|
end
|
185
174
|
it "should iterate through @fields hash" do
|
186
175
|
solr_doc = @subject.to_solr
|
187
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :
|
188
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :
|
189
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :
|
190
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :
|
191
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :
|
192
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :
|
193
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :
|
194
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :
|
195
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :
|
196
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :
|
197
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :
|
198
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :
|
199
|
-
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", :
|
176
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", type: :string)].should == ["publisher1"]
|
177
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :sortable)].should == ["publisher1"]
|
178
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :displayable)].should == ["publisher1"]
|
179
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :facetable)].should == ["publisher1"]
|
180
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", type: :string)].should == ["coverage1", "coverage2"]
|
181
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :displayable)].should == ["coverage1", "coverage2"]
|
182
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :facetable)].should == ["coverage1", "coverage2"]
|
183
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :sortable)].should == ["2009-10-10"]
|
184
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__created", :displayable)].should == ["2009-10-10"]
|
185
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", type: :string)].should == ["fake-title"]
|
186
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :sortable)].should == ["fake-title"]
|
187
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__title", :displayable)].should == ["fake-title"]
|
188
|
+
solr_doc[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string)].should == ["http://example.org/"]
|
200
189
|
end
|
201
190
|
|
202
191
|
describe "with an actual object" do
|
@@ -240,25 +229,25 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
240
229
|
end
|
241
230
|
describe ".to_solr()" do
|
242
231
|
it "should return the right fields" do
|
243
|
-
@obj.to_solr.keys.should include(ActiveFedora::SolrService.solr_name("solr_rdf__related_url", :
|
244
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :
|
245
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :
|
246
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :
|
247
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :
|
248
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__created", :
|
249
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__created", :
|
250
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__title", :
|
251
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__title", :
|
252
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__title", :
|
253
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :
|
254
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :
|
255
|
-
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :
|
232
|
+
@obj.to_solr.keys.should include(ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string),
|
233
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", type: :string),
|
234
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :sortable),
|
235
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :displayable),
|
236
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__publisher", :facetable),
|
237
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__created", :sortable),
|
238
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__created", :displayable),
|
239
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__title", type: :string),
|
240
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__title", :sortable),
|
241
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__title", :displayable),
|
242
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", type: :string),
|
243
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :facetable),
|
244
|
+
ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :displayable))
|
256
245
|
|
257
246
|
end
|
258
247
|
|
259
248
|
it "should return the right values" do
|
260
|
-
@obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", :
|
261
|
-
@obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", :
|
249
|
+
@obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__related_url", type: :string)].should == ["http://example.org/blogtastic/"]
|
250
|
+
@obj.to_solr[ActiveFedora::SolrService.solr_name("solr_rdf__based_near", type: :string)].should == ["Tacoma, WA","Renton, WA"]
|
262
251
|
end
|
263
252
|
end
|
264
253
|
end
|