active-fedora 4.0.0.rc5 → 4.0.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/History.txt +2 -1
- data/lib/active_fedora.rb +1 -1
- data/lib/active_fedora/associations/association_proxy.rb +1 -1
- data/lib/active_fedora/model.rb +5 -2
- data/lib/active_fedora/version.rb +1 -1
- data/spec/unit/model_spec.rb +5 -6
- data/spec/unit/relationships_spec.rb +3 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/History.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
4.0.0.
|
1
|
+
4.0.0.rc6
|
2
2
|
Removed deprecations
|
3
3
|
* allowing :fedora level in fedora.yml
|
4
4
|
* automatic includes of Relationships and FileMethods is removed
|
@@ -10,6 +10,7 @@ Replaced solr-ruby with rsolr. Note: remove any calls to .hits
|
|
10
10
|
load_instance is now deprecated, replaced with find
|
11
11
|
Find alwasy casts to the appropriate object.
|
12
12
|
Run a stub :environment task in the fixture loading rake tasks (which is overridden by rails)
|
13
|
+
Find raises ObjectNotFoundError when the object isn't found
|
13
14
|
|
14
15
|
3.3.2
|
15
16
|
HYDRA-745 No need to require :url be present on external datastreams
|
data/lib/active_fedora.rb
CHANGED
@@ -17,7 +17,7 @@ module ActiveFedora #:nodoc:
|
|
17
17
|
class UnknownAttributeError < NoMethodError; end; # :nodoc:
|
18
18
|
class ConfigurationError < RuntimeError; end # :nodoc:
|
19
19
|
class AssociationTypeMismatch < RuntimeError; end # :nodoc:
|
20
|
-
class UnregisteredPredicateError < RuntimeError; end
|
20
|
+
class UnregisteredPredicateError < RuntimeError; end # :nodoc:
|
21
21
|
|
22
22
|
|
23
23
|
eager_autoload do
|
@@ -122,7 +122,7 @@ module ActiveFedora
|
|
122
122
|
# If the \target is already \loaded it is just returned. Thus, you can call
|
123
123
|
# +load_target+ unconditionally to get the \target.
|
124
124
|
#
|
125
|
-
# ActiveFedora::
|
125
|
+
# ActiveFedora::ObjectNotFoundError is rescued within the method, and it is
|
126
126
|
# not reraised. The proxy is \reset and +nil+ is the return value.
|
127
127
|
def load_target
|
128
128
|
return nil unless defined?(@loaded)
|
data/lib/active_fedora/model.rb
CHANGED
@@ -263,12 +263,15 @@ module ActiveFedora
|
|
263
263
|
private
|
264
264
|
# Retrieve the Fedora object with te given pid, explore the returned object, determine its model
|
265
265
|
# using #{ActiveFedora::ContentModel.known_models_for} and cast to that class.
|
266
|
+
# Raises a ObjectNotFoundError if the object is not found.
|
266
267
|
# @param [String] pid of the object to load
|
267
268
|
#
|
268
269
|
# @example because the object hydra:dataset1 asserts it is a Dataset (hasModel info:fedora/afmodel:Dataset), return a Dataset object (not a Book).
|
269
|
-
# Book.
|
270
|
+
# Book.find_one("hydra:dataset1")
|
270
271
|
def find_one(pid)
|
271
|
-
|
272
|
+
inner = DigitalObject.find(self, pid)
|
273
|
+
raise ActiveFedora::ObjectNotFoundError if inner.new?
|
274
|
+
af_base = self.allocate.init_with(inner)
|
272
275
|
the_model = ActiveFedora::ContentModel.known_models_for( af_base ).first
|
273
276
|
if af_base.class != the_model
|
274
277
|
return af_base.adapt_to(the_model)
|
data/spec/unit/model_spec.rb
CHANGED
@@ -68,12 +68,7 @@ describe ActiveFedora::Model do
|
|
68
68
|
|
69
69
|
end
|
70
70
|
|
71
|
-
it 'should provide #find' do
|
72
|
-
SpecModel::Basic.should respond_to(:find)
|
73
|
-
end
|
74
|
-
|
75
71
|
describe '#find' do
|
76
|
-
|
77
72
|
it "(:all) should query solr for all objects with :active_fedora_model_s of self.class" do
|
78
73
|
ActiveFedora::SolrService.expects(:query).with('has_model_s:info\\:fedora/afmodel\\:SpecModel_Basic', :rows=>1001).returns([{"id" => "changeme:30"}, {"id" => "changeme:22"}])
|
79
74
|
SpecModel::Basic.expects(:find_one).with("changeme:30").returns("Fake Object1")
|
@@ -83,9 +78,13 @@ describe ActiveFedora::Model do
|
|
83
78
|
it "should use SpecModel::Basic.allocate.init_with to instantiate an object" do
|
84
79
|
ActiveFedora::ContentModel.expects(:known_models_for).returns([SpecModel::Basic])
|
85
80
|
SpecModel::Basic.any_instance.expects(:init_with).returns(mock("Model", :adapt_to=>SpecModel::Basic ))
|
86
|
-
|
81
|
+
ActiveFedora::DigitalObject.expects(:find).returns(stub("inner obj", :'new?'=>false))
|
87
82
|
SpecModel::Basic.find("_PID_")
|
88
83
|
end
|
84
|
+
it "should raise an exception if it is not found" do
|
85
|
+
SpecModel::Basic.expects(:connection_for_pid).with("_PID_")
|
86
|
+
lambda {SpecModel::Basic.find("_PID_")}.should raise_error ActiveFedora::ObjectNotFoundError
|
87
|
+
end
|
89
88
|
end
|
90
89
|
|
91
90
|
describe '#count' do
|
@@ -240,6 +240,9 @@ describe ActiveFedora::Relationships do
|
|
240
240
|
ActiveFedora::SolrService.expects(:query).with("id:my\\:_PID1_ OR id:my\\:_PID2_ OR id:my\\:_PID3_").returns([{"id"=> "my:_PID1_", "has_model_s"=>["info:fedora/afmodel:SpecNode"]},
|
241
241
|
{"id"=> "my:_PID2_", "has_model_s"=>["info:fedora/afmodel:SpecNode"]},
|
242
242
|
{"id"=> "my:_PID3_", "has_model_s"=>["info:fedora/afmodel:SpecNode"]}])
|
243
|
+
ActiveFedora::DigitalObject.expects(:find).with(SpecNode, 'my:_PID1_').returns(stub("inner obj", :'new?'=>false, :pid=>'my:_PID1_'))
|
244
|
+
ActiveFedora::DigitalObject.expects(:find).with(SpecNode, 'my:_PID2_').returns(stub("inner obj", :'new?'=>false, :pid=>'my:_PID2_'))
|
245
|
+
ActiveFedora::DigitalObject.expects(:find).with(SpecNode, 'my:_PID3_').returns(stub("inner obj", :'new?'=>false, :pid=>'my:_PID3_'))
|
243
246
|
local_node.containers.map(&:pid).should == ["my:_PID1_", "my:_PID2_", "my:_PID3_"]
|
244
247
|
end
|
245
248
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424153
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 4
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 4.0.0.
|
11
|
+
- 6
|
12
|
+
version: 4.0.0.rc6
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Matt Zumwalt
|