active-fedora 7.0.4 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/History.txt +51 -1
- data/active-fedora.gemspec +19 -19
- data/lib/active_fedora.rb +1 -6
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +1 -1
- data/lib/active_fedora/associations/collection_association.rb +1 -1
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
- data/lib/active_fedora/attributes.rb +8 -0
- data/lib/active_fedora/base.rb +1 -1
- data/lib/active_fedora/callbacks.rb +1 -1
- data/lib/active_fedora/core.rb +13 -5
- data/lib/active_fedora/datastream_attribute.rb +1 -1
- data/lib/active_fedora/datastream_hash.rb +12 -6
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file_configurator.rb +3 -3
- data/lib/active_fedora/fixture_loader.rb +2 -2
- data/lib/active_fedora/model.rb +2 -2
- data/lib/active_fedora/om_datastream.rb +2 -2
- data/lib/active_fedora/persistence.rb +22 -18
- data/lib/active_fedora/railtie.rb +5 -1
- data/lib/active_fedora/rdf.rb +11 -9
- data/lib/active_fedora/rdf/indexing.rb +1 -1
- data/lib/active_fedora/rdf/object_resource.rb +1 -1
- data/lib/active_fedora/rdf/rdf_datastream.rb +3 -3
- data/lib/active_fedora/relation/finder_methods.rb +16 -10
- data/lib/active_fedora/solr_instance_loader.rb +1 -1
- data/lib/active_fedora/solr_service.rb +1 -3
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/attributes_spec.rb +4 -4
- data/spec/integration/base_spec.rb +32 -13
- data/spec/integration/complex_rdf_datastream_spec.rb +4 -4
- data/spec/integration/delete_all_spec.rb +1 -1
- data/spec/integration/load_from_solr_spec.rb +1 -1
- data/spec/integration/rdf_nested_attributes_spec.rb +4 -4
- data/spec/integration/scoped_query_spec.rb +6 -6
- data/spec/spec_helper.rb +5 -3
- data/spec/unit/attributes_spec.rb +19 -1
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +9 -0
- data/spec/unit/datastreams_spec.rb +4 -0
- data/spec/unit/file_configurator_spec.rb +5 -5
- data/spec/unit/logger_spec.rb +20 -0
- data/spec/unit/om_datastream_spec.rb +1 -1
- data/spec/unit/persistence_spec.rb +50 -0
- data/spec/unit/query_spec.rb +15 -5
- data/spec/unit/rdf_resource_datastream_spec.rb +3 -3
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +1 -1
- data/spec/unit/solr_config_options_spec.rb +1 -1
- data/spec/unit/solr_service_spec.rb +1 -1
- metadata +33 -168
- data/lib/active_fedora/rdf/configurable.rb +0 -59
- data/lib/active_fedora/rdf/list.rb +0 -155
- data/lib/active_fedora/rdf/nested_attributes.rb +0 -130
- data/lib/active_fedora/rdf/node_config.rb +0 -57
- data/lib/active_fedora/rdf/properties.rb +0 -94
- data/lib/active_fedora/rdf/repositories.rb +0 -36
- data/lib/active_fedora/rdf/resource.rb +0 -328
- data/lib/active_fedora/rdf/term.rb +0 -188
- data/spec/unit/rdf_configurable_spec.rb +0 -37
- data/spec/unit/rdf_list_nested_attributes_spec.rb +0 -99
- data/spec/unit/rdf_list_spec.rb +0 -180
- data/spec/unit/rdf_properties_spec.rb +0 -81
- data/spec/unit/rdf_repositories_spec.rb +0 -28
- data/spec/unit/rdf_resource_spec.rb +0 -345
@@ -4,10 +4,14 @@ module ActiveFedora
|
|
4
4
|
load "tasks/active_fedora.rake"
|
5
5
|
end
|
6
6
|
|
7
|
-
initializer '
|
7
|
+
initializer 'active_fedora.autoload', :before => :set_autoload_paths do |app|
|
8
8
|
app.config.autoload_paths << 'app/models/datastreams'
|
9
9
|
end
|
10
10
|
|
11
|
+
initializer "active_fedora.logger" do
|
12
|
+
ActiveSupport.on_load(:active_fedora) { self.logger ||= ::Rails.logger }
|
13
|
+
end
|
14
|
+
|
11
15
|
generators do
|
12
16
|
require(
|
13
17
|
'generators/active_fedora/config/config_generator'
|
data/lib/active_fedora/rdf.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
module ActiveFedora
|
2
2
|
module Rdf
|
3
3
|
extend ActiveSupport::Autoload
|
4
|
-
autoload :NestedAttributes
|
5
|
-
autoload :NodeConfig
|
6
4
|
autoload :Indexing
|
7
|
-
autoload :Configurable
|
8
|
-
autoload :Properties
|
9
5
|
autoload :Identifiable
|
10
|
-
autoload :Repositories
|
11
|
-
autoload :Resource
|
12
|
-
autoload :VocabularyLoader
|
13
6
|
autoload :ObjectResource
|
14
|
-
|
15
|
-
|
7
|
+
|
8
|
+
# Aliases for deprecated ActiveFedora::Rdf Classes/Modules
|
9
|
+
# TODO: Remove in 8.0.0
|
10
|
+
Resource = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveFedora::Rdf::Resource', 'ActiveTriples::Resource')
|
11
|
+
Term = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveFedora::Rdf::Term', 'ActiveTriples::Term')
|
12
|
+
List = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveFedora::Rdf::List', 'ActiveTriples::List')
|
13
|
+
Configurable = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveFedora::Rdf::Configurable', 'ActiveTriples::Configurable')
|
14
|
+
Properties = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveFedora::Rdf::Properties', 'ActiveTriples::Properties')
|
15
|
+
Repositories = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveFedora::Rdf::Repositories', 'ActiveTriples::Repositories')
|
16
|
+
NodeConfig = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveFedora::Rdf::NodeConfig', 'ActiveTriples::NodeConfig')
|
17
|
+
NestedAttributes = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('ActiveFedora::Rdf::NestedAttributes', 'ActiveTriples::NestedAttributes')
|
16
18
|
end
|
17
19
|
end
|
@@ -20,7 +20,7 @@ module ActiveFedora
|
|
20
20
|
Array(values).each do |val|
|
21
21
|
if val.kind_of? RDF::URI
|
22
22
|
val = val.to_s
|
23
|
-
elsif val.kind_of?
|
23
|
+
elsif val.kind_of? ActiveTriples::Resource
|
24
24
|
val = val.solrize
|
25
25
|
end
|
26
26
|
self.class.create_and_insert_terms(apply_prefix(field_key), val, field_info[:behaviors], solr_doc)
|
@@ -4,7 +4,7 @@ module ActiveFedora::Rdf
|
|
4
4
|
# with a Datastream and ActiveFedora::Base object.
|
5
5
|
#
|
6
6
|
# @see ActiveFedora::RDFDatastream
|
7
|
-
class ObjectResource < Resource
|
7
|
+
class ObjectResource < ActiveTriples::Resource
|
8
8
|
configure :base_uri => 'info:fedora/'
|
9
9
|
attr_accessor :datastream
|
10
10
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module ActiveFedora
|
2
2
|
class RDFDatastream < ActiveFedora::Datastream
|
3
3
|
include Solrizer::Common
|
4
|
-
include
|
4
|
+
include ActiveTriples::NestedAttributes
|
5
5
|
include Rdf::Indexing
|
6
|
-
extend
|
6
|
+
extend ActiveTriples::Properties
|
7
7
|
|
8
8
|
delegate :rdf_subject, :set_value, :get_values, :attributes=, :to => :resource
|
9
9
|
|
@@ -25,7 +25,7 @@ module ActiveFedora
|
|
25
25
|
|
26
26
|
before_save do
|
27
27
|
if content.blank?
|
28
|
-
logger.warn "Cowardly refusing to save a datastream with empty content: #{self.inspect}"
|
28
|
+
ActiveFedora::Base.logger.warn "Cowardly refusing to save a datastream with empty content: #{self.inspect}" if ActiveFedora::Base.logger
|
29
29
|
false
|
30
30
|
end
|
31
31
|
end
|
@@ -60,14 +60,22 @@ module ActiveFedora
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
# Returns true if the pid exists in the repository
|
64
|
-
#
|
63
|
+
# Returns true if object having the pid or matching the conditions exists in the repository
|
64
|
+
# Returns false if param is false (or nil)
|
65
|
+
# @param[ActiveFedora::Base, String, Hash] object, pid or hash of conditions
|
65
66
|
# @return[boolean]
|
66
67
|
def exists?(conditions)
|
67
68
|
conditions = conditions.id if Base === conditions
|
68
69
|
return false if !conditions
|
69
|
-
|
70
|
-
|
70
|
+
case conditions
|
71
|
+
when Hash
|
72
|
+
find_with_conditions(conditions, {rows: 1}).present?
|
73
|
+
when String
|
74
|
+
!!DigitalObject.find(self.klass, conditions)
|
75
|
+
else
|
76
|
+
raise ArgumentError, "`conditions' argument must be ActiveFedora::Base, String, or Hash: #{conditions.inspect}"
|
77
|
+
end
|
78
|
+
rescue ActiveFedora::ObjectNotFoundError
|
71
79
|
false
|
72
80
|
end
|
73
81
|
|
@@ -99,7 +107,7 @@ module ActiveFedora
|
|
99
107
|
begin
|
100
108
|
yield(load_from_fedora(hit[SOLR_DOCUMENT_ID], cast))
|
101
109
|
rescue ActiveFedora::ObjectNotFoundError
|
102
|
-
logger.error "Although #{hit[SOLR_DOCUMENT_ID]} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch."
|
110
|
+
ActiveFedora::Base.logger.error "Although #{hit[SOLR_DOCUMENT_ID]} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch." if ActiveFedora::Base.logger
|
103
111
|
end
|
104
112
|
end
|
105
113
|
end
|
@@ -160,14 +168,12 @@ module ActiveFedora
|
|
160
168
|
protected
|
161
169
|
|
162
170
|
def load_from_fedora(pid, cast)
|
163
|
-
cast = true if
|
164
|
-
inner = DigitalObject.find(
|
165
|
-
af_base =
|
171
|
+
cast = true if klass == ActiveFedora::Base && cast.nil?
|
172
|
+
inner = DigitalObject.find(klass, pid)
|
173
|
+
af_base = klass.allocate.init_with_object(inner)
|
166
174
|
cast ? af_base.adapt_to_cmodel : af_base
|
167
|
-
|
168
175
|
end
|
169
176
|
|
170
|
-
|
171
177
|
def find_with_ids(ids, cast)
|
172
178
|
expects_array = ids.first.kind_of?(Array)
|
173
179
|
return ids.first if expects_array && ids.first.empty?
|
@@ -4,8 +4,6 @@ module ActiveFedora
|
|
4
4
|
class SolrService
|
5
5
|
extend Deprecation
|
6
6
|
|
7
|
-
include Loggable
|
8
|
-
|
9
7
|
attr_reader :conn
|
10
8
|
|
11
9
|
def initialize(host, args)
|
@@ -76,7 +74,7 @@ module ActiveFedora
|
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
79
|
-
logger.warn "Could not find a model for #{hit["id"]}, defaulting to ActiveFedora::Base" unless best_model_match
|
77
|
+
ActiveFedora::Base.logger.warn "Could not find a model for #{hit["id"]}, defaulting to ActiveFedora::Base" unless best_model_match if ActiveFedora::Base.logger
|
80
78
|
best_model_match || ActiveFedora::Base
|
81
79
|
end
|
82
80
|
|
@@ -21,12 +21,12 @@ describe "delegating attributes" do
|
|
21
21
|
obj
|
22
22
|
end
|
23
23
|
it "should keep a list of changes after a successful save" do
|
24
|
-
subject.previous_changes.
|
25
|
-
subject.previous_changes.keys.
|
24
|
+
expect(subject.previous_changes).to_not be_empty
|
25
|
+
expect(subject.previous_changes.keys).to include("title")
|
26
26
|
end
|
27
27
|
it "should clean out changes" do
|
28
|
-
subject.
|
29
|
-
subject.changes.
|
28
|
+
expect(subject).to_not be_title_changed
|
29
|
+
expect(subject.changes).to be_empty
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -104,7 +104,7 @@ describe "A base object with metadata" do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
describe '#reload' do
|
107
|
-
before
|
107
|
+
before do
|
108
108
|
@object = MockAFBaseRelationship.new
|
109
109
|
@object.foo.person = 'bob'
|
110
110
|
@object.save
|
@@ -114,17 +114,15 @@ describe "A base object with metadata" do
|
|
114
114
|
@object2.foo.person = 'dave'
|
115
115
|
@object2.save
|
116
116
|
end
|
117
|
+
|
117
118
|
it 'should requery Fedora' do
|
118
119
|
@object.reload
|
119
120
|
@object.foo.person.should == ['dave']
|
120
121
|
end
|
122
|
+
|
121
123
|
it 'should raise an error if not persisted' do
|
122
124
|
@object = MockAFBaseRelationship.new
|
123
|
-
|
124
|
-
@object.inner_object.logger.stub(:error)
|
125
|
-
expect {
|
126
|
-
@object.reload
|
127
|
-
}.to raise_error(ActiveFedora::ObjectNotFoundError)
|
125
|
+
expect { @object.reload }.to raise_error(ActiveFedora::ObjectNotFoundError)
|
128
126
|
end
|
129
127
|
end
|
130
128
|
end
|
@@ -271,7 +269,7 @@ describe ActiveFedora::Base do
|
|
271
269
|
describe ".datastreams" do
|
272
270
|
it "should return a Hash of datastreams from fedora" do
|
273
271
|
datastreams = @test_object.datastreams
|
274
|
-
datastreams.should be_a_kind_of(
|
272
|
+
datastreams.should be_a_kind_of(ActiveFedora::DatastreamHash)
|
275
273
|
datastreams.each_value do |ds|
|
276
274
|
ds.should be_a_kind_of(ActiveFedora::Datastream)
|
277
275
|
end
|
@@ -433,18 +431,39 @@ describe ActiveFedora::Base do
|
|
433
431
|
|
434
432
|
|
435
433
|
describe "#exists?" do
|
434
|
+
let(:obj) { ActiveFedora::Base.create }
|
436
435
|
it "should return true for objects that exist" do
|
437
|
-
|
438
|
-
|
436
|
+
expect(ActiveFedora::Base.exists?(obj)).to be true
|
437
|
+
end
|
438
|
+
it "should return true for pids that exist" do
|
439
|
+
expect(ActiveFedora::Base.exists?(obj.pid)).to be true
|
439
440
|
end
|
440
|
-
it "should return false for
|
441
|
-
ActiveFedora::Base.exists?('test:missing_object').
|
441
|
+
it "should return false for pids that don't exist" do
|
442
|
+
expect(ActiveFedora::Base.exists?('test:missing_object')).to be false
|
442
443
|
end
|
443
444
|
it "should return false for nil" do
|
444
|
-
ActiveFedora::Base.exists?(nil).
|
445
|
+
expect(ActiveFedora::Base.exists?(nil)).to be false
|
446
|
+
end
|
447
|
+
it "should return false for false" do
|
448
|
+
expect(ActiveFedora::Base.exists?(false)).to be false
|
445
449
|
end
|
446
450
|
it "should return false for empty" do
|
447
|
-
ActiveFedora::Base.exists?('').
|
451
|
+
expect(ActiveFedora::Base.exists?('')).to be false
|
452
|
+
end
|
453
|
+
context "when passed a hash of conditions" do
|
454
|
+
let(:conditions) { {foo: "bar"} }
|
455
|
+
context "and at least one object matches the conditions" do
|
456
|
+
it "should return true" do
|
457
|
+
allow(ActiveFedora::SolrService).to receive(:query) { [double("solr document")] }
|
458
|
+
expect(ActiveFedora::Base.exists?(conditions)).to be true
|
459
|
+
end
|
460
|
+
end
|
461
|
+
context "and no object matches the conditions" do
|
462
|
+
it "should return false" do
|
463
|
+
allow(ActiveFedora::SolrService).to receive(:query) { [] }
|
464
|
+
expect(ActiveFedora::Base.exists?(conditions)).to be false
|
465
|
+
end
|
466
|
+
end
|
448
467
|
end
|
449
468
|
end
|
450
469
|
end
|
@@ -6,7 +6,7 @@ describe "Nested Rdf Objects" do
|
|
6
6
|
class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
|
7
7
|
property :parts, predicate: RDF::DC.hasPart, class_name: 'Component'
|
8
8
|
|
9
|
-
class Component <
|
9
|
+
class Component < ActiveTriples::Resource
|
10
10
|
property :label, predicate: RDF::DC.title
|
11
11
|
end
|
12
12
|
end
|
@@ -134,7 +134,7 @@ END
|
|
134
134
|
class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
|
135
135
|
property :mediator, predicate: RDF::DC.mediator, class_name: 'MediatorUser'
|
136
136
|
|
137
|
-
class MediatorUser <
|
137
|
+
class MediatorUser < ActiveTriples::Resource
|
138
138
|
configure type: RDF::DC.AgentClass
|
139
139
|
property :title, predicate: RDF::DC.title
|
140
140
|
end
|
@@ -189,12 +189,12 @@ END
|
|
189
189
|
property :series, predicate: EbuCore.isEpisodeOf, class_name: 'Series'
|
190
190
|
property :program, predicate: EbuCore.isEpisodeOf, class_name: 'Program'
|
191
191
|
|
192
|
-
class Series <
|
192
|
+
class Series < ActiveTriples::Resource
|
193
193
|
configure type: 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
|
194
194
|
property :title, predicate: EbuCore.title
|
195
195
|
end
|
196
196
|
|
197
|
-
class Program <
|
197
|
+
class Program < ActiveTriples::Resource
|
198
198
|
configure type: 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
|
199
199
|
property :title, predicate: EbuCore.title
|
200
200
|
end
|
@@ -46,7 +46,7 @@ describe ActiveFedora::Base do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
it "should be able to skip a missing model" do
|
49
|
-
ActiveFedora::
|
49
|
+
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.")
|
50
50
|
SpecModel::Basic.destroy_all
|
51
51
|
SpecModel::Basic.count.should == 1
|
52
52
|
end
|
@@ -52,7 +52,7 @@ describe "Loading from solr" do
|
|
52
52
|
expect(obj.date_uploaded).to eq [Date.parse('1959-01-01')]
|
53
53
|
expect(obj.identifier).to eq 12345
|
54
54
|
expect{obj.part}.to raise_error KeyError, "Tried to fetch `part' from solr, but it isn't indexed."
|
55
|
-
ActiveFedora::
|
55
|
+
expect(ActiveFedora::Base.logger).to receive(:info).with "Couldn't get duck out of solr, because the datastream 'MyOmDatastream' doesn't respond to 'primary_solr_name'. Trying another way."
|
56
56
|
expect(obj.duck).to eq 'quack'
|
57
57
|
end
|
58
58
|
|
@@ -32,16 +32,16 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
32
32
|
|
33
33
|
accepts_nested_attributes_for :topic, :personalName
|
34
34
|
|
35
|
-
class Topic <
|
35
|
+
class Topic < ActiveTriples::Resource
|
36
36
|
property :elementList, predicate: DummyMADS.elementList, class_name: "ComplexRDFDatastream::ElementList"
|
37
37
|
accepts_nested_attributes_for :elementList
|
38
38
|
end
|
39
|
-
class PersonalName <
|
39
|
+
class PersonalName < ActiveTriples::Resource
|
40
40
|
property :elementList, predicate: DummyMADS.elementList, class_name: "ComplexRDFDatastream::ElementList"
|
41
41
|
property :extraProperty, predicate: DummyMADS.elementValue, class_name: "ComplexRDFDatastream::Topic"
|
42
42
|
accepts_nested_attributes_for :elementList, :extraProperty
|
43
43
|
end
|
44
|
-
class ElementList <
|
44
|
+
class ElementList < ActiveTriples::List
|
45
45
|
configure type: DummyMADS.elementList
|
46
46
|
property :topicElement, predicate: DummyMADS.TopicElement, class_name: "ComplexRDFDatastream::MadsTopicElement"
|
47
47
|
property :temporalElement, predicate: DummyMADS.TemporalElement
|
@@ -51,7 +51,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
51
51
|
property :elementValue, predicate: DummyMADS.elementValue
|
52
52
|
accepts_nested_attributes_for :topicElement
|
53
53
|
end
|
54
|
-
class MadsTopicElement <
|
54
|
+
class MadsTopicElement < ActiveTriples::Resource
|
55
55
|
configure :type => DummyMADS.TopicElement
|
56
56
|
property :elementValue, predicate: DummyMADS.elementValue
|
57
57
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "scoped queries" do
|
4
4
|
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
module ModelIntegrationSpec
|
7
7
|
class Basic < ActiveFedora::Base
|
8
8
|
has_metadata "properties", type: ActiveFedora::SimpleDatastream do |m|
|
@@ -24,7 +24,7 @@ describe "scoped queries" do
|
|
24
24
|
|
25
25
|
end
|
26
26
|
|
27
|
-
after
|
27
|
+
after do
|
28
28
|
Object.send(:remove_const, :ModelIntegrationSpec)
|
29
29
|
end
|
30
30
|
|
@@ -56,9 +56,9 @@ describe "scoped queries" do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "with multiple objects" do
|
59
|
-
let!(:test_instance1) { ModelIntegrationSpec::Basic.create!(:
|
60
|
-
let!(:test_instance2) { ModelIntegrationSpec::Basic.create!(:
|
61
|
-
let!(:test_instance3) { ModelIntegrationSpec::Basic.create!(:
|
59
|
+
let!(:test_instance1) { ModelIntegrationSpec::Basic.create!(foo: ['Beta'], bar: ['Chips']) }
|
60
|
+
let!(:test_instance2) { ModelIntegrationSpec::Basic.create!(foo: ['Alpha'], bar: ['Peanuts']) }
|
61
|
+
let!(:test_instance3) { ModelIntegrationSpec::Basic.create!(foo: ['Sigma'], bar: ['Peanuts']) }
|
62
62
|
|
63
63
|
describe "when the objects are in fedora" do
|
64
64
|
after do
|
@@ -124,7 +124,7 @@ describe "scoped queries" do
|
|
124
124
|
test_instance3.delete
|
125
125
|
end
|
126
126
|
it "should log an error" do
|
127
|
-
ActiveFedora::
|
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
128
|
ModelIntegrationSpec::Basic.all.should == [test_instance1, test_instance3]
|
129
129
|
end
|
130
130
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,13 +12,16 @@ end
|
|
12
12
|
|
13
13
|
require 'active-fedora'
|
14
14
|
require 'rspec'
|
15
|
+
require 'rspec/its'
|
15
16
|
require 'equivalent-xml/rspec_matchers'
|
17
|
+
require 'logger'
|
18
|
+
|
19
|
+
ActiveFedora::Base.logger = Logger.new(STDERR);
|
20
|
+
ActiveFedora::Base.logger.level = Logger::WARN
|
16
21
|
|
17
22
|
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f }
|
18
23
|
require 'samples/samples'
|
19
24
|
|
20
|
-
|
21
|
-
logger.level = Logger::WARN if logger.respond_to? :level ###MediaShelf StubLogger doesn't have a level= method
|
22
25
|
$VERBOSE=nil
|
23
26
|
|
24
27
|
# This loads the Fedora and Solr config info from /config/fedora.yml
|
@@ -32,7 +35,6 @@ restore_spec_configuration
|
|
32
35
|
ActiveSupport::Deprecation.behavior= Proc.new { |message, callstack| }
|
33
36
|
|
34
37
|
RSpec.configure do |config|
|
35
|
-
config.color_enabled = true
|
36
38
|
end
|
37
39
|
|
38
40
|
def fixture(file)
|
@@ -99,7 +99,25 @@ describe ActiveFedora::Base do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
-
|
102
|
+
describe "deprecated behavior" do
|
103
|
+
before(:all) do
|
104
|
+
@behavior = ActiveFedora::Attributes.deprecation_behavior
|
105
|
+
ActiveFedora::Attributes.deprecation_behavior = :raise
|
106
|
+
end
|
107
|
+
after(:all) do
|
108
|
+
ActiveFedora::Attributes.deprecation_behavior = @behavior
|
109
|
+
end
|
110
|
+
it "should deprecate passing a string to a multiple attribute writer" do
|
111
|
+
expect { subject.fubar = "Quack" }.to raise_error
|
112
|
+
expect { subject.fubar = ["Quack"] }.not_to raise_error
|
113
|
+
expect { subject.fubar = nil }.not_to raise_error
|
114
|
+
end
|
115
|
+
it "should deprecate passing an enumerable to a unique attribute writer" do
|
116
|
+
expect { subject.cow = "Low" }.not_to raise_error
|
117
|
+
expect { subject.cow = ["Low"] }.to raise_error
|
118
|
+
expect { subject.cow = nil }.not_to raise_error
|
119
|
+
end
|
120
|
+
end
|
103
121
|
|
104
122
|
it "should reveal the unique properties" do
|
105
123
|
BarHistory2.unique?(:horse).should be_false
|