active-fedora 6.4.2 → 6.4.3
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.
- checksums.yaml +4 -4
- data/.mailmap +15 -6
- data/active-fedora.gemspec +2 -2
- data/gemfiles/gemfile.rails4 +1 -1
- data/lib/active_fedora.rb +8 -12
- data/lib/active_fedora/digital_object.rb +1 -0
- data/lib/active_fedora/model.rb +6 -6
- data/lib/active_fedora/om_datastream.rb +14 -3
- data/lib/active_fedora/querying.rb +6 -5
- data/lib/active_fedora/solr_service.rb +15 -10
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora_dev.rake +1 -17
- data/spec/config_helper.rb +1 -1
- data/spec/{unit → integration}/auditable_spec.rb +5 -7
- data/spec/integration/base_spec.rb +2 -1
- data/spec/integration/bug_spec.rb +6 -0
- data/spec/integration/complex_rdf_datastream_spec.rb +3 -3
- data/spec/integration/model_spec.rb +8 -7
- data/spec/integration/om_datastream_spec.rb +78 -73
- data/spec/integration/rdf_nested_attributes_spec.rb +2 -2
- data/spec/integration/solr_instance_loader_spec.rb +9 -4
- data/spec/integration/solr_service_spec.rb +2 -8
- data/spec/support/mock_fedora.rb +6 -6
- data/spec/unit/active_fedora_spec.rb +12 -1
- data/spec/unit/base_extra_spec.rb +10 -10
- data/spec/unit/base_spec.rb +18 -18
- data/spec/unit/content_model_spec.rb +6 -6
- data/spec/unit/datastream_spec.rb +1 -1
- data/spec/unit/datastreams_spec.rb +19 -19
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +6 -6
- data/spec/unit/has_many_collection_spec.rb +3 -3
- data/spec/unit/ntriples_datastream_spec.rb +2 -2
- data/spec/unit/om_datastream_spec.rb +6 -6
- data/spec/unit/query_spec.rb +11 -11
- data/spec/unit/rdf_list_spec.rb +2 -2
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +2 -2
- data/spec/unit/rels_ext_datastream_spec.rb +6 -6
- data/spec/unit/semantic_node_spec.rb +5 -5
- data/spec/unit/solr_config_options_spec.rb +1 -1
- data/spec/unit/solr_service_spec.rb +42 -20
- metadata +10 -23
- data/spec/fixtures/auditable.foxml.xml +0 -110
- data/spec/fixtures/changeme155.xml +0 -255
- data/spec/fixtures/test_12.foxml.xml +0 -60
- data/spec/fixtures/test_fixture_mods_article1.foxml.xml +0 -234
- data/spec/fixtures/test_fixture_mods_article2.foxml.xml +0 -234
- data/spec/hydrangea_fixture_mods_article1.foxml.xml +0 -225
- data/spec/integration/mods_article_integration_spec.rb +0 -22
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
4
4
|
it "should call add_relationship" do
|
5
|
-
subject =
|
6
|
-
predicate =
|
5
|
+
subject = double("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => [])
|
6
|
+
predicate = double(:klass => double.class, :options=>{:property=>'predicate'}, :class_name=> nil)
|
7
7
|
ActiveFedora::SolrService.stub(:query).and_return([])
|
8
8
|
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
9
|
-
object =
|
9
|
+
object = double("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
10
10
|
|
11
11
|
subject.should_receive(:add_relationship).with('predicate', object)
|
12
12
|
|
@@ -15,11 +15,11 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should call add_relationship on subject and object when inverse_of given" do
|
18
|
-
subject =
|
19
|
-
predicate =
|
18
|
+
subject = double("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a', :ids_for_outbound => [])
|
19
|
+
predicate = double(:klass => double.class, :options=>{:property=>'predicate', :inverse_of => 'inverse_predicate'}, :class_name=> nil)
|
20
20
|
ActiveFedora::SolrService.stub(:query).and_return([])
|
21
21
|
ac = ActiveFedora::Associations::HasAndBelongsToManyAssociation.new(subject, predicate)
|
22
|
-
object =
|
22
|
+
object = double("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
23
23
|
|
24
24
|
subject.should_receive(:add_relationship).with('predicate', object)
|
25
25
|
|
@@ -2,11 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Associations::HasManyAssociation do
|
4
4
|
it "should call add_relationship" do
|
5
|
-
subject =
|
6
|
-
predicate =
|
5
|
+
subject = double("subject", :new_record? => false, :pid => 'subject:a', :internal_uri => 'info:fedora/subject:a')
|
6
|
+
predicate = double(:klass => double.class, :options=>{:property=>'predicate'}, :class_name=> nil)
|
7
7
|
ActiveFedora::SolrService.stub(:query).and_return([])
|
8
8
|
ac = ActiveFedora::Associations::HasManyAssociation.new(subject, predicate)
|
9
|
-
object =
|
9
|
+
object = double("object", :new_record? => false, :pid => 'object:b', :save => nil)
|
10
10
|
|
11
11
|
object.should_receive(:add_relationship).with('predicate', subject)
|
12
12
|
|
@@ -14,7 +14,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
14
14
|
map.related_url(:to => "seeAlso", :in => RDF::RDFS)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
@subject = MyDatastream.new(
|
17
|
+
@subject = MyDatastream.new(double('inner object', :pid=>'test:1', :new? =>true), 'descMetadata')
|
18
18
|
@subject.content = File.new('spec/fixtures/mixed_rdf_descMetadata.nt').read
|
19
19
|
end
|
20
20
|
after do
|
@@ -208,7 +208,7 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
208
208
|
delegate :rights, :to => :descMetadata
|
209
209
|
end
|
210
210
|
@obj = MyDatastream.new(@inner_object, 'solr_rdf')
|
211
|
-
repository =
|
211
|
+
repository = double()
|
212
212
|
@obj.stub(:repository => repository, :pid => 'test:1')
|
213
213
|
repository.stub(:modify_datastream)
|
214
214
|
repository.stub(:add_datastream)
|
@@ -9,7 +9,7 @@ describe ActiveFedora::OmDatastream do
|
|
9
9
|
:empty_field => {:values => {}}
|
10
10
|
}
|
11
11
|
@sample_raw_xml = "<foo><xmlelement/></foo>"
|
12
|
-
@solr_doc = {"id"=>"
|
12
|
+
@solr_doc = {"id"=>"mods_article1",
|
13
13
|
ActiveFedora::SolrService.solr_name("name_role_roleTerm", type: :string) =>["creator","submitter","teacher"],
|
14
14
|
ActiveFedora::SolrService.solr_name("name_0_role", type: :string)=>"\r\ncreator\r\nsubmitter\r\n",
|
15
15
|
ActiveFedora::SolrService.solr_name("name_1_role", type: :string)=>"\r\n teacher \r\n",
|
@@ -19,9 +19,9 @@ describe ActiveFedora::OmDatastream do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
before(:each) do
|
22
|
-
@mock_inner =
|
23
|
-
@mock_repo =
|
24
|
-
@mock_repo.stub(:datastream_dissemination=>'My Content', :config=>{})
|
22
|
+
@mock_inner = double('inner object')
|
23
|
+
@mock_repo = double('repository')
|
24
|
+
@mock_repo.stub(:datastream_dissemination=>'My Content', :config=>{}, :datastream=>'')
|
25
25
|
@mock_inner.stub(:repository).and_return(@mock_repo)
|
26
26
|
@mock_inner.stub(:pid)
|
27
27
|
@mock_inner.stub(:new? => false)
|
@@ -262,9 +262,9 @@ describe ActiveFedora::OmDatastream do
|
|
262
262
|
end
|
263
263
|
|
264
264
|
it "should return correct values from solr_doc given different term pointers" do
|
265
|
-
mock_term =
|
265
|
+
mock_term = double("OM::XML::Term")
|
266
266
|
mock_term.stub(:type).and_return(:text)
|
267
|
-
mock_terminology =
|
267
|
+
mock_terminology = double("OM::XML::Terminology")
|
268
268
|
mock_terminology.stub(:retrieve_term).and_return(mock_term)
|
269
269
|
ActiveFedora::OmDatastream.stub(:terminology).and_return(mock_terminology)
|
270
270
|
@mods_ds.from_solr(@solr_doc)
|
data/spec/unit/query_spec.rb
CHANGED
@@ -42,7 +42,7 @@ describe ActiveFedora::Base do
|
|
42
42
|
describe "and a pid is specified" do
|
43
43
|
it "should use SpecModel::Basic.allocate.init_with to instantiate an object" do
|
44
44
|
SpecModel::Basic.any_instance.should_receive(:init_with).and_return(SpecModel::Basic.new)
|
45
|
-
ActiveFedora::DigitalObject.should_receive(:find).and_return(
|
45
|
+
ActiveFedora::DigitalObject.should_receive(:find).and_return(double("inner obj", :'new?'=>false))
|
46
46
|
SpecModel::Basic.find("_PID_").should be_a SpecModel::Basic
|
47
47
|
end
|
48
48
|
it "should raise an exception if it is not found" do
|
@@ -54,8 +54,8 @@ describe ActiveFedora::Base do
|
|
54
54
|
end
|
55
55
|
describe "with :cast" do
|
56
56
|
it "should use SpecModel::Basic.allocate.init_with to instantiate an object" do
|
57
|
-
SpecModel::Basic.any_instance.should_receive(:init_with).and_return(
|
58
|
-
ActiveFedora::DigitalObject.should_receive(:find).and_return(
|
57
|
+
SpecModel::Basic.any_instance.should_receive(:init_with).and_return(double("Model", :adapt_to_cmodel=>SpecModel::Basic.new ))
|
58
|
+
ActiveFedora::DigitalObject.should_receive(:find).and_return(double("inner obj", :'new?'=>false))
|
59
59
|
SpecModel::Basic.find("_PID_", :cast=>true)
|
60
60
|
end
|
61
61
|
end
|
@@ -115,7 +115,7 @@ describe ActiveFedora::Base do
|
|
115
115
|
|
116
116
|
SpecModel::Basic.should_receive(:find_one).with("changeme:30", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:30'))
|
117
117
|
SpecModel::Basic.should_receive(:find_one).with("changeme:22", nil).and_return(SpecModel::Basic.new(:pid=>'changeme:22'))
|
118
|
-
yielded =
|
118
|
+
yielded = double("yielded method")
|
119
119
|
yielded.should_receive(:run).with { |obj| obj.class == SpecModel::Basic}.twice
|
120
120
|
SpecModel::Basic.find_each(){|obj| yielded.run(obj) }
|
121
121
|
end
|
@@ -138,7 +138,7 @@ describe ActiveFedora::Base do
|
|
138
138
|
hash[:params][:q].split(" AND ").include?("baz:\"quix\"") &&
|
139
139
|
hash[:params][:q].split(" AND ").include?("baz:\"quack\"")
|
140
140
|
}.and_return('response'=>{'docs'=>mock_docs})
|
141
|
-
yielded =
|
141
|
+
yielded = double("yielded method")
|
142
142
|
yielded.should_receive(:run).with { |obj| obj.class == SpecModel::Basic}.twice
|
143
143
|
SpecModel::Basic.find_each({:foo=>'bar', :baz=>['quix','quack']}){|obj| yielded.run(obj) }
|
144
144
|
end
|
@@ -148,7 +148,7 @@ describe ActiveFedora::Base do
|
|
148
148
|
describe '#find_in_batches' do
|
149
149
|
describe "with conditions hash" do
|
150
150
|
it "should filter by the provided fields" do
|
151
|
-
mock_docs =
|
151
|
+
mock_docs = double('docs')
|
152
152
|
mock_docs.should_receive(:has_next?).and_return(false)
|
153
153
|
ActiveFedora::SolrService.instance.conn.should_receive(:paginate).with() { |page, rows, method, hash|
|
154
154
|
page == 1 &&
|
@@ -162,7 +162,7 @@ describe ActiveFedora::Base do
|
|
162
162
|
hash[:params][:q].split(" AND ").include?("baz:\"quix\"") &&
|
163
163
|
hash[:params][:q].split(" AND ").include?("baz:\"quack\"")
|
164
164
|
}.and_return('response'=>{'docs'=>mock_docs})
|
165
|
-
yielded =
|
165
|
+
yielded = double("yielded method")
|
166
166
|
yielded.should_receive(:run).with(mock_docs)
|
167
167
|
SpecModel::Basic.find_in_batches({:foo=>'bar', :baz=>['quix','quack']}, {:batch_size=>1002, :fl=>'id'}){|group| yielded.run group }.should
|
168
168
|
end
|
@@ -191,7 +191,7 @@ describe ActiveFedora::Base do
|
|
191
191
|
|
192
192
|
describe '#find_with_conditions' do
|
193
193
|
it "should make a query to solr and return the results" do
|
194
|
-
mock_result =
|
194
|
+
mock_result = double('Result')
|
195
195
|
ActiveFedora::SolrService.should_receive(:query).with() { |args|
|
196
196
|
q = args.first if args.is_a? Array
|
197
197
|
q ||= args
|
@@ -204,7 +204,7 @@ describe ActiveFedora::Base do
|
|
204
204
|
end
|
205
205
|
|
206
206
|
it "should escape quotes" do
|
207
|
-
mock_result =
|
207
|
+
mock_result = double('Result')
|
208
208
|
ActiveFedora::SolrService.should_receive(:query).with() { |args|
|
209
209
|
q = args.first if args.is_a? Array
|
210
210
|
q ||= args
|
@@ -218,12 +218,12 @@ describe ActiveFedora::Base do
|
|
218
218
|
end
|
219
219
|
|
220
220
|
it "shouldn't use the class if it's called on AF:Base " do
|
221
|
-
mock_result =
|
221
|
+
mock_result = double('Result')
|
222
222
|
ActiveFedora::SolrService.should_receive(:query).with('baz:"quack"', {:sort => [@sort_query]}).and_return(mock_result)
|
223
223
|
ActiveFedora::Base.find_with_conditions(:baz=>'quack').should == mock_result
|
224
224
|
end
|
225
225
|
it "should use the query string if it's provided" do
|
226
|
-
mock_result =
|
226
|
+
mock_result = double('Result')
|
227
227
|
ActiveFedora::SolrService.should_receive(:query).with('chunky:monkey', {:sort => [@sort_query]}).and_return(mock_result)
|
228
228
|
ActiveFedora::Base.find_with_conditions('chunky:monkey').should == mock_result
|
229
229
|
end
|
data/spec/unit/rdf_list_spec.rb
CHANGED
@@ -39,7 +39,7 @@ describe ActiveFedora::RdfList do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "a new list" do
|
42
|
-
let (:ds) { DemoList.new(
|
42
|
+
let (:ds) { DemoList.new(double('inner object', :pid=>'foo', :new? =>true), 'descMetadata')}
|
43
43
|
subject { ds.elementList.build}
|
44
44
|
|
45
45
|
it "should insert at the end" do
|
@@ -102,7 +102,7 @@ END
|
|
102
102
|
|
103
103
|
describe "a list with content" do
|
104
104
|
subject do
|
105
|
-
subject = DemoList.new(
|
105
|
+
subject = DemoList.new(double('inner object', :pid=>'foo', :new? =>true), 'descMetadata')
|
106
106
|
subject.content =<<END
|
107
107
|
<rdf:RDF
|
108
108
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:mads="http://www.loc.gov/mads/rdf/v1#">
|
@@ -93,7 +93,7 @@ describe ActiveFedora::RdfxmlRDFDatastream do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
describe "a new instance" do
|
96
|
-
subject { MyDatastream.new(
|
96
|
+
subject { MyDatastream.new(double('inner object', :pid=>'test:1', :new? =>true), 'descMetadata', about:"http://library.ucsd.edu/ark:/20775/") }
|
97
97
|
it "should have a subject" do
|
98
98
|
subject.rdf_subject.to_s.should == "http://library.ucsd.edu/ark:/20775/"
|
99
99
|
end
|
@@ -102,7 +102,7 @@ describe ActiveFedora::RdfxmlRDFDatastream do
|
|
102
102
|
|
103
103
|
describe "an instance with content" do
|
104
104
|
subject do
|
105
|
-
subject = MyDatastream.new(
|
105
|
+
subject = MyDatastream.new(double('inner object', :pid=>'test:1', :new? =>true), 'descMetadata')
|
106
106
|
subject.content = File.new('spec/fixtures/damsObjectModel.xml').read
|
107
107
|
subject
|
108
108
|
end
|
@@ -14,8 +14,8 @@ describe ActiveFedora::RelsExtDatastream do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
before(:each) do
|
17
|
-
mock_inner =
|
18
|
-
@mock_repo =
|
17
|
+
mock_inner = double('inner object')
|
18
|
+
@mock_repo = double('repository')
|
19
19
|
@mock_repo.stub(:datastream_dissemination=>'My Content', :config=>{})
|
20
20
|
mock_inner.stub(:repository).and_return(@mock_repo)
|
21
21
|
mock_inner.stub(:pid).and_return(@pid)
|
@@ -37,7 +37,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
37
37
|
subject.changed?.should == false
|
38
38
|
end
|
39
39
|
it "should be true when the model has changes" do
|
40
|
-
subject.model =
|
40
|
+
subject.model = double(:relationships_are_dirty=>true)
|
41
41
|
subject.changed?.should == true
|
42
42
|
end
|
43
43
|
end
|
@@ -50,7 +50,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
50
50
|
subject = RDF::URI.new "info:fedora/test:sample_pid"
|
51
51
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:is_member_of), RDF::URI.new('demo:10'))
|
52
52
|
|
53
|
-
@test_ds.stub(:new? => true, :relationships_are_dirty? =>true, :relationships => graph, :model =>
|
53
|
+
@test_ds.stub(:new? => true, :relationships_are_dirty? =>true, :relationships => graph, :model => double(:relationships_are_dirty= => true))
|
54
54
|
@test_ds.serialize!
|
55
55
|
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
|
56
56
|
end
|
@@ -83,7 +83,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
83
83
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
|
84
84
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
|
85
85
|
|
86
|
-
@test_ds.should_receive(:model).and_return(
|
86
|
+
@test_ds.should_receive(:model).and_return(double("model", :relationships=>graph, :relationships_are_dirty= => true))
|
87
87
|
EquivalentXml.equivalent?(@test_ds.to_rels_ext(), @sample_rels_ext_xml).should be_true
|
88
88
|
end
|
89
89
|
|
@@ -96,7 +96,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
96
96
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:OtherModel"))
|
97
97
|
graph.insert RDF::Statement.new(subject, ActiveFedora::Predicates.find_graph_predicate(:has_model), RDF::URI.new("info:fedora/afmodel:SampleModel"))
|
98
98
|
|
99
|
-
@test_ds.stub(:model).and_return(
|
99
|
+
@test_ds.stub(:model).and_return(double("model", :relationships=>graph, :relationships_are_dirty= => true))
|
100
100
|
rels = @test_ds.to_rels_ext()
|
101
101
|
EquivalentXml.equivalent?(rels, @sample_rels_ext_xml).should be_true
|
102
102
|
rels.should_not =~ /fedora:isMemberOf/
|
@@ -45,11 +45,11 @@ describe ActiveFedora::SemanticNode do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
@node = SpecNode.new
|
48
|
-
@node.stub(:rels_ext).and_return(
|
48
|
+
@node.stub(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
|
49
49
|
@node.pid = increment_pid
|
50
50
|
@test_object = SpecNode2.new
|
51
51
|
@test_object.pid = increment_pid
|
52
|
-
@test_object.stub(:rels_ext).and_return(
|
52
|
+
@test_object.stub(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
|
53
53
|
end
|
54
54
|
|
55
55
|
after(:each) do
|
@@ -103,9 +103,9 @@ describe ActiveFedora::SemanticNode do
|
|
103
103
|
it "adding relationship to an instance should not affect class-level relationships hash" do
|
104
104
|
local_test_node1 = SpecNode.new
|
105
105
|
local_test_node2 = SpecNode.new
|
106
|
-
local_test_node1.stub(:rels_ext).and_return(
|
106
|
+
local_test_node1.stub(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
|
107
107
|
local_test_node1.add_relationship(:is_member_of, 'demo:10')
|
108
|
-
local_test_node2.stub(:rels_ext).and_return(
|
108
|
+
local_test_node2.stub(:rels_ext).and_return(double('rels-ext', :content=>''))
|
109
109
|
|
110
110
|
local_test_node1.relationships(:is_member_of).should == ["demo:10"]
|
111
111
|
local_test_node2.relationships(:is_member_of).should == []
|
@@ -135,7 +135,7 @@ describe ActiveFedora::SemanticNode do
|
|
135
135
|
|
136
136
|
describe '#remove_relationship' do
|
137
137
|
it 'should remove a relationship from the relationships hash' do
|
138
|
-
@test_object.stub(:rels_ext).and_return(
|
138
|
+
@test_object.stub(:rels_ext).and_return(double("rels_ext", :content_will_change! => true, :content=>''))
|
139
139
|
@test_object.add_relationship(:has_part, "info:fedora/3")
|
140
140
|
@test_object.add_relationship(:has_part, "info:fedora/4")
|
141
141
|
#check both are there
|
@@ -33,7 +33,7 @@ describe ActiveFedora do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should be used by ActiveFedora::Base#find_with_conditions" do
|
36
|
-
mock_response =
|
36
|
+
mock_response = double("SolrResponse")
|
37
37
|
ActiveFedora::SolrService.should_receive(:query).with("_query_:\"{!raw f=#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}}info:fedora/afmodel:SolrSpecModel_Basic\" AND " + SOLR_DOCUMENT_ID + ':"changeme\\:30"', {:sort => ["#{ActiveFedora::SolrService.solr_name("system_create", :stored_sortable, type: :date)} asc"]}).and_return(mock_response)
|
38
38
|
|
39
39
|
SolrSpecModel::Basic.find_with_conditions(:id=>"changeme:30").should equal(mock_response)
|
@@ -34,8 +34,8 @@ describe ActiveFedora::SolrService do
|
|
34
34
|
proc{ActiveFedora::SolrService.instance}.should raise_error(ActiveFedora::SolrNotInitialized)
|
35
35
|
end
|
36
36
|
|
37
|
-
describe "
|
38
|
-
before(:
|
37
|
+
describe "reify solr results" do
|
38
|
+
before(:all) do
|
39
39
|
class AudioRecord
|
40
40
|
attr_accessor :pid
|
41
41
|
def init_with(inner_obj)
|
@@ -46,14 +46,36 @@ describe ActiveFedora::SolrService do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
@sample_solr_hits = [{"id"=>"my:_PID1_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["info:fedora/afmodel:AudioRecord"]},
|
49
|
-
|
50
|
-
|
49
|
+
{"id"=>"my:_PID2_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["info:fedora/afmodel:AudioRecord"]},
|
50
|
+
{"id"=>"my:_PID3_", ActiveFedora::SolrService.solr_name("has_model", :symbol)=>["info:fedora/afmodel:AudioRecord"]}]
|
51
51
|
end
|
52
|
-
|
53
|
-
AudioRecord.
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
describe ".reify_solr_results" do
|
53
|
+
it "should use AudioRecord.find to instantiate objects" do
|
54
|
+
AudioRecord.should_receive(:find).with("my:_PID1_")
|
55
|
+
AudioRecord.should_receive(:find).with("my:_PID2_")
|
56
|
+
AudioRecord.should_receive(:find).with("my:_PID3_")
|
57
|
+
ActiveFedora::SolrService.reify_solr_results(@sample_solr_hits)
|
58
|
+
end
|
59
|
+
it "should use AudioRecord.load_instance_from_solr when called with :load_from_solr option" do
|
60
|
+
AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID1_")
|
61
|
+
AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID2_")
|
62
|
+
AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID3_")
|
63
|
+
ActiveFedora::SolrService.reify_solr_results(@sample_solr_hits, load_from_solr: true)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
describe ".lazy_reify_solr_results" do
|
67
|
+
it "should lazily reify solr results" do
|
68
|
+
AudioRecord.should_receive(:find).with("my:_PID1_")
|
69
|
+
AudioRecord.should_receive(:find).with("my:_PID2_")
|
70
|
+
AudioRecord.should_receive(:find).with("my:_PID3_")
|
71
|
+
ActiveFedora::SolrService.lazy_reify_solr_results(@sample_solr_hits).each {|r| r}
|
72
|
+
end
|
73
|
+
it "should use AudioRecord.load_instance_from_solr when called with :load_from_solr option" do
|
74
|
+
AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID1_")
|
75
|
+
AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID2_")
|
76
|
+
AudioRecord.should_receive(:load_instance_from_solr).with("my:_PID3_")
|
77
|
+
ActiveFedora::SolrService.lazy_reify_solr_results(@sample_solr_hits, load_from_solr: true).each {|r| r}
|
78
|
+
end
|
57
79
|
end
|
58
80
|
end
|
59
81
|
|
@@ -76,44 +98,44 @@ describe ActiveFedora::SolrService do
|
|
76
98
|
|
77
99
|
describe ".query" do
|
78
100
|
it "should call solr" do
|
79
|
-
mock_conn =
|
80
|
-
stub_result =
|
101
|
+
mock_conn = double("Connection")
|
102
|
+
stub_result = double("Result")
|
81
103
|
mock_conn.should_receive(:get).with('select', :params=>{:q=>'querytext', :qt=>'standard'}).and_return(stub_result)
|
82
|
-
ActiveFedora::SolrService.stub(:instance =>
|
104
|
+
ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
|
83
105
|
ActiveFedora::SolrService.query('querytext', :raw=>true).should == stub_result
|
84
106
|
end
|
85
107
|
end
|
86
108
|
describe ".count" do
|
87
109
|
it "should return a count of matching records" do
|
88
|
-
mock_conn =
|
110
|
+
mock_conn = double("Connection")
|
89
111
|
stub_result = {'response' => {'numFound'=>'7'}}
|
90
112
|
mock_conn.should_receive(:get).with('select', :params=>{:rows=>0, :q=>'querytext', :qt=>'standard'}).and_return(stub_result)
|
91
|
-
ActiveFedora::SolrService.stub(:instance =>
|
113
|
+
ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
|
92
114
|
ActiveFedora::SolrService.count('querytext').should == 7
|
93
115
|
end
|
94
116
|
it "should accept query args" do
|
95
|
-
mock_conn =
|
117
|
+
mock_conn = double("Connection")
|
96
118
|
stub_result = {'response' => {'numFound'=>'7'}}
|
97
119
|
mock_conn.should_receive(:get).with('select', :params=>{:rows=>0, :q=>'querytext', :qt=>'standard', :fq=>'filter'}).and_return(stub_result)
|
98
|
-
ActiveFedora::SolrService.stub(:instance =>
|
120
|
+
ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
|
99
121
|
ActiveFedora::SolrService.count('querytext', :fq=>'filter', :rows=>10).should == 7
|
100
122
|
end
|
101
123
|
end
|
102
124
|
describe ".add" do
|
103
125
|
it "should call solr" do
|
104
|
-
mock_conn =
|
126
|
+
mock_conn = double("Connection")
|
105
127
|
doc = {'id' => '1234'}
|
106
128
|
mock_conn.should_receive(:add).with(doc)
|
107
|
-
ActiveFedora::SolrService.stub(:instance =>
|
129
|
+
ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
|
108
130
|
ActiveFedora::SolrService.add(doc)
|
109
131
|
end
|
110
132
|
end
|
111
133
|
describe ".commit" do
|
112
134
|
it "should call solr" do
|
113
|
-
mock_conn =
|
135
|
+
mock_conn = double("Connection")
|
114
136
|
doc = {'id' => '1234'}
|
115
137
|
mock_conn.should_receive(:commit)
|
116
|
-
ActiveFedora::SolrService.stub(:instance =>
|
138
|
+
ActiveFedora::SolrService.stub(:instance =>double("instance", :conn=>mock_conn))
|
117
139
|
ActiveFedora::SolrService.commit()
|
118
140
|
end
|
119
141
|
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: 6.4.
|
4
|
+
version: 6.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-07-
|
13
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -120,16 +120,16 @@ dependencies:
|
|
120
120
|
name: rdf-rdfxml
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - '='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.0.
|
125
|
+
version: 1.0.1
|
126
126
|
type: :runtime
|
127
127
|
prerelease: false
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - '='
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 1.0.
|
132
|
+
version: 1.0.1
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: deprecation
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
@@ -394,8 +394,6 @@ files:
|
|
394
394
|
- script/destroy
|
395
395
|
- script/generate
|
396
396
|
- spec/config_helper.rb
|
397
|
-
- spec/fixtures/auditable.foxml.xml
|
398
|
-
- spec/fixtures/changeme155.xml
|
399
397
|
- spec/fixtures/damsObjectModel.xml
|
400
398
|
- spec/fixtures/dino.jpg
|
401
399
|
- spec/fixtures/dino_jpg_no_file_ext
|
@@ -412,11 +410,8 @@ files:
|
|
412
410
|
- spec/fixtures/rails_root/config/solr_mappings_bl_2.4.yml
|
413
411
|
- spec/fixtures/sharded_fedora.yml
|
414
412
|
- spec/fixtures/solr_rdf_descMetadata.nt
|
415
|
-
- spec/fixtures/test_12.foxml.xml
|
416
|
-
- spec/fixtures/test_fixture_mods_article1.foxml.xml
|
417
|
-
- spec/fixtures/test_fixture_mods_article2.foxml.xml
|
418
|
-
- spec/hydrangea_fixture_mods_article1.foxml.xml
|
419
413
|
- spec/integration/associations_spec.rb
|
414
|
+
- spec/integration/auditable_spec.rb
|
420
415
|
- spec/integration/base_spec.rb
|
421
416
|
- spec/integration/bug_spec.rb
|
422
417
|
- spec/integration/complex_rdf_datastream_spec.rb
|
@@ -427,7 +422,6 @@ files:
|
|
427
422
|
- spec/integration/full_featured_model_spec.rb
|
428
423
|
- spec/integration/has_many_associations_spec.rb
|
429
424
|
- spec/integration/model_spec.rb
|
430
|
-
- spec/integration/mods_article_integration_spec.rb
|
431
425
|
- spec/integration/nested_attribute_spec.rb
|
432
426
|
- spec/integration/ntriples_datastream_spec.rb
|
433
427
|
- spec/integration/om_datastream_spec.rb
|
@@ -486,7 +480,6 @@ files:
|
|
486
480
|
- spec/support/mock_fedora.rb
|
487
481
|
- spec/unit/active_fedora_spec.rb
|
488
482
|
- spec/unit/association_proxy_spec.rb
|
489
|
-
- spec/unit/auditable_spec.rb
|
490
483
|
- spec/unit/base_active_model_spec.rb
|
491
484
|
- spec/unit/base_cma_spec.rb
|
492
485
|
- spec/unit/base_datastream_management_spec.rb
|
@@ -536,7 +529,8 @@ files:
|
|
536
529
|
- spec/unit/unsaved_digital_object_spec.rb
|
537
530
|
- spec/unit/validations_spec.rb
|
538
531
|
homepage: https://github.com/projecthydra/active_fedora
|
539
|
-
licenses:
|
532
|
+
licenses:
|
533
|
+
- APACHE2
|
540
534
|
metadata: {}
|
541
535
|
post_install_message:
|
542
536
|
rdoc_options: []
|
@@ -560,8 +554,6 @@ specification_version: 4
|
|
560
554
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|
561
555
|
test_files:
|
562
556
|
- spec/config_helper.rb
|
563
|
-
- spec/fixtures/auditable.foxml.xml
|
564
|
-
- spec/fixtures/changeme155.xml
|
565
557
|
- spec/fixtures/damsObjectModel.xml
|
566
558
|
- spec/fixtures/dino.jpg
|
567
559
|
- spec/fixtures/dino_jpg_no_file_ext
|
@@ -578,11 +570,8 @@ test_files:
|
|
578
570
|
- spec/fixtures/rails_root/config/solr_mappings_bl_2.4.yml
|
579
571
|
- spec/fixtures/sharded_fedora.yml
|
580
572
|
- spec/fixtures/solr_rdf_descMetadata.nt
|
581
|
-
- spec/fixtures/test_12.foxml.xml
|
582
|
-
- spec/fixtures/test_fixture_mods_article1.foxml.xml
|
583
|
-
- spec/fixtures/test_fixture_mods_article2.foxml.xml
|
584
|
-
- spec/hydrangea_fixture_mods_article1.foxml.xml
|
585
573
|
- spec/integration/associations_spec.rb
|
574
|
+
- spec/integration/auditable_spec.rb
|
586
575
|
- spec/integration/base_spec.rb
|
587
576
|
- spec/integration/bug_spec.rb
|
588
577
|
- spec/integration/complex_rdf_datastream_spec.rb
|
@@ -593,7 +582,6 @@ test_files:
|
|
593
582
|
- spec/integration/full_featured_model_spec.rb
|
594
583
|
- spec/integration/has_many_associations_spec.rb
|
595
584
|
- spec/integration/model_spec.rb
|
596
|
-
- spec/integration/mods_article_integration_spec.rb
|
597
585
|
- spec/integration/nested_attribute_spec.rb
|
598
586
|
- spec/integration/ntriples_datastream_spec.rb
|
599
587
|
- spec/integration/om_datastream_spec.rb
|
@@ -652,7 +640,6 @@ test_files:
|
|
652
640
|
- spec/support/mock_fedora.rb
|
653
641
|
- spec/unit/active_fedora_spec.rb
|
654
642
|
- spec/unit/association_proxy_spec.rb
|
655
|
-
- spec/unit/auditable_spec.rb
|
656
643
|
- spec/unit/base_active_model_spec.rb
|
657
644
|
- spec/unit/base_cma_spec.rb
|
658
645
|
- spec/unit/base_datastream_management_spec.rb
|