active-fedora 6.6.0.rc4 → 6.6.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +6 -1
- data/lib/active_fedora/associations.rb +2 -1
- data/lib/active_fedora/associations/association_collection.rb +1 -1
- data/lib/active_fedora/querying.rb +5 -1
- data/lib/active_fedora/relation.rb +2 -1
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/has_many_associations_spec.rb +30 -7
- data/spec/integration/scoped_query_spec.rb +26 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c25ddcf281f3eb10b558ee44dc144880d3551c31
|
4
|
+
data.tar.gz: f2f13e587a927cfe015eec879a023c8407eb2fac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 317a0a139aa98883265545996a6587a8f26020a38d3aefbd001770f30c756a35c60079b49b9cd9deabf6ac357f7d204b2f36191b1b222af165e43a186bddd88d
|
7
|
+
data.tar.gz: 5777d15192af9d28f43f59c6f27640b55419cb74fc50df642981d038825a259504e54d086a9694eedec07ae700890cae55125fa8a70a8f147529a2e62606c59e
|
data/History.txt
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
v6.6.0 (
|
1
|
+
v6.6.0 (rc5)
|
2
|
+
Gracefully handle an ObjectNotFound in find_all [Justin Coyne]
|
3
|
+
Revert "Removed unused code that breaks certain use cases (Fixes #234)." [Jeremy Friesen]
|
4
|
+
Removed unset opts parameter from call to reify_solr_results, introduced in PR #236. [David Chandek-Stark]
|
5
|
+
Removed unused code that breaks certain use cases (Fixes #234). [David Chandek-Stark]
|
6
|
+
Fix deprecation warning when using the ids setter of a has_many collection relationship that has class_name set to 'ActiveFedora::Base [Justin Coyne]
|
2
7
|
Fix deprecation warning when loading a has_many association [Justin Coyne]
|
3
8
|
Explicitly set cast to false on reload to avoid deprecation warnings [Justin Coyne]
|
4
9
|
Cast relationship results if class is ActiveFedora::Base [Justin Coyne]
|
@@ -280,7 +280,8 @@ module ActiveFedora
|
|
280
280
|
ids = (new_value || []).reject { |nid| nid.blank? }
|
281
281
|
#TODO, like this when find() can return multiple records
|
282
282
|
#send("#{reflection.name}=", reflection.klass.find(ids))
|
283
|
-
|
283
|
+
opts = reflection.klass == ActiveFedora::Base ? {cast: true} : nil
|
284
|
+
send("#{reflection.name}=", ids.collect { |id| reflection.klass.find(id, opts)})
|
284
285
|
end
|
285
286
|
end
|
286
287
|
end
|
@@ -156,7 +156,7 @@ module ActiveFedora
|
|
156
156
|
opts[:class] = @reflection.class_name.constantize.to_class_uri unless @reflection.class_name.nil?
|
157
157
|
|
158
158
|
#TODO, don't reify, just store the solr results and lazily reify.
|
159
|
-
return ActiveFedora::SolrService.reify_solr_results(solr_result
|
159
|
+
return ActiveFedora::SolrService.reify_solr_results(solr_result)
|
160
160
|
end
|
161
161
|
|
162
162
|
def load_from_solr
|
@@ -63,7 +63,11 @@ module ActiveFedora
|
|
63
63
|
cast = opts.delete(:cast)
|
64
64
|
find_in_batches(conditions, opts.merge({:fl=>SOLR_DOCUMENT_ID})) do |group|
|
65
65
|
group.each do |hit|
|
66
|
-
|
66
|
+
begin
|
67
|
+
yield(find_one(hit[SOLR_DOCUMENT_ID], cast))
|
68
|
+
rescue ActiveFedora::ObjectNotFoundError
|
69
|
+
logger.error "When trying to find_each #{hit[SOLR_DOCUMENT_ID]}, encountered an ObjectNotFoundError. Solr may be out of sync with Fedora"
|
70
|
+
end
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -103,8 +103,9 @@ module ActiveFedora
|
|
103
103
|
def find(*args)
|
104
104
|
return to_a.find { |*block_args| yield(*block_args) } if block_given?
|
105
105
|
options = args.extract_options!
|
106
|
+
options = options.dup
|
106
107
|
|
107
|
-
cast = if
|
108
|
+
cast = if @klass == ActiveFedora::Base && !options.has_key?(:cast)
|
108
109
|
Deprecation.warn(Relation, "find's cast option will default to true in ActiveFedora 7.0.0. To preserve existing behavior send parameter: `:cast=> false`", caller)
|
109
110
|
false
|
110
111
|
else
|
@@ -45,11 +45,8 @@ describe "When relationship is restricted to AF::Base" do
|
|
45
45
|
class PDF < ActiveFedora::Base
|
46
46
|
belongs_to :email, :property=>:is_part_of
|
47
47
|
end
|
48
|
-
|
49
|
-
@book = Email.create!
|
50
|
-
@image = Image.create!(:email=>@book)
|
51
|
-
@pdf = PDF.create!(:email=>@book)
|
52
48
|
end
|
49
|
+
|
53
50
|
after do
|
54
51
|
Object.send(:remove_const, :Image)
|
55
52
|
Object.send(:remove_const, :PDF)
|
@@ -57,8 +54,34 @@ describe "When relationship is restricted to AF::Base" do
|
|
57
54
|
end
|
58
55
|
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
describe "creating new objects with object relationships" do
|
58
|
+
before do
|
59
|
+
@book = Email.create!
|
60
|
+
@image = Image.create!(:email=>@book)
|
61
|
+
@pdf = PDF.create!(:email=>@book)
|
62
|
+
end
|
63
|
+
it "Should not restrict relationships " do
|
64
|
+
@book.reload
|
65
|
+
@book.attachments.should == [@image, @pdf]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "creating new objects with id setter" do
|
70
|
+
let!(:image) { Image.create }
|
71
|
+
let!(:email) { Email.create }
|
72
|
+
let!(:pdf) { PDF.create }
|
73
|
+
|
74
|
+
after do
|
75
|
+
email.destroy
|
76
|
+
pdf.destroy
|
77
|
+
image.destroy
|
78
|
+
end
|
79
|
+
|
80
|
+
it "Should not restrict relationships " do
|
81
|
+
Deprecation.should_not_receive(:warn) # a deprecation in 6.6.0 that's going away in 7.0.0
|
82
|
+
email.attachment_ids = [image.id, pdf.id]
|
83
|
+
email.reload
|
84
|
+
email.attachments.should == [image, pdf]
|
85
|
+
end
|
63
86
|
end
|
64
87
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe "scoped queries" do
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
module ModelIntegrationSpec
|
@@ -30,15 +30,11 @@ describe ActiveFedora::Model do
|
|
30
30
|
|
31
31
|
|
32
32
|
describe "When there is one object in the store" do
|
33
|
-
|
34
|
-
@test_instance = ModelIntegrationSpec::Basic.new
|
35
|
-
@test_instance.save
|
36
|
-
end
|
33
|
+
let!(:test_instance) { ModelIntegrationSpec::Basic.create!()}
|
37
34
|
|
38
35
|
after do
|
39
|
-
|
36
|
+
test_instance.delete
|
40
37
|
end
|
41
|
-
|
42
38
|
|
43
39
|
describe ".all" do
|
44
40
|
it "should return an array of instances of the calling Class" do
|
@@ -54,40 +50,49 @@ describe ActiveFedora::Model do
|
|
54
50
|
|
55
51
|
describe ".first" do
|
56
52
|
it "should return one instance of the calling class" do
|
57
|
-
ModelIntegrationSpec::Basic.first.should ==
|
53
|
+
ModelIntegrationSpec::Basic.first.should == test_instance
|
58
54
|
end
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
62
58
|
describe "with multiple objects" do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
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
|
+
|
68
63
|
after do
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
test_instance1.delete
|
65
|
+
test_instance2.delete
|
66
|
+
test_instance3.delete
|
72
67
|
end
|
73
68
|
it "should query" do
|
74
|
-
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta').should == [
|
75
|
-
ModelIntegrationSpec::Basic.where('foo' => 'Beta').should == [
|
69
|
+
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('foo', type: :string)=> 'Beta').should == [test_instance1]
|
70
|
+
ModelIntegrationSpec::Basic.where('foo' => 'Beta').should == [test_instance1]
|
76
71
|
end
|
77
72
|
it "should order" do
|
78
|
-
ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').should == [
|
73
|
+
ModelIntegrationSpec::Basic.order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').should == [test_instance2, test_instance1, test_instance3]
|
79
74
|
end
|
80
75
|
it "should limit" do
|
81
|
-
ModelIntegrationSpec::Basic.limit(1).should == [
|
76
|
+
ModelIntegrationSpec::Basic.limit(1).should == [test_instance1]
|
82
77
|
end
|
83
78
|
|
84
79
|
it "should chain queries" do
|
85
|
-
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1).should == [
|
80
|
+
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').order(ActiveFedora::SolrService.solr_name('foo', :sortable) + ' asc').limit(1).should == [test_instance2]
|
86
81
|
end
|
87
82
|
|
88
83
|
it "should chain count" do
|
89
84
|
ModelIntegrationSpec::Basic.where(ActiveFedora::SolrService.solr_name('bar', type: :string) => 'Peanuts').count.should == 2
|
90
85
|
end
|
86
|
+
|
87
|
+
describe "when one of the objects in solr isn't in fedora" do
|
88
|
+
it "should log an error" do
|
89
|
+
ModelIntegrationSpec::Basic.should_receive(:find_one).with(test_instance1.pid, nil).and_call_original
|
90
|
+
ModelIntegrationSpec::Basic.should_receive(:find_one).with(test_instance2.pid, nil).and_raise(ActiveFedora::ObjectNotFoundError)
|
91
|
+
ModelIntegrationSpec::Basic.should_receive(:find_one).with(test_instance3.pid, nil).and_call_original
|
92
|
+
ActiveFedora::Relation.logger.should_receive(:error).with("When trying to find_each #{test_instance2.pid}, encountered an ObjectNotFoundError. Solr may be out of sync with Fedora")
|
93
|
+
ModelIntegrationSpec::Basic.all.should == [test_instance1, test_instance3]
|
94
|
+
end
|
95
|
+
end
|
91
96
|
end
|
92
97
|
end
|
93
98
|
|