active-fedora 10.3.0.rc1 → 10.3.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfce14d5c623e569206f59c02700d667e34bde26
|
4
|
+
data.tar.gz: ead2d01f58a36fc8afac60ddfc9825fd1e581d53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c61d8f7606b23f0cbff48e4280711cab4b1237d245590b775cead65ca4b65907ee6b000b8bcef23bafd41cc2bb8f84dd194edb220589f9e510e2712a47885cc8
|
7
|
+
data.tar.gz: b5af3107ec86f44ab5e56926e678601430f855ea8c962e193dc90eff90b2db46fde9bc6de6ed68f36cc64a7173986d6d56b05848b0f79e02b5c7788101758656
|
@@ -83,7 +83,7 @@ module ActiveFedora
|
|
83
83
|
protected
|
84
84
|
|
85
85
|
def find_polymorphic_inverse(record)
|
86
|
-
record.reflections.values.find { |r| !r.has_many? && r.
|
86
|
+
record.reflections.values.find { |r| !r.has_many? && r.predicate == reflection.predicate }
|
87
87
|
end
|
88
88
|
|
89
89
|
# Deletes the records according to the <tt>:dependent</tt> option.
|
@@ -32,19 +32,34 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe "
|
36
|
-
before do
|
37
|
-
# :books must come first, so that we can test that is being passed over in favor of :contents
|
38
|
-
Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
39
|
-
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
40
|
-
end
|
35
|
+
describe "#find_polymorphic_inverse" do
|
41
36
|
let(:book_reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
42
37
|
let(:association) { described_class.new(book, book_reflection) }
|
43
38
|
|
44
|
-
subject { association.send(:find_polymorphic_inverse, page) }
|
39
|
+
subject(:inverse) { association.send(:find_polymorphic_inverse, page) }
|
40
|
+
|
41
|
+
context "when a has_many is present" do
|
42
|
+
before do
|
43
|
+
# :books must come first, so that we can test that is being passed over in favor of :contents
|
44
|
+
Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
45
|
+
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "finds the HABTM reflection" do
|
49
|
+
expect(inverse.name).to eq :contents
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when multiple belongs_to are present" do
|
54
|
+
before do
|
55
|
+
# :foo must come first, so that we can test that is being passed over in favor of :bar
|
56
|
+
Page.belongs_to :foo, predicate: ::RDF::Vocab::DC.isPartOf, class_name: 'ActiveFedora::Base'
|
57
|
+
Page.belongs_to :bar, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
58
|
+
end
|
45
59
|
|
46
|
-
|
47
|
-
|
60
|
+
it "finds the belongs_to reflection" do
|
61
|
+
expect(inverse.name).to eq :bar
|
62
|
+
end
|
48
63
|
end
|
49
64
|
end
|
50
65
|
|