active-fedora 3.3.2 → 4.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +21 -22
- data/History.txt +9 -0
- data/README.textile +1 -1
- data/TODO +1 -0
- data/active-fedora.gemspec +3 -3
- data/config/fedora.yml +9 -3
- data/lib/active_fedora.rb +43 -33
- data/lib/active_fedora/base.rb +80 -31
- data/lib/active_fedora/config.rb +38 -0
- data/lib/active_fedora/content_model.rb +0 -6
- data/lib/active_fedora/datastream.rb +22 -0
- data/lib/active_fedora/delegating.rb +24 -25
- data/lib/active_fedora/digital_object.rb +2 -1
- data/lib/active_fedora/file_management.rb +1 -0
- data/lib/active_fedora/fixture_exporter.rb +1 -1
- data/lib/active_fedora/fixture_loader.rb +3 -3
- data/lib/active_fedora/metadata_datastream.rb +6 -0
- data/lib/active_fedora/model.rb +24 -5
- data/lib/active_fedora/nokogiri_datastream.rb +1 -0
- data/lib/active_fedora/ntriples_rdf_datastream.rb +0 -1
- data/lib/active_fedora/persistence.rb +2 -1
- data/lib/active_fedora/predicates.rb +27 -27
- data/lib/active_fedora/rdf_datastream.rb +104 -30
- data/lib/active_fedora/rels_ext_datastream.rb +14 -10
- data/lib/active_fedora/rubydora_connection.rb +4 -27
- data/lib/active_fedora/service_definitions.rb +2 -3
- data/lib/active_fedora/solr_digital_object.rb +22 -8
- data/lib/active_fedora/solr_service.rb +1 -1
- data/lib/active_fedora/unsaved_digital_object.rb +1 -4
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora.rake +6 -6
- data/lib/tasks/active_fedora_dev.rake +0 -1
- data/spec/fixtures/mixed_rdf_descMetadata.nt +6 -0
- data/spec/fixtures/rails_root/config/fedora.yml +3 -1
- data/spec/fixtures/sharded_fedora.yml +11 -0
- data/spec/integration/base_file_management_spec.rb +6 -3
- data/spec/integration/base_find_by_fields_spec.rb +15 -16
- data/spec/integration/base_spec.rb +11 -178
- data/spec/integration/datastream_collections_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +1 -2
- data/spec/integration/model_spec.rb +8 -9
- data/spec/integration/mods_article_integration_spec.rb +1 -1
- data/spec/integration/nokogiri_datastream_spec.rb +1 -1
- data/spec/integration/ntriples_datastream_spec.rb +80 -0
- data/spec/integration/rels_ext_datastream_spec.rb +0 -1
- data/spec/integration/semantic_node_spec.rb +18 -26
- data/spec/integration/solr_service_spec.rb +51 -1
- data/{lib/active_fedora → spec}/samples/hydra-mods_article_datastream.rb +0 -0
- data/{lib/active_fedora → spec}/samples/hydra-rights_metadata_datastream.rb +0 -0
- data/{lib/active_fedora → spec}/samples/marpa-dc_datastream.rb +0 -0
- data/spec/samples/models/hydrangea_article.rb +2 -2
- data/spec/samples/samples.rb +2 -0
- data/{lib/active_fedora → spec}/samples/special_thing.rb +3 -3
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/active_fedora_spec.rb +17 -50
- data/spec/unit/base_extra_spec.rb +4 -0
- data/spec/unit/base_file_management_spec.rb +5 -2
- data/spec/unit/base_spec.rb +692 -628
- data/spec/unit/config_spec.rb +19 -0
- data/spec/unit/content_model_spec.rb +1 -24
- data/spec/unit/datastream_collections_spec.rb +11 -14
- data/spec/unit/datastreams_spec.rb +49 -54
- data/spec/unit/model_spec.rb +24 -53
- data/spec/unit/nokogiri_datastream_spec.rb +6 -1
- data/spec/unit/ntriples_datastream_spec.rb +73 -0
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/relationships_spec.rb +6 -3
- data/spec/unit/rels_ext_datastream_spec.rb +19 -0
- data/spec/unit/rubydora_connection_spec.rb +2 -56
- data/spec/unit/solr_service_spec.rb +3 -1
- data/spec/unit/unsaved_digital_object_spec.rb +2 -2
- metadata +46 -33
- data/lib/active_fedora/dcrdf_datastream.rb +0 -11
- data/lib/active_fedora/relationship.rb +0 -47
- data/lib/active_fedora/samples.rb +0 -3
- data/spec/integration/dc_rdf_datastream_spec.rb +0 -24
- data/spec/unit/dc_rdf_datastream_spec.rb +0 -50
- data/spec/unit/relationship_spec.rb +0 -92
@@ -2,8 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::DatastreamCollections do
|
4
4
|
before(:all) do
|
5
|
-
ActiveSupport::Deprecation.expects(:warn).with("Deprecation: DatastreamCollections will not be included by default in the next version. To use has_datastream add 'include ActiveFedora::DatastreamCollections' to your model")
|
6
5
|
class MockAFBaseDatastream < ActiveFedora::Base
|
6
|
+
include ActiveFedora::DatastreamCollections
|
7
7
|
has_datastream :name=>"thumbnail",:prefix => "THUMB", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
|
8
8
|
has_datastream :name=>"high", :type=>ActiveFedora::Datastream, :mimeType=>"image/jpeg", :controlGroup=>'M'
|
9
9
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'rexml/document'
|
3
|
-
require File.join(File.dirname(__FILE__), "../..", "lib/active_fedora/samples", 'hydra-mods_article_datastream')
|
4
3
|
|
5
4
|
include ActiveFedora
|
6
5
|
|
@@ -8,7 +7,7 @@ describe ActiveFedora::Base do
|
|
8
7
|
|
9
8
|
before(:all) do
|
10
9
|
class OralHistory < ActiveFedora::Base
|
11
|
-
|
10
|
+
include ActiveFedora::Relationships
|
12
11
|
|
13
12
|
# Imitating DataMapper ...
|
14
13
|
|
@@ -1,9 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'active_fedora'
|
4
|
-
require 'active_fedora/model'
|
5
|
-
require "rexml/document"
|
6
|
-
require 'mocha'
|
2
|
+
require 'spec/samples/models/hydrangea_article'
|
7
3
|
|
8
4
|
include ActiveFedora::Model
|
9
5
|
include Mocha::API
|
@@ -45,12 +41,15 @@ describe ActiveFedora::Model do
|
|
45
41
|
end
|
46
42
|
end
|
47
43
|
end
|
44
|
+
|
45
|
+
describe "#find_document with a valid pid" do
|
46
|
+
subject { ActiveFedora::Base.find_document('hydrangea:fixture_mods_article1') }
|
47
|
+
it { should be_instance_of HydrangeaArticle}
|
48
|
+
end
|
48
49
|
|
49
|
-
describe '#
|
50
|
-
|
50
|
+
describe '#load_instance' do
|
51
51
|
it "should return an object of the given Model whose inner object is nil" do
|
52
|
-
|
53
|
-
result = ActiveFedora::RubydoraConnection.instance.find_model(@test_instance.pid, ModelIntegrationSpec::Basic)
|
52
|
+
result = ModelIntegrationSpec::Basic.load_instance(@test_instance.pid)
|
54
53
|
result.class.should == ModelIntegrationSpec::Basic
|
55
54
|
result.inner_object.new?.should be_false
|
56
55
|
end
|
@@ -4,7 +4,7 @@ describe ActiveFedora::Base do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
class HydrangeaArticle < ActiveFedora::Base
|
7
|
-
|
7
|
+
include ActiveFedora::Relationships
|
8
8
|
has_relationship "parts", :is_part_of, :inbound => true
|
9
9
|
|
10
10
|
# Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
|
@@ -6,7 +6,7 @@ describe ActiveFedora::NokogiriDatastream do
|
|
6
6
|
before(:all) do
|
7
7
|
class HydrangeaArticle2 < ActiveFedora::Base
|
8
8
|
|
9
|
-
has_relationship "parts", :is_part_of, :inbound => true
|
9
|
+
#has_relationship "parts", :is_part_of, :inbound => true
|
10
10
|
|
11
11
|
# Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
|
12
12
|
# has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::NtriplesRDFDatastream do
|
4
|
+
before do
|
5
|
+
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
6
|
+
map_predicates do |map|
|
7
|
+
map.title(:in => RDF::DC)
|
8
|
+
map.part(:to => "hasPart", :in => RDF::DC)
|
9
|
+
map.based_near(:in => RDF::FOAF)
|
10
|
+
map.related_url(:to => "seeAlso", :in => RDF::RDFS)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
class RdfTest < ActiveFedora::Base
|
14
|
+
has_metadata :name=>'rdf', :type=>MyDatastream
|
15
|
+
delegate :based_near, :to=>'rdf'
|
16
|
+
delegate :related_url, :to=>'rdf'
|
17
|
+
delegate :part, :to=>'rdf'
|
18
|
+
delegate :title, :to=>'rdf', :unique=>true
|
19
|
+
end
|
20
|
+
@subject = RdfTest.new
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
Object.send(:remove_const, :RdfTest)
|
25
|
+
Object.send(:remove_const, :MyDatastream)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set and recall values" do
|
29
|
+
@subject.title = 'War and Peace'
|
30
|
+
@subject.based_near = "Moscow, Russia"
|
31
|
+
@subject.related_url = "http://en.wikipedia.org/wiki/War_and_Peace"
|
32
|
+
@subject.part = "this is a part"
|
33
|
+
@subject.save
|
34
|
+
@subject.title.should == 'War and Peace'
|
35
|
+
@subject.based_near.should == ["Moscow, Russia"]
|
36
|
+
@subject.related_url.should == ["http://en.wikipedia.org/wiki/War_and_Peace"]
|
37
|
+
@subject.part.should == ["this is a part"]
|
38
|
+
end
|
39
|
+
it "should set, persist, and recall values" do
|
40
|
+
@subject.title = 'War and Peace'
|
41
|
+
@subject.based_near = "Moscow, Russia"
|
42
|
+
@subject.related_url = "http://en.wikipedia.org/wiki/War_and_Peace"
|
43
|
+
@subject.part = "this is a part"
|
44
|
+
@subject.save
|
45
|
+
|
46
|
+
loaded = RdfTest.find(@subject.pid)
|
47
|
+
loaded.title.should == 'War and Peace'
|
48
|
+
loaded.based_near.should == ['Moscow, Russia']
|
49
|
+
loaded.related_url.should == ['http://en.wikipedia.org/wiki/War_and_Peace']
|
50
|
+
loaded.part.should == ['this is a part']
|
51
|
+
end
|
52
|
+
it "should set multiple values" do
|
53
|
+
@subject.part = ["part 1", "part 2"]
|
54
|
+
@subject.save
|
55
|
+
|
56
|
+
loaded = RdfTest.find(@subject.pid)
|
57
|
+
loaded.part.should == ['part 1', 'part 2']
|
58
|
+
end
|
59
|
+
it "should append values" do
|
60
|
+
@subject.part = "thing 1"
|
61
|
+
@subject.save
|
62
|
+
|
63
|
+
@subject.part << "thing 2"
|
64
|
+
@subject.part.should == ["thing 1", "thing 2"]
|
65
|
+
end
|
66
|
+
it "should delete values" do
|
67
|
+
@subject.title = "Hamlet"
|
68
|
+
@subject.related_url = "http://psu.edu/"
|
69
|
+
@subject.related_url << "http://projecthydra.org/"
|
70
|
+
@subject.save
|
71
|
+
@subject.title.should == "Hamlet"
|
72
|
+
@subject.related_url.should include("http://psu.edu/")
|
73
|
+
@subject.related_url.should include("http://projecthydra.org/")
|
74
|
+
@subject.title = ""
|
75
|
+
@subject.related_url.delete("http://projecthydra.org/")
|
76
|
+
@subject.save
|
77
|
+
@subject.title.should be_nil
|
78
|
+
@subject.related_url.should == ["http://psu.edu/"]
|
79
|
+
end
|
80
|
+
end
|
@@ -80,7 +80,6 @@ describe ActiveFedora::RelsExtDatastream do
|
|
80
80
|
|
81
81
|
describe '#from_solr' do
|
82
82
|
before do
|
83
|
-
ActiveSupport::Deprecation.stubs(:warn)
|
84
83
|
class MockAFRelsSolr < ActiveFedora::Base
|
85
84
|
include ActiveFedora::FileManagement
|
86
85
|
has_relationship "testing", :has_part, :type=>MockAFRelsSolr
|
@@ -6,20 +6,17 @@ describe ActiveFedora::SemanticNode do
|
|
6
6
|
|
7
7
|
before(:all) do
|
8
8
|
class SNSpecNode < ActiveFedora::Base
|
9
|
-
|
10
|
-
# attr_accessor :rels_ext
|
11
|
-
# def initialize
|
12
|
-
# self.rels_ext = ActiveFedora::RelsExtDatastream.new(nil, nil)
|
13
|
-
# rels_ext.model = self
|
14
|
-
# end
|
9
|
+
include ActiveFedora::FileManagement
|
15
10
|
end
|
16
11
|
@node = SNSpecNode.new
|
17
12
|
class SNSpecModel < ActiveFedora::Base
|
13
|
+
include ActiveFedora::Relationships
|
18
14
|
has_relationship("parts", :is_part_of, :inbound => true)
|
19
15
|
has_relationship("containers", :is_member_of)
|
20
16
|
has_bidirectional_relationship("bi_containers", :is_member_of, :has_member)
|
21
17
|
end
|
22
18
|
class SpecNodeSolrFilterQuery < ActiveFedora::Base
|
19
|
+
include ActiveFedora::Relationships
|
23
20
|
has_relationship("parts", :is_part_of, :inbound => true)
|
24
21
|
has_relationship("special_parts", :is_part_of, :inbound => true, :solr_fq=>"has_model_s:info\\:fedora/afmodel\\:SpecialPart")
|
25
22
|
has_relationship("containers", :is_member_of)
|
@@ -56,8 +53,8 @@ describe ActiveFedora::SemanticNode do
|
|
56
53
|
@container4.add_relationship(:has_member,@test_object)
|
57
54
|
@container4.save
|
58
55
|
|
59
|
-
class SpecialContainer; end;
|
60
|
-
class SpecialPart; end;
|
56
|
+
class SpecialContainer < ActiveFedora::Base; end;
|
57
|
+
class SpecialPart < ActiveFedora::Base; end;
|
61
58
|
@special_container = ActiveFedora::Base.new()
|
62
59
|
@special_container.add_relationship(:has_model, SpecialContainer.to_class_uri)
|
63
60
|
@special_container.save
|
@@ -161,19 +158,27 @@ describe ActiveFedora::SemanticNode do
|
|
161
158
|
describe "inbound relationship finders" do
|
162
159
|
describe "when inheriting from parents" do
|
163
160
|
before do
|
164
|
-
|
165
|
-
|
161
|
+
class Test1 < ActiveFedora::Base
|
162
|
+
include ActiveFedora::FileManagement
|
163
|
+
end
|
164
|
+
@part4 = Test1.new()
|
165
|
+
@part4.parts
|
166
|
+
|
166
167
|
class Test2 < ActiveFedora::Base
|
168
|
+
include ActiveFedora::FileManagement
|
167
169
|
end
|
168
170
|
class Test3 < Test2
|
171
|
+
include ActiveFedora::Relationships
|
169
172
|
has_relationship "testing", :has_member
|
170
173
|
end
|
171
174
|
|
172
175
|
class Test4 < Test3
|
176
|
+
include ActiveFedora::Relationships
|
173
177
|
has_relationship "testing_inbound", :is_member_of, :inbound=>true
|
174
178
|
end
|
175
179
|
|
176
180
|
class Test5 < Test4
|
181
|
+
include ActiveFedora::Relationships
|
177
182
|
has_relationship "testing_inbound", :is_part_of, :inbound=>true
|
178
183
|
end
|
179
184
|
|
@@ -181,21 +186,9 @@ describe ActiveFedora::SemanticNode do
|
|
181
186
|
@test_object2.save
|
182
187
|
end
|
183
188
|
it "should have relationships defined" do
|
184
|
-
|
185
|
-
# puts Test2.relationships_desc.inspect
|
186
|
-
# puts "ActiveFedora::Base relationships_desc:"
|
187
|
-
# puts ActiveFedora::Base.relationships_desc.inspect
|
188
|
-
ActiveFedora::Base.relationships_desc.should have_key(:inbound)
|
189
|
+
Test1.relationships_desc.should have_key(:inbound)
|
189
190
|
Test2.relationships_desc.should have_key(:inbound)
|
190
|
-
|
191
|
-
Test2.relationships_desc[:inbound].should have_key(key)
|
192
|
-
Test2.relationships_desc[:inbound][key].should == value
|
193
|
-
Test2.inbound_relationship_query("foo:1",key.to_s).should_not be_empty
|
194
|
-
end
|
195
|
-
ActiveFedora::Base.relationships_desc[:self].each_pair do |key, value|
|
196
|
-
Test2.relationships_desc[:self].should have_key(key)
|
197
|
-
Test2.relationships_desc[:self][key].should == value
|
198
|
-
end
|
191
|
+
Test2.relationships_desc[:inbound]["parts_inbound"].should == {:inbound=>true, :predicate=>:is_part_of, :singular=>nil}
|
199
192
|
end
|
200
193
|
|
201
194
|
it "should have relationships defined from more than one ancestor class" do
|
@@ -213,7 +206,7 @@ describe ActiveFedora::SemanticNode do
|
|
213
206
|
|
214
207
|
it "should not have relationships bleeding over from other sibling classes" do
|
215
208
|
SpecNodeSolrFilterQuery.relationships_desc[:inbound].should have_key("bi_special_containers_inbound")
|
216
|
-
|
209
|
+
Test1.relationships_desc[:inbound].should_not have_key("bi_special_containers_inbound")
|
217
210
|
Test2.relationships_desc[:inbound].should_not have_key("bi_special_containers_inbound")
|
218
211
|
end
|
219
212
|
it "should return an empty set" do
|
@@ -431,7 +424,6 @@ describe ActiveFedora::SemanticNode do
|
|
431
424
|
#putting this test here instead of relationships_helper because testing that relationships_by_name hash gets refreshed if the relationships hash is changed
|
432
425
|
describe "relationships_by_name" do
|
433
426
|
before do
|
434
|
-
ActiveSupport::Deprecation.stubs(:warn)
|
435
427
|
class MockSemNamedRelationships < ActiveFedora::Base
|
436
428
|
include ActiveFedora::FileManagement
|
437
429
|
has_relationship "testing", :has_part
|
@@ -23,7 +23,9 @@ describe ActiveFedora::SolrService do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
@test_object = ActiveFedora::Base.new
|
26
|
+
@test_object.label = 'test_object'
|
26
27
|
@foo_object = FooObject.new
|
28
|
+
@foo_object.label = 'foo_object'
|
27
29
|
attributes = {"holding_id"=>{0=>"Holding 1"},
|
28
30
|
"language"=>{0=>"Italian"},
|
29
31
|
"creator"=>{0=>"Linguist, A."},
|
@@ -32,6 +34,13 @@ describe ActiveFedora::SolrService do
|
|
32
34
|
@foo_object.update_indexed_attributes(attributes)
|
33
35
|
@test_object.save
|
34
36
|
@foo_object.save
|
37
|
+
@profiles = {
|
38
|
+
'test' => @test_object.inner_object.profile,
|
39
|
+
'foo' => @foo_object.inner_object.profile,
|
40
|
+
'foo_properties' => @foo_object.datastreams['properties'].profile,
|
41
|
+
'foo_descMetadata' => @foo_object.datastreams['descMetadata'].profile
|
42
|
+
}
|
43
|
+
@foo_content = @foo_object.datastreams['descMetadata'].content
|
35
44
|
end
|
36
45
|
after(:all) do
|
37
46
|
@test_object.delete
|
@@ -53,10 +62,51 @@ describe ActiveFedora::SolrService do
|
|
53
62
|
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
54
63
|
result.length.should == 2
|
55
64
|
result.each do |r|
|
56
|
-
|
65
|
+
r.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
|
66
|
+
[ActiveFedora::Base, FooObject].should include(r.class)
|
67
|
+
['test_object','foo_object'].should include(r.label)
|
68
|
+
@test_object.inner_object.profile.should == @profiles['test']
|
69
|
+
@foo_object.inner_object.profile.should == @profiles['foo']
|
70
|
+
@foo_object.datastreams['properties'].profile.should == @profiles['foo_properties']
|
71
|
+
@foo_object.datastreams['descMetadata'].profile.should == @profiles['foo_descMetadata']
|
72
|
+
@foo_object.datastreams['descMetadata'].content.should be_equivalent_to(@foo_content)
|
57
73
|
end
|
58
74
|
end
|
59
75
|
|
76
|
+
it 'should #reify a lightweight object as a new instance' do
|
77
|
+
query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
|
78
|
+
solr_result = ActiveFedora::SolrService.instance.conn.query(query)
|
79
|
+
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
80
|
+
solr_foo = result.first
|
81
|
+
real_foo = solr_foo.reify
|
82
|
+
solr_foo.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
|
83
|
+
real_foo.inner_object.should be_a(ActiveFedora::DigitalObject)
|
84
|
+
solr_foo.label.should == 'foo_object'
|
85
|
+
real_foo.label.should == 'foo_object'
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should #reify! a lightweight object within the same instance' do
|
89
|
+
query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
|
90
|
+
solr_result = ActiveFedora::SolrService.instance.conn.query(query)
|
91
|
+
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
92
|
+
solr_foo = result.first
|
93
|
+
solr_foo.inner_object.should be_a(ActiveFedora::SolrDigitalObject)
|
94
|
+
solr_foo.reify!
|
95
|
+
solr_foo.inner_object.should be_a(ActiveFedora::DigitalObject)
|
96
|
+
solr_foo.label.should == 'foo_object'
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should raise an exception when attempting to reify a first-class object' do
|
100
|
+
query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
|
101
|
+
solr_result = ActiveFedora::SolrService.instance.conn.query(query)
|
102
|
+
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
103
|
+
solr_foo = result.first
|
104
|
+
lambda {solr_foo.reify}.should_not raise_exception
|
105
|
+
lambda {solr_foo.reify!}.should_not raise_exception
|
106
|
+
lambda {solr_foo.reify!}.should raise_exception(/already a full/)
|
107
|
+
lambda {solr_foo.reify}.should raise_exception(/already a full/)
|
108
|
+
end
|
109
|
+
|
60
110
|
it 'should call load_instance_from_solr if :load_from_solr option passed in' do
|
61
111
|
query = "id\:#{ActiveFedora::SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{ActiveFedora::SolrService.escape_uri_for_query(@foo_object.pid)}"
|
62
112
|
solr_result = ActiveFedora::SolrService.instance.conn.query(query)
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "active-fedora"
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require 'spec/samples/hydra-mods_article_datastream.rb'
|
3
|
+
require 'spec/samples/hydra-rights_metadata_datastream.rb'
|
4
4
|
|
5
5
|
# This Model is used to load & index the hydrangea:fixture_mods_article1 fixture for use in tests.
|
6
6
|
#
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "active-fedora"
|
2
|
-
require "active_fedora/samples/hydra-mods_article_datastream.rb"
|
3
|
-
require "active_fedora/samples/hydra-rights_metadata_datastream.rb"
|
4
|
-
require "active_fedora/samples/marpa-dc_datastream.rb"
|
2
|
+
# require "active_fedora/samples/hydra-mods_article_datastream.rb"
|
3
|
+
# require "active_fedora/samples/hydra-rights_metadata_datastream.rb"
|
4
|
+
# require "active_fedora/samples/marpa-dc_datastream.rb"
|
5
5
|
|
6
6
|
# This is an example of an ActiveFedora Model
|
7
7
|
#
|
data/spec/spec_helper.rb
CHANGED
@@ -92,28 +92,17 @@ describe ActiveFedora do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should return the solr.yml file in the same directory as the fedora.yml if it exists" do
|
95
|
-
ActiveFedora.expects(:
|
96
|
-
ActiveFedora.expects(:fedora_config_path).returns("/path/to/fedora/config/fedora.yml")
|
95
|
+
ActiveFedora::Config.any_instance.expects(:path).returns("/path/to/fedora/config/fedora.yml")
|
97
96
|
File.expects(:file?).with("/path/to/fedora/config/solr.yml").returns(true)
|
98
97
|
ActiveFedora.get_config_path(:solr).should eql("/path/to/fedora/config/solr.yml")
|
99
98
|
end
|
100
99
|
|
101
|
-
it "should raise an error if there is not a solr.yml in the same directory as the fedora.yml and the fedora.yml has a solr url defined" do
|
102
|
-
ActiveFedora.expects(:config_options).at_least_once.returns({})
|
103
|
-
ActiveFedora.expects(:fedora_config_path).returns("/path/to/fedora/config/fedora.yml")
|
104
|
-
File.expects(:file?).with("/path/to/fedora/config/solr.yml").returns(false)
|
105
|
-
ActiveFedora.expects(:fedora_config).returns({"test"=>{"solr"=>{"url"=>"http://some_url"}}})
|
106
|
-
ActiveSupport::Deprecation.expects(:warn)
|
107
|
-
lambda { ActiveFedora.get_config_path(:solr) }.should raise_exception
|
108
|
-
end
|
109
|
-
|
110
100
|
context "no solr.yml in same directory as fedora.yml and fedora.yml does not contain solr url" do
|
111
101
|
|
112
102
|
before :each do
|
113
103
|
ActiveFedora.expects(:config_options).at_least_once.returns({})
|
114
|
-
ActiveFedora.expects(:
|
104
|
+
ActiveFedora::Config.any_instance.expects(:path).returns("/path/to/fedora/config/fedora.yml")
|
115
105
|
File.expects(:file?).with("/path/to/fedora/config/solr.yml").returns(false)
|
116
|
-
ActiveFedora.expects(:fedora_config).returns({"test"=>{"url"=>"http://some_url"}})
|
117
106
|
end
|
118
107
|
after :each do
|
119
108
|
unstub_rails
|
@@ -144,12 +133,6 @@ describe ActiveFedora do
|
|
144
133
|
|
145
134
|
|
146
135
|
describe "#determine url" do
|
147
|
-
it "should support config['environment']['fedora']['url'] if config_type is fedora" do
|
148
|
-
config = {:test=> {:fedora=>{"url"=>"http://fedoraAdmin:fedorAdmin@localhost:8983/fedora"}}}
|
149
|
-
ActiveSupport::Deprecation.expects(:warn).with("Using \"fedora\" in the fedora.yml file is no longer supported")
|
150
|
-
ActiveFedora.determine_url("fedora",config).should eql("http://localhost:8983/fedora")
|
151
|
-
end
|
152
|
-
|
153
136
|
it "should support config['environment']['url'] if config_type is fedora" do
|
154
137
|
config = {:test=> {:url=>"http://fedoraAdmin:fedorAdmin@localhost:8983/fedora"}}
|
155
138
|
ActiveFedora.determine_url("fedora",config).should eql("http://localhost:8983/fedora")
|
@@ -163,12 +146,6 @@ describe ActiveFedora do
|
|
163
146
|
end
|
164
147
|
|
165
148
|
describe "load_config" do
|
166
|
-
it "should load the file specified in fedora_config_path" do
|
167
|
-
ActiveFedora.expects(:fedora_config_path).returns("/path/to/fedora.yml")
|
168
|
-
File.expects(:open).with("/path/to/fedora.yml").returns("test:\n url: http://myfedora:8080")
|
169
|
-
ActiveFedora.load_config(:fedora).should eql({:url=>"http://myfedora:8080",:test=>{:url=>"http://myfedora:8080", :user=>nil, :password=>nil}})
|
170
|
-
ActiveFedora.fedora_config.should eql({:url=>"http://myfedora:8080",:test=>{:url=>"http://myfedora:8080", :user=>nil, :password=>nil}})
|
171
|
-
end
|
172
149
|
it "should load the file specified in solr_config_path" do
|
173
150
|
ActiveFedora.expects(:solr_config_path).returns("/path/to/solr.yml")
|
174
151
|
File.expects(:open).with("/path/to/solr.yml").returns("development:\n default:\n url: http://devsolr:8983\ntest:\n default:\n url: http://mysolr:8080")
|
@@ -183,7 +160,7 @@ describe ActiveFedora do
|
|
183
160
|
ActiveFedora.instance_variable_set :@config_loaded, nil
|
184
161
|
end
|
185
162
|
it "should load the fedora and solr configs" do
|
186
|
-
ActiveFedora.expects(:load_config).with(:fedora)
|
163
|
+
#ActiveFedora.expects(:load_config).with(:fedora)
|
187
164
|
ActiveFedora.expects(:load_config).with(:solr)
|
188
165
|
ActiveFedora.config_loaded?.should be_false
|
189
166
|
ActiveFedora.load_configs
|
@@ -205,12 +182,12 @@ describe ActiveFedora do
|
|
205
182
|
|
206
183
|
describe "check_fedora_path_for_solr" do
|
207
184
|
it "should find the solr.yml file and return it if it exists" do
|
208
|
-
ActiveFedora.expects(:
|
185
|
+
ActiveFedora::Config.any_instance.expects(:path).returns("/path/to/fedora/fedora.yml")
|
209
186
|
File.expects(:file?).with("/path/to/fedora/solr.yml").returns(true)
|
210
187
|
ActiveFedora.check_fedora_path_for_solr.should == "/path/to/fedora/solr.yml"
|
211
188
|
end
|
212
189
|
it "should return nil if the solr.yml file is not there" do
|
213
|
-
ActiveFedora.expects(:
|
190
|
+
ActiveFedora::Config.any_instance.expects(:path).returns("/path/to/fedora/fedora.yml")
|
214
191
|
File.expects(:file?).with("/path/to/fedora/solr.yml").returns(false)
|
215
192
|
ActiveFedora.check_fedora_path_for_solr.should be_nil
|
216
193
|
end
|
@@ -236,28 +213,27 @@ describe ActiveFedora do
|
|
236
213
|
|
237
214
|
it "can tell its config paths" do
|
238
215
|
ActiveFedora.init
|
239
|
-
ActiveFedora.should respond_to(:fedora_config_path)
|
240
216
|
ActiveFedora.should respond_to(:solr_config_path)
|
241
217
|
end
|
242
218
|
it "loads a config from the current working directory as a second choice" do
|
243
219
|
Dir.stubs(:getwd).returns(@fake_rails_root)
|
244
220
|
ActiveFedora.init
|
245
|
-
ActiveFedora.
|
221
|
+
ActiveFedora.get_config_path(:fedora).should eql("#{@fake_rails_root}/config/fedora.yml")
|
246
222
|
ActiveFedora.solr_config_path.should eql("#{@fake_rails_root}/config/solr.yml")
|
247
223
|
end
|
248
224
|
it "loads the config that ships with this gem as a last choice" do
|
249
225
|
Dir.stubs(:getwd).returns("/fake/path")
|
250
|
-
logger.expects(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml) - or set Rails.root and put fedora.yml into \#{Rails.root}/config.")
|
226
|
+
logger.expects(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml) - or set Rails.root and put fedora.yml into \#{Rails.root}/config.").twice
|
251
227
|
ActiveFedora.init
|
252
228
|
expected_config = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config"))
|
253
|
-
ActiveFedora.
|
229
|
+
ActiveFedora.get_config_path(:fedora).should eql(expected_config+'/fedora.yml')
|
254
230
|
ActiveFedora.solr_config_path.should eql(expected_config+'/solr.yml')
|
255
231
|
end
|
256
232
|
it "raises an error if you pass in a string" do
|
257
233
|
lambda{ ActiveFedora.init("#{@fake_rails_root}/config/fake_fedora.yml") }.should raise_exception(ArgumentError)
|
258
234
|
end
|
259
235
|
it "raises an error if you pass in a non-existant config file" do
|
260
|
-
lambda{ ActiveFedora.init(:fedora_config_path=>"really_fake_fedora.yml") }.should raise_exception(ActiveFedora::
|
236
|
+
lambda{ ActiveFedora.init(:fedora_config_path=>"really_fake_fedora.yml") }.should raise_exception(ActiveFedora::ConfigurationError)
|
261
237
|
end
|
262
238
|
|
263
239
|
describe "within Rails" do
|
@@ -271,7 +247,7 @@ describe ActiveFedora do
|
|
271
247
|
|
272
248
|
it "loads a config from Rails.root as a first choice" do
|
273
249
|
ActiveFedora.init
|
274
|
-
ActiveFedora.
|
250
|
+
ActiveFedora.get_config_path(:fedora).should eql("#{Rails.root}/config/fedora.yml")
|
275
251
|
ActiveFedora.solr_config_path.should eql("#{Rails.root}/config/solr.yml")
|
276
252
|
end
|
277
253
|
|
@@ -315,9 +291,7 @@ describe ActiveFedora do
|
|
315
291
|
before do
|
316
292
|
|
317
293
|
ActiveFedora.instance_variable_set :@predicate_config_path, nil
|
318
|
-
ActiveFedora.
|
319
|
-
# ActiveFedora.expects(:load_config).with(:fedora)
|
320
|
-
# ActiveFedora.expects(:load_config).with(:solr)
|
294
|
+
ActiveFedora::Config.any_instance.expects(:path).returns("/path/to/my/files/fedora.yml")
|
321
295
|
end
|
322
296
|
it "should return the path that was set at initialization" do
|
323
297
|
File.expects(:exist?).with("/path/to/my/files/predicate_mappings.yml").returns(true)
|
@@ -360,17 +334,11 @@ describe ActiveFedora do
|
|
360
334
|
describe "outside of rails" do
|
361
335
|
it "should load the default packaged config/fedora.yml file if no explicit config path is passed" do
|
362
336
|
ActiveFedora.init()
|
363
|
-
ActiveFedora.
|
364
|
-
ActiveFedora.fedora_config[:test][:url].to_s.should == "http://127.0.0.1:8983/fedora-test"
|
365
|
-
ActiveFedora.fedora_config[:test][:user].to_s.should == "fedoraAdmin"
|
366
|
-
ActiveFedora.fedora_config[:test][:password].to_s.should == "fedoraAdmin"
|
337
|
+
ActiveFedora.config.credentials.should == {:url=> "http://127.0.0.1:8983/fedora-test", :user=>'fedoraAdmin', :password=>'fedoraAdmin'}
|
367
338
|
end
|
368
339
|
it "should load the passed config if explicit config passed in as a string" do
|
369
340
|
ActiveFedora.init(:fedora_config_path=>'./spec/fixtures/rails_root/config/fedora.yml')
|
370
|
-
ActiveFedora.
|
371
|
-
ActiveFedora.fedora_config[:test][:url].to_s.should == "http://testhost.com:8983/fedora"
|
372
|
-
ActiveFedora.fedora_config[:test][:user].to_s.should == "fedoraAdmin"
|
373
|
-
ActiveFedora.fedora_config[:test][:password].to_s.should == "fedoraAdmin"
|
341
|
+
ActiveFedora.config.credentials.should == {:url=> "http://testhost.com:8983/fedora", :user=>'fedoraAdmin', :password=>'fedoraAdmin'}
|
374
342
|
end
|
375
343
|
end
|
376
344
|
|
@@ -383,7 +351,7 @@ describe ActiveFedora do
|
|
383
351
|
describe "versions prior to 3.0" do
|
384
352
|
describe "with explicit config path passed in" do
|
385
353
|
it "should load the specified config path" do
|
386
|
-
fedora_config="test:\n
|
354
|
+
fedora_config="test:\n url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora"
|
387
355
|
solr_config = "test:\n default:\n url: http://foosolr:8983"
|
388
356
|
|
389
357
|
fedora_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/fedora.yml"))
|
@@ -394,10 +362,9 @@ describe ActiveFedora do
|
|
394
362
|
File.stubs(:open).with(solr_config_path).returns(solr_config)
|
395
363
|
|
396
364
|
|
397
|
-
ActiveSupport::Deprecation.expects(:warn).with("Using \"
|
365
|
+
ActiveSupport::Deprecation.expects(:warn).with("Using \":url\" in the fedora.yml file without :user and :password is no longer supported")
|
398
366
|
ActiveFedora.init(:fedora_config_path=>fedora_config_path,:solr_config_path=>solr_config_path)
|
399
367
|
ActiveFedora.solr.class.should == ActiveFedora::SolrService
|
400
|
-
ActiveFedora.fedora.class.should == ActiveFedora::RubydoraConnection
|
401
368
|
end
|
402
369
|
end
|
403
370
|
|
@@ -405,12 +372,12 @@ describe ActiveFedora do
|
|
405
372
|
it "should look for the file in the path defined at Rails.root" do
|
406
373
|
stub_rails(:root=>File.join(File.dirname(__FILE__),"../fixtures/rails_root"))
|
407
374
|
ActiveFedora.init()
|
408
|
-
ActiveFedora.
|
375
|
+
ActiveFedora.config.credentials[:url].should == "http://testhost.com:8983/fedora"
|
409
376
|
end
|
410
377
|
it "should load the default file if no config is found at Rails.root" do
|
411
378
|
stub_rails(:root=>File.join(File.dirname(__FILE__),"../fixtures/bad/path/to/rails_root"))
|
412
379
|
ActiveFedora.init()
|
413
|
-
ActiveFedora.
|
380
|
+
ActiveFedora.config.credentials[:url].should == "http://127.0.0.1:8983/fedora-test"
|
414
381
|
end
|
415
382
|
end
|
416
383
|
end
|