active-fedora 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/active-fedora.gemspec +1 -2
- data/lib/active_fedora/datastreams.rb +14 -14
- data/lib/active_fedora/file_management.rb +5 -3
- data/lib/active_fedora/metadata_datastream_helper.rb +5 -1
- data/lib/active_fedora/nokogiri_datastream.rb +17 -4
- data/lib/active_fedora/rdf_datastream.rb +59 -36
- data/lib/active_fedora/relationships.rb +28 -11
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +3 -3
- data/spec/integration/base_spec.rb +15 -3
- data/spec/integration/bug_spec.rb +0 -3
- data/spec/integration/datastream_collections_spec.rb +9 -9
- data/spec/integration/datastream_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +3 -4
- data/spec/integration/ntriples_datastream_spec.rb +0 -1
- data/spec/integration/rels_ext_datastream_spec.rb +12 -1
- data/spec/integration/semantic_node_spec.rb +10 -0
- data/spec/integration/solr_service_spec.rb +2 -2
- data/spec/spec_helper.rb +4 -7
- data/spec/support/mock_fedora.rb +10 -10
- data/spec/unit/active_fedora_spec.rb +8 -8
- data/spec/unit/association_proxy_spec.rb +2 -1
- data/spec/unit/base_cma_spec.rb +2 -2
- data/spec/unit/base_datastream_management_spec.rb +9 -9
- data/spec/unit/base_extra_spec.rb +25 -25
- data/spec/unit/base_file_management_spec.rb +32 -23
- data/spec/unit/base_spec.rb +94 -151
- data/spec/unit/callback_spec.rb +16 -11
- data/spec/unit/code_configurator_spec.rb +4 -4
- data/spec/unit/content_model_spec.rb +8 -8
- data/spec/unit/datastream_collections_spec.rb +23 -23
- data/spec/unit/datastream_spec.rb +7 -7
- data/spec/unit/datastreams_spec.rb +189 -304
- data/spec/unit/file_configurator_spec.rb +56 -56
- data/spec/unit/has_many_collection_spec.rb +1 -1
- data/spec/unit/model_spec.rb +51 -56
- data/spec/unit/nokogiri_datastream_spec.rb +24 -25
- data/spec/unit/ntriples_datastream_spec.rb +18 -27
- data/spec/unit/property_spec.rb +0 -2
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -2
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +1 -1
- data/spec/unit/relationship_graph_spec.rb +1 -1
- data/spec/unit/relationships_spec.rb +64 -52
- data/spec/unit/rels_ext_datastream_spec.rb +7 -7
- data/spec/unit/semantic_node_spec.rb +5 -5
- data/spec/unit/service_definitions_spec.rb +18 -16
- data/spec/unit/solr_config_options_spec.rb +6 -6
- data/spec/unit/solr_service_spec.rb +16 -16
- metadata +5 -21
@@ -16,11 +16,11 @@ describe ActiveFedora::RelsExtDatastream do
|
|
16
16
|
before(:each) do
|
17
17
|
mock_inner = mock('inner object')
|
18
18
|
@mock_repo = mock('repository')
|
19
|
-
@mock_repo.
|
20
|
-
mock_inner.
|
21
|
-
mock_inner.
|
19
|
+
@mock_repo.stub(:datastream_dissemination=>'My Content', :config=>{})
|
20
|
+
mock_inner.stub(:repository).and_return(@mock_repo)
|
21
|
+
mock_inner.stub(:pid).and_return(@pid)
|
22
22
|
@test_ds = ActiveFedora::RelsExtDatastream.new(mock_inner, "RELS-EXT")
|
23
|
-
@test_ds.
|
23
|
+
@test_ds.stub(:profile).and_return({})
|
24
24
|
end
|
25
25
|
|
26
26
|
its(:metadata?) { should be_true}
|
@@ -49,7 +49,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
49
49
|
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
50
50
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('demo:10'))
|
51
51
|
|
52
|
-
@test_ds.
|
52
|
+
@test_ds.stub(:new? => true, :relationships_are_dirty? =>true, :relationships => graph, :model => mock(:relationships_are_dirty= => true))
|
53
53
|
@test_ds.serialize!
|
54
54
|
EquivalentXml.equivalent?(@test_ds.content, "<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n <rdf:Description rdf:about='info:fedora/test:sample_pid'>\n <isMemberOf rdf:resource='demo:10' xmlns='info:fedora/fedora-system:def/relations-external#'/></rdf:Description>\n </rdf:RDF>").should be_true
|
55
55
|
end
|
@@ -82,7 +82,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
82
82
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
|
83
83
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
|
84
84
|
|
85
|
-
@test_ds.
|
85
|
+
@test_ds.should_receive(:model).and_return(stub("model", :relationships=>graph, :relationships_are_dirty= => true))
|
86
86
|
EquivalentXml.equivalent?(@test_ds.to_rels_ext(), @sample_rels_ext_xml).should be_true
|
87
87
|
end
|
88
88
|
|
@@ -95,7 +95,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
95
95
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
|
96
96
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
|
97
97
|
|
98
|
-
@test_ds.
|
98
|
+
@test_ds.stub(:model).and_return(stub("model", :relationships=>graph, :relationships_are_dirty= => true))
|
99
99
|
rels = @test_ds.to_rels_ext()
|
100
100
|
EquivalentXml.equivalent?(rels, @sample_rels_ext_xml).should be_true
|
101
101
|
rels.should_not =~ /fedora:isMemberOf/
|
@@ -47,11 +47,11 @@ describe ActiveFedora::SemanticNode do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
@node = SpecNode.new
|
50
|
-
@node.
|
50
|
+
@node.stub(:rels_ext).and_return(stub("rels_ext", :content_will_change! => true, :content=>''))
|
51
51
|
@node.pid = increment_pid
|
52
52
|
@test_object = SpecNode2.new
|
53
53
|
@test_object.pid = increment_pid
|
54
|
-
@test_object.
|
54
|
+
@test_object.stub(:rels_ext).and_return(stub("rels_ext", :content_will_change! => true, :content=>''))
|
55
55
|
end
|
56
56
|
|
57
57
|
after(:each) do
|
@@ -105,9 +105,9 @@ describe ActiveFedora::SemanticNode do
|
|
105
105
|
it "adding relationship to an instance should not affect class-level relationships hash" do
|
106
106
|
local_test_node1 = SpecNode.new
|
107
107
|
local_test_node2 = SpecNode.new
|
108
|
-
local_test_node1.
|
108
|
+
local_test_node1.stub(:rels_ext).and_return(stub("rels_ext", :content_will_change! => true, :content=>''))
|
109
109
|
local_test_node1.add_relationship(:is_member_of, 'demo:10')
|
110
|
-
local_test_node2.
|
110
|
+
local_test_node2.stub(:rels_ext).and_return(stub('rels-ext', :content=>''))
|
111
111
|
|
112
112
|
local_test_node1.relationships(:is_member_of).should == ["demo:10"]
|
113
113
|
local_test_node2.relationships(:is_member_of).should == []
|
@@ -137,7 +137,7 @@ describe ActiveFedora::SemanticNode do
|
|
137
137
|
|
138
138
|
describe '#remove_relationship' do
|
139
139
|
it 'should remove a relationship from the relationships hash' do
|
140
|
-
@test_object.
|
140
|
+
@test_object.stub(:rels_ext).and_return(stub("rels_ext", :content_will_change! => true, :content=>''))
|
141
141
|
@test_object.add_relationship(:has_part, "info:fedora/3")
|
142
142
|
@test_object.add_relationship(:has_part, "info:fedora/4")
|
143
143
|
#check both are there
|
@@ -13,11 +13,16 @@ describe ActiveFedora::ServiceDefinitions do
|
|
13
13
|
<fmm:Method operationName="getDocumentStyle2"/>
|
14
14
|
</fmm:MethodMap>
|
15
15
|
MMAP
|
16
|
-
|
17
|
-
|
18
|
-
Rubydora::Repository.any_instance.stubs(:datastream_dissemination).with({:pid=>'test:12',:dsid=>'METHODMAP'}).returns mmap
|
16
|
+
@repository = ActiveFedora::Base.connection_for_pid(0)
|
17
|
+
@repository.stub(:datastream_dissemination).with({:pid=>'test:12',:dsid=>'METHODMAP'}).and_return mmap
|
19
18
|
Test.has_service_definition "test:12"
|
20
19
|
end
|
20
|
+
|
21
|
+
subject {
|
22
|
+
obj = Test.new()
|
23
|
+
obj.stub(:pid).and_return('monkey:99')
|
24
|
+
obj
|
25
|
+
}
|
21
26
|
describe "method lookup" do
|
22
27
|
it "should find method keys in the YAML config" do
|
23
28
|
ActiveFedora::ServiceDefinitions.lookup_method("fedora-system:3", "viewObjectProfile").should == :object_profile
|
@@ -25,32 +30,29 @@ describe ActiveFedora::ServiceDefinitions do
|
|
25
30
|
end
|
26
31
|
describe "method creation" do
|
27
32
|
it "should create the system sdef methods" do
|
28
|
-
|
29
|
-
(obj.respond_to? :object_profile).should == true
|
33
|
+
subject.should respond_to(:object_profile)
|
30
34
|
end
|
31
35
|
it "should create the declared sdef methods" do
|
32
|
-
|
33
|
-
(obj.respond_to? :document_style_1).should == true
|
36
|
+
subject.should respond_to(:document_style_1)
|
34
37
|
end
|
35
38
|
end
|
36
39
|
describe "generated method" do
|
37
40
|
it "should call the appropriate rubydora rest api method" do
|
38
|
-
|
39
|
-
#@mock_client.
|
40
|
-
|
41
|
-
|
42
|
-
obj.document_style_1
|
41
|
+
@repository.should_receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1'})
|
42
|
+
#@mock_client.stub(:[]).with('objects/monkey%3A99/methods/test%3A12/getDocumentStyle1')
|
43
|
+
|
44
|
+
subject.document_style_1
|
43
45
|
end
|
44
46
|
it "should call the appropriate rubydora rest api method with parameters" do
|
45
|
-
|
47
|
+
@repository.should_receive(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1', :format=>'xml'})
|
46
48
|
obj = Test.new()
|
47
|
-
obj.
|
49
|
+
obj.stub(:pid).and_return('monkey:99')
|
48
50
|
obj.document_style_1({:format=>'xml'})
|
49
51
|
end
|
50
52
|
it "should call the appropriate rubydora rest api method with a block" do
|
51
|
-
|
53
|
+
@repository.stub(:dissemination).with({:pid=>'monkey:99',:sdef=>'test:12', :method=>'getDocumentStyle1'}).and_yield "ping!","pang!"
|
52
54
|
obj = Test.new()
|
53
|
-
obj.
|
55
|
+
obj.stub(:pid).and_return('monkey:99')
|
54
56
|
block_response = ""
|
55
57
|
obj.document_style_1 {|res,req|
|
56
58
|
block_response += 'pong!' if res == "ping!" and req == "pang!"
|
@@ -51,7 +51,7 @@ describe ActiveFedora do
|
|
51
51
|
|
52
52
|
it "should be used by ActiveFedora::Base#find_with_conditions" do
|
53
53
|
mock_response = mock("SolrResponse")
|
54
|
-
ActiveFedora::SolrService.
|
54
|
+
ActiveFedora::SolrService.should_receive(:query).with("has_model_s:info\\:fedora\\/afmodel\\:SolrSpecModel_Basic AND " + SOLR_DOCUMENT_ID + ':"changeme\\:30"', {:sort => ['system_create_dt asc']}).and_return(mock_response)
|
55
55
|
|
56
56
|
SolrSpecModel::Basic.find_with_conditions(:id=>"changeme:30").should equal(mock_response)
|
57
57
|
end
|
@@ -69,14 +69,14 @@ describe ActiveFedora do
|
|
69
69
|
it "should prevent Base.save from calling update_index if false" do
|
70
70
|
dirty_ds = ActiveFedora::SimpleDatastream.new(@test_object.inner_object, 'ds1')
|
71
71
|
@test_object.datastreams['ds1'] = dirty_ds
|
72
|
-
@test_object.
|
73
|
-
@test_object.
|
74
|
-
@test_object.
|
72
|
+
@test_object.stub(:datastreams).and_return({:ds1 => dirty_ds})
|
73
|
+
@test_object.should_receive(:update_index).never
|
74
|
+
@test_object.should_receive(:refresh)
|
75
75
|
@test_object.save
|
76
76
|
end
|
77
77
|
it "should prevent Base.delete from deleting the corresponding Solr document if false" do
|
78
|
-
ActiveFedora::SolrService.instance.conn.
|
79
|
-
@test_object.inner_object.
|
78
|
+
ActiveFedora::SolrService.instance.conn.should_receive(:delete).with(@test_object.pid).never
|
79
|
+
@test_object.inner_object.should_receive(:delete)
|
80
80
|
@test_object.delete
|
81
81
|
end
|
82
82
|
end
|
@@ -10,27 +10,27 @@ describe ActiveFedora::SolrService do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should take a narg constructor and configure for localhost" do
|
13
|
-
RSolr.
|
13
|
+
RSolr.should_receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr')
|
14
14
|
ActiveFedora::SolrService.register
|
15
15
|
end
|
16
16
|
it "should accept host arg into constructor" do
|
17
|
-
RSolr.
|
17
|
+
RSolr.should_receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://fubar')
|
18
18
|
ActiveFedora::SolrService.register('http://fubar')
|
19
19
|
end
|
20
20
|
it "should clobber options" do
|
21
|
-
RSolr.
|
21
|
+
RSolr.should_receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr', :autocommit=>:off, :foo=>:bar)
|
22
22
|
ActiveFedora::SolrService.register(nil, {:autocommit=>:off, :foo=>:bar})
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should set the threadlocal solr service" do
|
26
|
-
RSolr.
|
26
|
+
RSolr.should_receive(:connect).with(:read_timeout => 120, :open_timeout => 120, :url => 'http://localhost:8080/solr', :autocommit=>:off, :foo=>:bar)
|
27
27
|
ss = ActiveFedora::SolrService.register(nil, {:autocommit=>:off, :foo=>:bar})
|
28
28
|
Thread.current[:solr_service].should == ss
|
29
29
|
ActiveFedora::SolrService.instance.should == ss
|
30
30
|
end
|
31
31
|
it "should try to initialize if the service not initialized, and fail if it does not succeed" do
|
32
32
|
Thread.current[:solr_service].should be_nil
|
33
|
-
ActiveFedora::SolrService.
|
33
|
+
ActiveFedora::SolrService.should_receive(:register)
|
34
34
|
proc{ActiveFedora::SolrService.instance}.should raise_error(ActiveFedora::SolrNotInitialized)
|
35
35
|
end
|
36
36
|
|
@@ -50,9 +50,9 @@ describe ActiveFedora::SolrService do
|
|
50
50
|
{"id"=>"my:_PID3_", "has_model_s"=>["info:fedora/afmodel:AudioRecord"]}]
|
51
51
|
end
|
52
52
|
it "should use Repository.find to instantiate objects" do
|
53
|
-
AudioRecord.
|
54
|
-
AudioRecord.
|
55
|
-
AudioRecord.
|
53
|
+
AudioRecord.should_receive(:find).with("my:_PID1_")
|
54
|
+
AudioRecord.should_receive(:find).with("my:_PID2_")
|
55
|
+
AudioRecord.should_receive(:find).with("my:_PID3_")
|
56
56
|
ActiveFedora::SolrService.reify_solr_results(@sample_solr_hits)
|
57
57
|
end
|
58
58
|
end
|
@@ -77,8 +77,8 @@ describe ActiveFedora::SolrService do
|
|
77
77
|
it "should call solr" do
|
78
78
|
mock_conn = mock("Connection")
|
79
79
|
stub_result = stub("Result")
|
80
|
-
mock_conn.
|
81
|
-
ActiveFedora::SolrService.
|
80
|
+
mock_conn.should_receive(:get).with('select', :params=>{:q=>'querytext', :qt=>'standard'}).and_return(stub_result)
|
81
|
+
ActiveFedora::SolrService.stub(:instance =>stub("instance", :conn=>mock_conn))
|
82
82
|
ActiveFedora::SolrService.query('querytext', :raw=>true).should == stub_result
|
83
83
|
end
|
84
84
|
end
|
@@ -86,8 +86,8 @@ describe ActiveFedora::SolrService do
|
|
86
86
|
it "should return a count of matching records" do
|
87
87
|
mock_conn = mock("Connection")
|
88
88
|
stub_result = {'response' => {'numFound'=>'7'}}
|
89
|
-
mock_conn.
|
90
|
-
ActiveFedora::SolrService.
|
89
|
+
mock_conn.should_receive(:get).with('select', :params=>{:rows=>0, :q=>'querytext', :qt=>'standard'}).and_return(stub_result)
|
90
|
+
ActiveFedora::SolrService.stub(:instance =>stub("instance", :conn=>mock_conn))
|
91
91
|
ActiveFedora::SolrService.count('querytext').should == 7
|
92
92
|
end
|
93
93
|
end
|
@@ -95,8 +95,8 @@ describe ActiveFedora::SolrService do
|
|
95
95
|
it "should call solr" do
|
96
96
|
mock_conn = mock("Connection")
|
97
97
|
doc = {'id' => '1234'}
|
98
|
-
mock_conn.
|
99
|
-
ActiveFedora::SolrService.
|
98
|
+
mock_conn.should_receive(:add).with(doc)
|
99
|
+
ActiveFedora::SolrService.stub(:instance =>stub("instance", :conn=>mock_conn))
|
100
100
|
ActiveFedora::SolrService.add(doc)
|
101
101
|
end
|
102
102
|
end
|
@@ -104,8 +104,8 @@ describe ActiveFedora::SolrService do
|
|
104
104
|
it "should call solr" do
|
105
105
|
mock_conn = mock("Connection")
|
106
106
|
doc = {'id' => '1234'}
|
107
|
-
mock_conn.
|
108
|
-
ActiveFedora::SolrService.
|
107
|
+
mock_conn.should_receive(:commit)
|
108
|
+
ActiveFedora::SolrService.stub(:instance =>stub("instance", :conn=>mock_conn))
|
109
109
|
ActiveFedora::SolrService.commit()
|
110
110
|
end
|
111
111
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-12-
|
14
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rsolr
|
@@ -132,7 +132,7 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - ~>
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
135
|
+
version: '1.0'
|
136
136
|
type: :runtime
|
137
137
|
prerelease: false
|
138
138
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -140,7 +140,7 @@ dependencies:
|
|
140
140
|
requirements:
|
141
141
|
- - ~>
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
143
|
+
version: '1.0'
|
144
144
|
- !ruby/object:Gem::Dependency
|
145
145
|
name: rdf
|
146
146
|
requirement: !ruby/object:Gem::Requirement
|
@@ -285,22 +285,6 @@ dependencies:
|
|
285
285
|
- - ! '>='
|
286
286
|
- !ruby/object:Gem::Version
|
287
287
|
version: '0'
|
288
|
-
- !ruby/object:Gem::Dependency
|
289
|
-
name: mocha
|
290
|
-
requirement: !ruby/object:Gem::Requirement
|
291
|
-
none: false
|
292
|
-
requirements:
|
293
|
-
- - '='
|
294
|
-
- !ruby/object:Gem::Version
|
295
|
-
version: 0.10.5
|
296
|
-
type: :development
|
297
|
-
prerelease: false
|
298
|
-
version_requirements: !ruby/object:Gem::Requirement
|
299
|
-
none: false
|
300
|
-
requirements:
|
301
|
-
- - '='
|
302
|
-
- !ruby/object:Gem::Version
|
303
|
-
version: 0.10.5
|
304
288
|
description: ActiveFedora provides for creating and managing objects in the Fedora
|
305
289
|
Repository Architecture.
|
306
290
|
email:
|
@@ -560,7 +544,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
560
544
|
version: '0'
|
561
545
|
segments:
|
562
546
|
- 0
|
563
|
-
hash:
|
547
|
+
hash: 1765541384270860265
|
564
548
|
requirements: []
|
565
549
|
rubyforge_project: rubyfedora
|
566
550
|
rubygems_version: 1.8.23
|