active-fedora 8.2.1 → 8.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/active-fedora.gemspec +1 -2
- data/lib/active_fedora/datastream_collections.rb +4 -8
- data/lib/active_fedora/datastreams.rb +7 -9
- data/lib/active_fedora/version.rb +1 -1
- data/spec/config_helper.rb +3 -3
- data/spec/integration/associations_spec.rb +76 -76
- data/spec/integration/auditable_spec.rb +7 -7
- data/spec/integration/autosave_association_spec.rb +3 -3
- data/spec/integration/base_spec.rb +51 -51
- data/spec/integration/belongs_to_association_spec.rb +27 -27
- data/spec/integration/bug_spec.rb +1 -1
- data/spec/integration/collection_association_spec.rb +2 -2
- data/spec/integration/complex_rdf_datastream_spec.rb +32 -32
- data/spec/integration/datastream_collections_spec.rb +42 -42
- data/spec/integration/datastream_spec.rb +19 -19
- data/spec/integration/datastreams_spec.rb +25 -25
- data/spec/integration/delete_all_spec.rb +5 -5
- data/spec/integration/fedora_solr_sync_spec.rb +1 -1
- data/spec/integration/full_featured_model_spec.rb +9 -9
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +46 -47
- data/spec/integration/has_many_associations_spec.rb +17 -17
- data/spec/integration/json_serialization_spec.rb +2 -2
- data/spec/integration/load_from_solr_spec.rb +1 -1
- data/spec/integration/model_spec.rb +9 -9
- data/spec/integration/nested_attribute_spec.rb +17 -17
- data/spec/integration/ntriples_datastream_spec.rb +43 -43
- data/spec/integration/om_datastream_spec.rb +37 -37
- data/spec/integration/persistence_spec.rb +1 -1
- data/spec/integration/rdf_nested_attributes_spec.rb +9 -9
- data/spec/integration/relation_delegation_spec.rb +7 -7
- data/spec/integration/relation_spec.rb +2 -2
- data/spec/integration/rels_ext_datastream_spec.rb +3 -3
- data/spec/integration/scoped_query_spec.rb +14 -14
- data/spec/integration/solr_service_spec.rb +24 -24
- data/spec/support/mock_fedora.rb +9 -10
- data/spec/unit/active_fedora_spec.rb +20 -20
- data/spec/unit/attributes_spec.rb +24 -24
- data/spec/unit/base_active_model_spec.rb +6 -6
- data/spec/unit/base_cma_spec.rb +2 -2
- data/spec/unit/base_datastream_management_spec.rb +7 -7
- data/spec/unit/base_extra_spec.rb +20 -20
- data/spec/unit/base_spec.rb +141 -141
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
- data/spec/unit/callback_spec.rb +12 -12
- data/spec/unit/code_configurator_spec.rb +7 -7
- data/spec/unit/config_spec.rb +2 -2
- data/spec/unit/content_model_spec.rb +19 -20
- data/spec/unit/core_spec.rb +1 -1
- data/spec/unit/datastream_collections_spec.rb +101 -101
- data/spec/unit/datastream_spec.rb +12 -12
- data/spec/unit/datastreams_spec.rb +39 -39
- data/spec/unit/file_configurator_spec.rb +117 -117
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +16 -16
- data/spec/unit/has_many_collection_spec.rb +5 -5
- data/spec/unit/inheritance_spec.rb +5 -5
- data/spec/unit/model_spec.rb +5 -5
- data/spec/unit/nom_datastream_spec.rb +5 -5
- data/spec/unit/ntriples_datastream_spec.rb +56 -56
- data/spec/unit/om_datastream_spec.rb +99 -99
- data/spec/unit/persistence_spec.rb +2 -2
- data/spec/unit/predicates_spec.rb +28 -28
- data/spec/unit/property_spec.rb +5 -5
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +10 -10
- data/spec/unit/query_spec.rb +66 -66
- data/spec/unit/rdf_datastream_spec.rb +10 -10
- data/spec/unit/rdf_resource_datastream_spec.rb +2 -2
- data/spec/unit/rdf_xml_writer_spec.rb +3 -3
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +9 -9
- data/spec/unit/relationship_graph_spec.rb +31 -31
- data/spec/unit/reload_on_save_spec.rb +3 -3
- data/spec/unit/rels_ext_datastream_spec.rb +28 -28
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +11 -11
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +7 -7
- data/spec/unit/rubydora_connection_spec.rb +3 -3
- data/spec/unit/semantic_node_spec.rb +17 -17
- data/spec/unit/serializers_spec.rb +1 -1
- data/spec/unit/service_definitions_spec.rb +11 -11
- data/spec/unit/simple_datastream_spec.rb +6 -6
- data/spec/unit/solr_config_options_spec.rb +10 -10
- data/spec/unit/solr_digital_object_spec.rb +4 -4
- data/spec/unit/solr_service_spec.rb +41 -41
- data/spec/unit/unsaved_digital_object_spec.rb +8 -8
- data/spec/unit/validations_spec.rb +6 -6
- metadata +4 -4
@@ -16,7 +16,7 @@ describe "persisting objects" do
|
|
16
16
|
|
17
17
|
describe "#create!" do
|
18
18
|
it "should validate" do
|
19
|
-
|
19
|
+
expect { MockAFBaseRelationship.create!}.to raise_error ActiveFedora::RecordInvalid, "Validation failed: Name can't be blank"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -100,14 +100,14 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
100
100
|
subject { ComplexRDFDatastream::PersonalName.new(RDF::Graph.new) }
|
101
101
|
it "should accept a hash" do
|
102
102
|
subject.elementList_attributes = [{ topicElement_attributes: {'0' => { elementValue:"Quantum Behavior" }, '1' => { elementValue:"Wave Function" }}}]
|
103
|
-
subject.elementList.first[0].elementValue.
|
104
|
-
subject.elementList.first[1].elementValue.
|
103
|
+
expect(subject.elementList.first[0].elementValue).to eq(["Quantum Behavior"])
|
104
|
+
expect(subject.elementList.first[1].elementValue).to eq(["Wave Function"])
|
105
105
|
|
106
106
|
end
|
107
107
|
it "should accept an array" do
|
108
108
|
subject.elementList_attributes = [{ topicElement_attributes: [{ elementValue:"Quantum Behavior" }, { elementValue:"Wave Function" }]}]
|
109
|
-
subject.elementList.first[0].elementValue.
|
110
|
-
subject.elementList.first[1].elementValue.
|
109
|
+
expect(subject.elementList.first[0].elementValue).to eq(["Quantum Behavior"])
|
110
|
+
expect(subject.elementList.first[1].elementValue).to eq(["Wave Function"])
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -118,10 +118,10 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'should have attributes' do
|
121
|
-
subject.topic[0].elementList.first[0].elementValue.
|
122
|
-
subject.topic[1].elementList.first[0].elementValue.
|
123
|
-
subject.personalName.first.elementList.first.fullNameElement.
|
124
|
-
subject.personalName.first.elementList.first.dateNameElement.
|
121
|
+
expect(subject.topic[0].elementList.first[0].elementValue).to eq(["Cosmology"])
|
122
|
+
expect(subject.topic[1].elementList.first[0].elementValue).to eq(["Quantum Behavior"])
|
123
|
+
expect(subject.personalName.first.elementList.first.fullNameElement).to eq(["Jefferson, Thomas"])
|
124
|
+
expect(subject.personalName.first.elementList.first.dateNameElement).to eq(["1743-1826"])
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'should build nodes with ids' do
|
@@ -171,7 +171,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
171
171
|
it "should update nested objects" do
|
172
172
|
subject.parts_attributes= [{id: replace_object_id, label: "Universal Joint"}, {label:"Oil Pump"}, {id: remove_object_id, _destroy: '1', label: "bar1 uno"}]
|
173
173
|
|
174
|
-
subject.parts.map{|p| p.label.first}.
|
174
|
+
expect(subject.parts.map{|p| p.label.first}).to eq(['Alternator', 'Universal Joint', 'Transmission', 'Oil Pump'])
|
175
175
|
|
176
176
|
end
|
177
177
|
it "create a new object when the id is provided" do
|
@@ -38,27 +38,27 @@ describe ActiveFedora::Model do
|
|
38
38
|
subject { ModelIntegrationSpec::Basic.where(bar: 'Peanuts') }
|
39
39
|
|
40
40
|
it "should map" do
|
41
|
-
subject.map(&:id).
|
41
|
+
expect(subject.map(&:id)).to eq([instance2.id, instance3.id])
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should collect" do
|
45
|
-
subject.collect(&:id).
|
45
|
+
expect(subject.collect(&:id)).to eq([instance2.id, instance3.id])
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should have each" do
|
49
49
|
t = double
|
50
|
-
t.
|
50
|
+
expect(t).to receive(:foo).twice
|
51
51
|
subject.each { t.foo }
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should have all?" do
|
55
|
-
expect(subject.all? { |t| t.foo == ['Alpha']}).to
|
56
|
-
expect(subject.all? { |t| t.bar == ['Peanuts']}).to
|
55
|
+
expect(subject.all? { |t| t.foo == ['Alpha']}).to be_falsey
|
56
|
+
expect(subject.all? { |t| t.bar == ['Peanuts']}).to be_truthy
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should have include?" do
|
60
|
-
expect(subject.include?(instance1)).to
|
61
|
-
expect(subject.include?(instance2)).to
|
60
|
+
expect(subject.include?(instance1)).to be_falsey
|
61
|
+
expect(subject.include?(instance2)).to be_truthy
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -14,7 +14,7 @@ describe ActiveFedora::Base do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
subject { Library.all }
|
17
|
-
its(:class) {
|
17
|
+
its(:class) {is_expected.to eq ActiveFedora::Relation }
|
18
18
|
|
19
19
|
before :all do
|
20
20
|
Library.create
|
@@ -32,7 +32,7 @@ describe ActiveFedora::Base do
|
|
32
32
|
expect(subject).to be_loaded
|
33
33
|
end
|
34
34
|
it "shouldn't reload" do
|
35
|
-
ActiveFedora::Relation.
|
35
|
+
expect_any_instance_of(ActiveFedora::Relation).not_to receive :find_each
|
36
36
|
subject[0]
|
37
37
|
end
|
38
38
|
end
|
@@ -60,7 +60,7 @@ describe ActiveFedora::RelsExtDatastream do
|
|
60
60
|
rexml1 = REXML::Document.new(@test_datastream.to_rels_ext())
|
61
61
|
@test_datastream.serialize!
|
62
62
|
rexml2 = REXML::Document.new(@test_object.datastreams["RELS-EXT"].content)
|
63
|
-
rexml1.root.elements["rdf:Description"].inspect.
|
63
|
+
expect(rexml1.root.elements["rdf:Description"].inspect).to eql(rexml2.root.elements["rdf:Description"].inspect)
|
64
64
|
end
|
65
65
|
|
66
66
|
end
|
@@ -72,11 +72,11 @@ describe ActiveFedora::RelsExtDatastream do
|
|
72
72
|
end
|
73
73
|
@test_object.save
|
74
74
|
# make sure that _something_ was actually added to the object's relationships hash
|
75
|
-
@test_object.ids_for_outbound(:is_member_of).size.
|
75
|
+
expect(@test_object.ids_for_outbound(:is_member_of).size).to eq(1)
|
76
76
|
new_rels = ActiveFedora::Base.find(@test_object.pid).relationships
|
77
77
|
# This stopped working, need to push an issue into the rdf library. (when dumping ntriples, the order of assertions changed)
|
78
78
|
#new_rels.should == @test_object.relationships
|
79
|
-
new_rels.dump(:rdfxml).
|
79
|
+
expect(new_rels.dump(:rdfxml)).to eq(@test_object.relationships.dump(:rdfxml))
|
80
80
|
end
|
81
81
|
|
82
82
|
end
|
@@ -39,18 +39,18 @@ describe "scoped queries" do
|
|
39
39
|
describe ".all" do
|
40
40
|
it "should return an array of instances of the calling Class" do
|
41
41
|
result = ModelIntegrationSpec::Basic.all.to_a
|
42
|
-
result.
|
42
|
+
expect(result).to be_instance_of(Array)
|
43
43
|
# this test is meaningless if the array length is zero
|
44
|
-
result.length.
|
44
|
+
expect(result.length).to be > 0
|
45
45
|
result.each do |obj|
|
46
|
-
obj.class.
|
46
|
+
expect(obj.class).to eq(ModelIntegrationSpec::Basic)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe ".first" do
|
52
52
|
it "should return one instance of the calling class" do
|
53
|
-
ModelIntegrationSpec::Basic.first.
|
53
|
+
expect(ModelIntegrationSpec::Basic.first).to eq(test_instance)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -67,33 +67,33 @@ describe "scoped queries" do
|
|
67
67
|
test_instance3.delete
|
68
68
|
end
|
69
69
|
it "should query" do
|
70
|
-
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta').
|
71
|
-
ModelIntegrationSpec::Basic.where('foo' => 'Beta').
|
70
|
+
expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta')).to eq([test_instance1])
|
71
|
+
expect(ModelIntegrationSpec::Basic.where('foo' => 'Beta')).to eq([test_instance1])
|
72
72
|
end
|
73
73
|
it "should order" do
|
74
|
-
ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').
|
74
|
+
expect(ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc')).to eq([test_instance2, test_instance1, test_instance3])
|
75
75
|
end
|
76
76
|
it "should limit" do
|
77
|
-
ModelIntegrationSpec::Basic.limit(1).
|
77
|
+
expect(ModelIntegrationSpec::Basic.limit(1)).to eq([test_instance1])
|
78
78
|
end
|
79
79
|
it "should offset" do
|
80
|
-
ModelIntegrationSpec::Basic.offset(1).
|
80
|
+
expect(ModelIntegrationSpec::Basic.offset(1)).to eq([test_instance2, test_instance3])
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should chain queries" do
|
84
|
-
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1).
|
84
|
+
expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1)).to eq([test_instance2])
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should wrap string conditions with parentheses" do
|
88
|
-
ModelIntegrationSpec::Basic.where("foo:bar OR bar:baz").where_values.
|
88
|
+
expect(ModelIntegrationSpec::Basic.where("foo:bar OR bar:baz").where_values).to eq(["(foo:bar OR bar:baz)"])
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should chain where queries" do
|
92
|
-
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').where("#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar").where_values.
|
92
|
+
expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').where("#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar").where_values).to eq(["#{ActiveFedora::SolrService.solr_name('bar', type: :string)}:Peanuts", "(#{ActiveFedora::SolrService.solr_name('foo', type: :string)}:bar)"])
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should chain count" do
|
96
|
-
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count.
|
96
|
+
expect(ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count).to eq(2)
|
97
97
|
end
|
98
98
|
|
99
99
|
it "calling first should not affect the relation's ability to get all results later" do
|
@@ -125,7 +125,7 @@ describe "scoped queries" do
|
|
125
125
|
end
|
126
126
|
it "should log an error" do
|
127
127
|
expect(ActiveFedora::Base.logger).to receive(:error).with("Although #{pid} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch.")
|
128
|
-
ModelIntegrationSpec::Basic.all.
|
128
|
+
expect(ModelIntegrationSpec::Basic.all).to eq([test_instance1, test_instance3])
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
@@ -39,9 +39,9 @@ describe ActiveFedora::SolrService do
|
|
39
39
|
query = "id\:#{RSolr.solr_escape(@test_object.pid)} OR id\:#{RSolr.solr_escape(@foo_object.pid)}"
|
40
40
|
solr_result = ActiveFedora::SolrService.query(query)
|
41
41
|
result = ActiveFedora::SolrService.reify_solr_results(solr_result)
|
42
|
-
result.length.
|
42
|
+
expect(result.length).to eq(2)
|
43
43
|
result.each do |r|
|
44
|
-
(r.class == ActiveFedora::Base || r.class == FooObject).
|
44
|
+
expect(r.class == ActiveFedora::Base || r.class == FooObject).to be_truthy
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -49,21 +49,21 @@ describe ActiveFedora::SolrService do
|
|
49
49
|
query = "id\:#{RSolr.solr_escape(@test_object.pid)} OR id\:#{RSolr.solr_escape(@foo_object.pid)}"
|
50
50
|
solr_result = ActiveFedora::SolrService.query(query)
|
51
51
|
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
52
|
-
result.length.
|
52
|
+
expect(result.length).to eq(2)
|
53
53
|
result.each do |r|
|
54
|
-
r.inner_object.
|
55
|
-
[ActiveFedora::Base, FooObject].
|
56
|
-
['test_object','foo_object'].
|
57
|
-
@test_object.inner_object.profile.
|
58
|
-
@foo_object.inner_object.profile.
|
59
|
-
@foo_object.datastreams['descMetadata'].profile.
|
60
|
-
@foo_object.datastreams['descMetadata'].content.
|
54
|
+
expect(r.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
|
55
|
+
expect([ActiveFedora::Base, FooObject]).to include(r.class)
|
56
|
+
expect(['test_object','foo_object']).to include(r.label)
|
57
|
+
expect(@test_object.inner_object.profile).to eq(@profiles['test'])
|
58
|
+
expect(@foo_object.inner_object.profile).to eq(@profiles['foo'])
|
59
|
+
expect(@foo_object.datastreams['descMetadata'].profile).to eq(@profiles['foo_descMetadata'])
|
60
|
+
expect(@foo_object.datastreams['descMetadata'].content).to be_equivalent_to(@foo_content)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'should instantiate all datastreams in the solr doc, even ones undeclared by the class' do
|
65
65
|
obj = ActiveFedora::Base.load_instance_from_solr @foo_object.pid
|
66
|
-
obj.datastreams.keys.
|
66
|
+
expect(obj.datastreams.keys).to include('descMetadata')
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should #reify a lightweight object as a new instance' do
|
@@ -72,10 +72,10 @@ describe ActiveFedora::SolrService do
|
|
72
72
|
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
73
73
|
solr_foo = result.first
|
74
74
|
real_foo = solr_foo.reify
|
75
|
-
solr_foo.inner_object.
|
76
|
-
real_foo.inner_object.
|
77
|
-
solr_foo.label.
|
78
|
-
real_foo.label.
|
75
|
+
expect(solr_foo.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
|
76
|
+
expect(real_foo.inner_object).to be_a(ActiveFedora::DigitalObject)
|
77
|
+
expect(solr_foo.label).to eq('foo_object')
|
78
|
+
expect(real_foo.label).to eq('foo_object')
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should #reify! a lightweight object within the same instance' do
|
@@ -83,10 +83,10 @@ describe ActiveFedora::SolrService do
|
|
83
83
|
solr_result = ActiveFedora::SolrService.query(query)
|
84
84
|
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
85
85
|
solr_foo = result.first
|
86
|
-
solr_foo.inner_object.
|
86
|
+
expect(solr_foo.inner_object).to be_a(ActiveFedora::SolrDigitalObject)
|
87
87
|
solr_foo.reify!
|
88
|
-
solr_foo.inner_object.
|
89
|
-
solr_foo.label.
|
88
|
+
expect(solr_foo.inner_object).to be_a(ActiveFedora::DigitalObject)
|
89
|
+
expect(solr_foo.label).to eq('foo_object')
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'should raise an exception when attempting to reify a first-class object' do
|
@@ -94,17 +94,17 @@ describe ActiveFedora::SolrService do
|
|
94
94
|
solr_result = ActiveFedora::SolrService.query(query)
|
95
95
|
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
96
96
|
solr_foo = result.first
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
97
|
+
expect {solr_foo.reify}.not_to raise_exception
|
98
|
+
expect {solr_foo.reify!}.not_to raise_exception
|
99
|
+
expect {solr_foo.reify!}.to raise_exception(/already a full/)
|
100
|
+
expect {solr_foo.reify}.to raise_exception(/already a full/)
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should call load_instance_from_solr if :load_from_solr option passed in' do
|
104
104
|
query = "id\:#{RSolr.solr_escape(@test_object.pid)} OR id\:#{RSolr.solr_escape(@foo_object.pid)}"
|
105
105
|
solr_result = ActiveFedora::SolrService.query(query)
|
106
|
-
ActiveFedora::Base.
|
107
|
-
FooObject.
|
106
|
+
expect(ActiveFedora::Base).to receive(:load_instance_from_solr).once
|
107
|
+
expect(FooObject).to receive(:load_instance_from_solr).once
|
108
108
|
result = ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
|
109
109
|
end
|
110
110
|
|
data/spec/support/mock_fedora.rb
CHANGED
@@ -2,34 +2,34 @@ def mock_client
|
|
2
2
|
return @mock_client if @mock_client
|
3
3
|
@mock_client = double("client")
|
4
4
|
@getter = double("getter")
|
5
|
-
@getter.
|
6
|
-
@mock_client.
|
5
|
+
allow(@getter).to receive(:get).and_return('')
|
6
|
+
allow(@mock_client).to receive(:[]).with("describe?xml=true").and_return('')
|
7
7
|
@mock_client
|
8
8
|
end
|
9
9
|
|
10
10
|
def stub_get(pid, datastreams=nil, record_exists=false)
|
11
11
|
pid.gsub!(/:/, '%3A')
|
12
12
|
if record_exists
|
13
|
-
mock_client.
|
13
|
+
allow(mock_client).to receive(:[]).with("objects/#{pid}?format=xml").and_return(double('get getter', :get=>'foobar'))
|
14
14
|
else
|
15
|
-
mock_client.
|
15
|
+
allow(mock_client).to receive(:[]).with("objects/#{pid}?format=xml").and_raise(RestClient::ResourceNotFound)
|
16
16
|
end
|
17
|
-
mock_client.
|
17
|
+
allow(mock_client).to receive(:[]).with("objects/#{pid}/datastreams?format=xml").and_return(@getter)
|
18
18
|
datastreams ||= ['someData', 'withText', 'withText2', 'RELS-EXT']
|
19
19
|
datastreams.each do |dsid|
|
20
|
-
mock_client.
|
20
|
+
allow(mock_client).to receive(:[]).with("objects/#{pid}/datastreams/#{dsid}?format=xml").and_return(@getter)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def stub_ingest(pid=nil)
|
25
25
|
n = pid ? pid.gsub(/:/, '%3A') : nil
|
26
|
-
mock_client.
|
26
|
+
expect(mock_client).to receive(:[]).with("objects/#{n || 'new'}").and_return(double("ingester", :post=>pid))
|
27
27
|
end
|
28
28
|
|
29
29
|
def stub_add_ds(pid, dsids)
|
30
30
|
pid.gsub!(/:/, '%3A')
|
31
31
|
dsids.each do |dsid|
|
32
|
-
client = mock_client.
|
32
|
+
client = allow(mock_client).to receive(:[]) do |params|
|
33
33
|
/objects\/#{pid}\/datastreams\/#{dsid}/.match(params)
|
34
34
|
end
|
35
35
|
client.and_return(double("ds_adder", :post=>pid, :get=>''))
|
@@ -39,7 +39,6 @@ end
|
|
39
39
|
def stub_get_content(pid, dsids)
|
40
40
|
pid.gsub!(/:/, '%3A')
|
41
41
|
dsids.each do |dsid|
|
42
|
-
mock_client.
|
42
|
+
allow(mock_client).to receive(:[]) { |params| /objects\/#{pid}\/datastreams\/#{dsid}\/content/.match(params)}.and_return(double("content_accessor", :post=>pid, :get=>''))
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
@@ -14,36 +14,36 @@ describe ActiveFedora do
|
|
14
14
|
describe "initialization methods" do
|
15
15
|
describe "environment" do
|
16
16
|
it "should use config_options[:environment] if set" do
|
17
|
-
ActiveFedora.
|
18
|
-
ActiveFedora.environment.
|
17
|
+
allow(ActiveFedora).to receive_messages(:config_options => {:environment=>"ballyhoo"})
|
18
|
+
expect(ActiveFedora.environment).to eql("ballyhoo")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should use Rails.env if no config_options and Rails.env is set" do
|
22
22
|
stub_rails(:env => "bedbugs")
|
23
|
-
ActiveFedora.
|
24
|
-
ActiveFedora.environment.
|
23
|
+
allow(ActiveFedora).to receive_messages(:config_options => {})
|
24
|
+
expect(ActiveFedora.environment).to eql("bedbugs")
|
25
25
|
unstub_rails
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should use ENV['environment'] if neither config_options nor Rails.env are set" do
|
29
29
|
ENV['environment'] = "wichita"
|
30
|
-
ActiveFedora.
|
31
|
-
ActiveFedora.environment.
|
30
|
+
allow(ActiveFedora).to receive_messages(:config_options => {})
|
31
|
+
expect(ActiveFedora.environment).to eql("wichita")
|
32
32
|
ENV['environment']='test'
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should use ENV['RAILS_ENV'] and log a warning if none of the above are set" do
|
36
36
|
ENV['environment']=nil
|
37
37
|
ENV['RAILS_ENV'] = "rails_env"
|
38
|
-
|
38
|
+
expect {ActiveFedora.environment}.to raise_error(RuntimeError, "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'")
|
39
39
|
ENV['environment']='test'
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should be development if none of the above are present" do
|
43
43
|
ENV['environment']=nil
|
44
44
|
ENV['RAILS_ENV'] = nil
|
45
|
-
ActiveFedora.
|
46
|
-
ActiveFedora.environment.
|
45
|
+
allow(ActiveFedora).to receive_messages(:config_options => {})
|
46
|
+
expect(ActiveFedora.environment).to eq('development')
|
47
47
|
ENV['environment']="test"
|
48
48
|
end
|
49
49
|
end
|
@@ -59,7 +59,7 @@ describe ActiveFedora do
|
|
59
59
|
describe "outside of rails" do
|
60
60
|
it "should load the passed config if explicit config passed in as a string" do
|
61
61
|
ActiveFedora.init(:fedora_config_path=>'./spec/fixtures/rails_root/config/fedora.yml', :environment => 'test')
|
62
|
-
ActiveFedora.config.credentials.
|
62
|
+
expect(ActiveFedora.config.credentials).to eq({:url=> "http://testhost.com:8983/fedora", :user=>'fedoraAdmin', :password=>'fedoraAdmin'})
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -79,22 +79,22 @@ describe ActiveFedora do
|
|
79
79
|
solr_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/solr.yml"))
|
80
80
|
pred_config_path = File.expand_path(File.join(File.dirname(__FILE__),"../fixtures/rails_root/config/predicate_mappings.yml"))
|
81
81
|
|
82
|
-
File.
|
83
|
-
File.
|
84
|
-
ActiveFedora::SolrService.
|
82
|
+
allow(File).to receive(:open).with(fedora_config_path).and_return(fedora_config)
|
83
|
+
allow(File).to receive(:open).with(solr_config_path).and_return(solr_config)
|
84
|
+
allow(ActiveFedora::SolrService).to receive(:load_mappings) #For the solrizer solr_mappings.yml
|
85
85
|
|
86
86
|
ActiveFedora.init(:fedora_config_path=>fedora_config_path,:solr_config_path=>solr_config_path)
|
87
|
-
ActiveFedora.solr.class.
|
87
|
+
expect(ActiveFedora.solr.class).to eq(ActiveFedora::SolrService)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
describe "with no explicit config path" do
|
92
92
|
it "should look for the file in the path defined at Rails.root" do
|
93
|
-
ActiveFedora::SolrService.
|
93
|
+
allow(ActiveFedora::SolrService).to receive(:load_mappings) #necessary or else it will load the solrizer config and it breaks other tests in the suite.
|
94
94
|
|
95
95
|
stub_rails(:root=>File.join(File.dirname(__FILE__),"../fixtures/rails_root"))
|
96
96
|
ActiveFedora.init()
|
97
|
-
ActiveFedora.config.credentials[:url].
|
97
|
+
expect(ActiveFedora.config.credentials[:url]).to eq("http://testhost.com:8983/fedora")
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -111,13 +111,13 @@ describe ActiveFedora do
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
it "should return class constants based on strings" do
|
114
|
-
ActiveFedora.class_from_string("Om").
|
115
|
-
ActiveFedora.class_from_string("ActiveFedora::RDF::Indexing").
|
116
|
-
ActiveFedora.class_from_string("Indexing", ActiveFedora::RDF).
|
114
|
+
expect(ActiveFedora.class_from_string("Om")).to eq(Om)
|
115
|
+
expect(ActiveFedora.class_from_string("ActiveFedora::RDF::Indexing")).to eq(ActiveFedora::RDF::Indexing)
|
116
|
+
expect(ActiveFedora.class_from_string("Indexing", ActiveFedora::RDF)).to eq(ActiveFedora::RDF::Indexing)
|
117
117
|
end
|
118
118
|
|
119
119
|
it "should find sibling classes" do
|
120
|
-
ActiveFedora.class_from_string("SiblingClass", ParentClass::OtherSiblingClass).
|
120
|
+
expect(ActiveFedora.class_from_string("SiblingClass", ParentClass::OtherSiblingClass)).to eq(ParentClass::SiblingClass)
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should raise a NameError if the class isn't found" do
|