active-fedora 10.3.0 → 11.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.rubocop_todo.yml +24 -0
- data/README.md +3 -1
- data/active-fedora.gemspec +4 -4
- data/lib/active_fedora.rb +0 -2
- data/lib/active_fedora/aggregation/list_source.rb +2 -0
- data/lib/active_fedora/associations/association_scope.rb +1 -1
- data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
- data/lib/active_fedora/associations/builder/association.rb +1 -1
- data/lib/active_fedora/associations/builder/orders.rb +11 -3
- data/lib/active_fedora/associations/collection_association.rb +2 -2
- data/lib/active_fedora/associations/has_many_association.rb +2 -2
- data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
- data/lib/active_fedora/associations/orders_association.rb +4 -0
- data/lib/active_fedora/associations/rdf.rb +2 -0
- data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
- data/lib/active_fedora/base.rb +1 -1
- data/lib/active_fedora/containers/container.rb +1 -1
- data/lib/active_fedora/core.rb +7 -9
- data/lib/active_fedora/fedora.rb +2 -6
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file.rb +1 -1
- data/lib/active_fedora/file/streaming.rb +1 -1
- data/lib/active_fedora/indexing.rb +1 -18
- data/lib/active_fedora/indexing_service.rb +0 -5
- data/lib/active_fedora/loadable_from_json.rb +12 -1
- data/lib/active_fedora/nested_attributes.rb +2 -2
- data/lib/active_fedora/orders/list_node.rb +2 -2
- data/lib/active_fedora/orders/ordered_list.rb +7 -3
- data/lib/active_fedora/orders/target_proxy.rb +4 -0
- data/lib/active_fedora/rake_support.rb +1 -1
- data/lib/active_fedora/rdf/persistence.rb +1 -0
- data/lib/active_fedora/rdf/rdf_datastream.rb +7 -1
- data/lib/active_fedora/solr_hit.rb +0 -9
- data/lib/active_fedora/solr_query_builder.rb +1 -1
- data/lib/active_fedora/version.rb +1 -1
- data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +0 -11
- data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
- data/lib/generators/active_fedora/model/model_generator.rb +1 -1
- data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
- data/lib/tasks/active_fedora_dev.rake +1 -1
- data/solr/config/_rest_managed.json +3 -0
- data/solr/config/admin-extra.html +31 -0
- data/solr/config/elevate.xml +36 -0
- data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
- data/solr/config/protwords.txt +21 -0
- data/solr/config/schema.xml +372 -0
- data/solr/config/scripts.conf +24 -0
- data/solr/config/solrconfig.xml +311 -0
- data/solr/config/spellings.txt +2 -0
- data/solr/config/stopwords.txt +58 -0
- data/solr/config/stopwords_en.txt +58 -0
- data/solr/config/synonyms.txt +31 -0
- data/solr/config/xslt/example.xsl +132 -0
- data/solr/config/xslt/example_atom.xsl +67 -0
- data/solr/config/xslt/example_rss.xsl +66 -0
- data/solr/config/xslt/luke.xsl +337 -0
- data/spec/integration/associations_spec.rb +6 -6
- data/spec/integration/basic_contains_association_spec.rb +1 -1
- data/spec/integration/clean_connection_spec.rb +1 -1
- data/spec/integration/complex_rdf_datastream_spec.rb +4 -5
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +15 -14
- data/spec/integration/date_time_properties_spec.rb +0 -15
- data/spec/integration/direct_container_spec.rb +4 -4
- data/spec/integration/directly_contains_one_association_spec.rb +1 -1
- data/spec/integration/eradicate_spec.rb +1 -1
- data/spec/integration/generators/solr_generator_spec.rb +10 -7
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
- data/spec/integration/has_many_associations_spec.rb +4 -4
- data/spec/integration/indexing_spec.rb +1 -1
- data/spec/integration/indirect_container_spec.rb +3 -3
- data/spec/integration/ntriples_datastream_spec.rb +35 -23
- data/spec/integration/rdf_nested_attributes_spec.rb +3 -3
- data/spec/integration/relation_delegation_spec.rb +2 -2
- data/spec/integration/scoped_query_spec.rb +3 -3
- data/spec/integration/solr_hit_spec.rb +0 -11
- data/spec/integration/versionable_spec.rb +6 -6
- data/spec/integration/with_metadata_spec.rb +1 -1
- data/spec/samples/hydra-mods_article_datastream.rb +2 -4
- data/spec/unit/base_spec.rb +3 -4
- data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
- data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
- data/spec/unit/core_spec.rb +5 -5
- data/spec/unit/fedora_spec.rb +1 -2
- data/spec/unit/file_spec.rb +2 -2
- data/spec/unit/filter_spec.rb +3 -3
- data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +2 -2
- data/spec/unit/has_many_association_spec.rb +11 -26
- data/spec/unit/ntriples_datastream_spec.rb +6 -9
- data/spec/unit/ordered_spec.rb +8 -11
- data/spec/unit/orders/list_node_spec.rb +2 -2
- data/spec/unit/orders/ordered_list_spec.rb +1 -1
- data/spec/unit/query_spec.rb +4 -4
- data/spec/unit/rdf/indexing_service_spec.rb +5 -5
- data/spec/unit/rdf_resource_datastream_spec.rb +4 -0
- metadata +44 -17
- data/.solr_wrapper +0 -6
- data/lib/active_fedora/profile_indexing_service.rb +0 -11
- data/lib/active_fedora/solr_instance_loader.rb +0 -47
- data/spec/integration/solr_instance_loader_spec.rb +0 -156
@@ -9,7 +9,7 @@ describe "Nesting attribute behavior of RDF resources" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class CustomName < ActiveFedora::Base
|
12
|
-
property :pref_label, predicate: ::RDF::SKOS.prefLabel, multiple: false
|
12
|
+
property :pref_label, predicate: ::RDF::Vocab::SKOS.prefLabel, multiple: false
|
13
13
|
end
|
14
14
|
|
15
15
|
class CustomSource < ActiveFedora::Base
|
@@ -52,11 +52,11 @@ describe "Nesting attribute behavior of RDF resources" do
|
|
52
52
|
|
53
53
|
it "sets the attributes" do
|
54
54
|
expect(subject.topic.size).to eq 2
|
55
|
-
expect(subject.topic.map(&:subject)).to
|
55
|
+
expect(subject.topic.map(&:subject)).to contain_exactly ['Foo'], ['Bar']
|
56
56
|
end
|
57
57
|
|
58
58
|
it "marks the attributes as changed" do
|
59
|
-
expect(subject.changed_attributes).to eq
|
59
|
+
expect(subject.changed_attributes.keys).to eq ["topic"]
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -28,11 +28,11 @@ describe ActiveFedora::Base do
|
|
28
28
|
subject { TestClass.where(bar: 'Peanuts') }
|
29
29
|
|
30
30
|
it "maps" do
|
31
|
-
expect(subject.map(&:id)).to
|
31
|
+
expect(subject.map(&:id)).to contain_exactly instance2.id, instance3.id
|
32
32
|
end
|
33
33
|
|
34
34
|
it "collects" do
|
35
|
-
expect(subject.collect(&:id)).to
|
35
|
+
expect(subject.collect(&:id)).to contain_exactly instance2.id, instance3.id
|
36
36
|
end
|
37
37
|
|
38
38
|
it "has each" do
|
@@ -68,13 +68,13 @@ describe ActiveFedora::Querying do
|
|
68
68
|
expect(ModelIntegrationSpec::Basic.where('foo' => ['Beta', 'Alpha'])).to eq [test_instance1, test_instance2]
|
69
69
|
end
|
70
70
|
it "orders" do
|
71
|
-
expect(ModelIntegrationSpec::Basic.order(ActiveFedora.index_field_mapper.solr_name('foo', :sortable) + ' asc')).to
|
71
|
+
expect(ModelIntegrationSpec::Basic.order(ActiveFedora.index_field_mapper.solr_name('foo', :sortable) + ' asc')).to contain_exactly test_instance2, test_instance1, test_instance3
|
72
72
|
end
|
73
73
|
it "limits" do
|
74
74
|
expect(ModelIntegrationSpec::Basic.limit(1)).to eq [test_instance1]
|
75
75
|
end
|
76
76
|
it "offsets" do
|
77
|
-
expect(ModelIntegrationSpec::Basic.offset(1)).to
|
77
|
+
expect(ModelIntegrationSpec::Basic.offset(1)).to contain_exactly test_instance2, test_instance3
|
78
78
|
end
|
79
79
|
|
80
80
|
it "chains queries" do
|
@@ -127,7 +127,7 @@ describe ActiveFedora::Querying do
|
|
127
127
|
end
|
128
128
|
it "logs an error" do
|
129
129
|
expect(ActiveFedora::Base.logger).to receive(:error).with("Although #{id} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch.")
|
130
|
-
expect(ModelIntegrationSpec::Basic.all).to
|
130
|
+
expect(ModelIntegrationSpec::Basic.all).to contain_exactly test_instance1, test_instance3
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|
@@ -29,15 +29,4 @@ describe ActiveFedora::SolrHit do
|
|
29
29
|
expect(subject.title).to eq 'My Title'
|
30
30
|
end
|
31
31
|
end
|
32
|
-
|
33
|
-
describe "#instantiate_with_json" do
|
34
|
-
subject { solr_hit.instantiate_with_json }
|
35
|
-
|
36
|
-
it { is_expected.to be_persisted }
|
37
|
-
|
38
|
-
it "finds the document in solr" do
|
39
|
-
expect(subject).to be_instance_of Foo
|
40
|
-
expect(subject.title).to eq 'My Title'
|
41
|
-
end
|
42
|
-
end
|
43
32
|
end
|
@@ -106,7 +106,7 @@ describe ActiveFedora::Versionable do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
it "will return to the first version's values" do
|
109
|
-
expect(subject.title).to
|
109
|
+
expect(subject.title).to eq(["Greetings Earthlings"])
|
110
110
|
end
|
111
111
|
|
112
112
|
context "and creating additional versions" do
|
@@ -118,7 +118,7 @@ describe ActiveFedora::Versionable do
|
|
118
118
|
|
119
119
|
it "has three versions" do
|
120
120
|
expect(subject.versions.all.size).to eq 3
|
121
|
-
expect(subject.title).to
|
121
|
+
expect(subject.title).to eq(["Now, surrender and prepare to be boarded"])
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -179,7 +179,7 @@ describe ActiveFedora::Versionable do
|
|
179
179
|
end
|
180
180
|
|
181
181
|
it "has a title" do
|
182
|
-
expect(subject.title).to
|
182
|
+
expect(subject.title).to eq(["Greetings Earthlings"])
|
183
183
|
end
|
184
184
|
|
185
185
|
it "has a size" do
|
@@ -202,7 +202,7 @@ describe ActiveFedora::Versionable do
|
|
202
202
|
end
|
203
203
|
|
204
204
|
it "has the new title" do
|
205
|
-
expect(subject.title).to
|
205
|
+
expect(subject.title).to eq(["Surrender and prepare to be boarded"])
|
206
206
|
end
|
207
207
|
|
208
208
|
it "has a new size" do
|
@@ -221,7 +221,7 @@ describe ActiveFedora::Versionable do
|
|
221
221
|
end
|
222
222
|
|
223
223
|
it "loads the restored file's content" do
|
224
|
-
expect(subject.title).to
|
224
|
+
expect(subject.title).to eq(["Greetings Earthlings"])
|
225
225
|
end
|
226
226
|
|
227
227
|
it "is the same size as the original file" do
|
@@ -240,7 +240,7 @@ describe ActiveFedora::Versionable do
|
|
240
240
|
end
|
241
241
|
|
242
242
|
it "has a new title" do
|
243
|
-
expect(subject.title).to
|
243
|
+
expect(subject.title).to eq(["Now, surrender and prepare to be boarded"])
|
244
244
|
end
|
245
245
|
|
246
246
|
it "has a new size" do
|
@@ -253,8 +253,7 @@ module Hydra
|
|
253
253
|
"edt" => "Editor",
|
254
254
|
"ill" => "Illustrator",
|
255
255
|
"oth" => "Other",
|
256
|
-
"trl" => "Translator"
|
257
|
-
}
|
256
|
+
"trl" => "Translator" }
|
258
257
|
end
|
259
258
|
|
260
259
|
def self.person_relator_terms
|
@@ -268,8 +267,7 @@ module Hydra
|
|
268
267
|
"res" => "Researcher",
|
269
268
|
"rth" => "Research team head",
|
270
269
|
"rtm" => "Research team member",
|
271
|
-
"trl" => "Translator"
|
272
|
-
}
|
270
|
+
"trl" => "Translator" }
|
273
271
|
end
|
274
272
|
|
275
273
|
def self.conference_relator_terms
|
data/spec/unit/base_spec.rb
CHANGED
@@ -72,8 +72,8 @@ describe ActiveFedora::Base do
|
|
72
72
|
context "on an inherited class" do
|
73
73
|
before do
|
74
74
|
class Agent < ActiveFedora::Base
|
75
|
-
rdf_label ::RDF::FOAF.name
|
76
|
-
property :foaf_name, predicate: ::RDF::FOAF.name
|
75
|
+
rdf_label ::RDF::Vocab::FOAF.name
|
76
|
+
property :foaf_name, predicate: ::RDF::Vocab::FOAF.name
|
77
77
|
end
|
78
78
|
class Person < Agent
|
79
79
|
rdf_label ::RDF::URI('http://example.com/foo')
|
@@ -141,7 +141,6 @@ describe ActiveFedora::Base do
|
|
141
141
|
|
142
142
|
context "with an id argument" do
|
143
143
|
it "is able to create with a custom id" do
|
144
|
-
expect(Deprecation).to receive(:warn)
|
145
144
|
expect(FooHistory).to receive(:id_to_uri).and_call_original
|
146
145
|
f = FooHistory.new('baz_1')
|
147
146
|
expect(f.id).to eq 'baz_1'
|
@@ -260,7 +259,7 @@ describe ActiveFedora::Base do
|
|
260
259
|
end
|
261
260
|
|
262
261
|
it "updates the resource" do
|
263
|
-
expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.
|
262
|
+
expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/#{@this_id}")
|
264
263
|
expect(test_object.title).to eq ['foo']
|
265
264
|
end
|
266
265
|
end
|
@@ -4,7 +4,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
|
|
4
4
|
describe ".call" do
|
5
5
|
let(:result) { described_class.call(id) }
|
6
6
|
context "when given an id" do
|
7
|
-
let(:good_uri) { ActiveFedora.fedora.
|
7
|
+
let(:good_uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/banana" }
|
8
8
|
let(:id) { "banana" }
|
9
9
|
it "returns a fedora URI" do
|
10
10
|
expect(result).to eq good_uri
|
@@ -18,7 +18,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
context "with characters that need escaping" do
|
21
|
-
let(:good_uri) { ActiveFedora.fedora.
|
21
|
+
let(:good_uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/%5Bfrob%5D" }
|
22
22
|
let(:id) { "[frob]" }
|
23
23
|
it "returns a good fedora URI" do
|
24
24
|
expect(result).to eq good_uri
|
@@ -4,13 +4,13 @@ RSpec.describe ActiveFedora::Core::FedoraUriTranslator do
|
|
4
4
|
describe ".call" do
|
5
5
|
let(:result) { described_class.call(uri) }
|
6
6
|
context "when given a Fedora URI" do
|
7
|
-
let(:uri) { ActiveFedora.fedora.
|
7
|
+
let(:uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/6" }
|
8
8
|
it "returns the id" do
|
9
9
|
expect(result).to eq '6'
|
10
10
|
end
|
11
11
|
end
|
12
12
|
context "when given a URI missing a slash" do
|
13
|
-
let(:uri) { ActiveFedora.fedora.
|
13
|
+
let(:uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "602-a" }
|
14
14
|
it "returns the id" do
|
15
15
|
expect(result).to eq "602-a"
|
16
16
|
end
|
data/spec/unit/core_spec.rb
CHANGED
@@ -109,7 +109,7 @@ describe ActiveFedora::Base do
|
|
109
109
|
subject { described_class.id_to_uri(id) }
|
110
110
|
|
111
111
|
context "with no custom proc is set" do
|
112
|
-
it {
|
112
|
+
it { should eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/123456w" }
|
113
113
|
it "justs call #translate_id_to_uri" do
|
114
114
|
allow(described_class).to receive(:translate_id_to_uri).and_call_original
|
115
115
|
allow(ActiveFedora::Core::FedoraIdTranslator).to receive(:call).and_call_original
|
@@ -122,11 +122,11 @@ describe ActiveFedora::Base do
|
|
122
122
|
|
123
123
|
context "when custom proc is set" do
|
124
124
|
before do
|
125
|
-
described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.
|
125
|
+
described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/#{id}" }
|
126
126
|
end
|
127
127
|
after { described_class.translate_id_to_uri = nil }
|
128
128
|
|
129
|
-
it {
|
129
|
+
it { should eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/123456w" }
|
130
130
|
end
|
131
131
|
|
132
132
|
context "with an empty base path" do
|
@@ -145,8 +145,8 @@ describe ActiveFedora::Base do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
describe "uri_to_id" do
|
148
|
-
let(:uri) { "#{ActiveFedora.fedora.
|
149
|
-
subject
|
148
|
+
let(:uri) { "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/123456w" }
|
149
|
+
subject { described_class.uri_to_id(uri) }
|
150
150
|
|
151
151
|
context "with no custom proc is set" do
|
152
152
|
it { should eq 'foo/123456w' }
|
data/spec/unit/fedora_spec.rb
CHANGED
@@ -8,8 +8,7 @@ describe ActiveFedora::Fedora do
|
|
8
8
|
{ url: "https://example.com",
|
9
9
|
user: "fedoraAdmin",
|
10
10
|
password: "fedoraAdmin",
|
11
|
-
ssl: { ca_path: '/path/to/certs' }
|
12
|
-
}
|
11
|
+
ssl: { ca_path: '/path/to/certs' } }
|
13
12
|
}
|
14
13
|
specify {
|
15
14
|
expect(Faraday).to receive(:new).with("https://example.com", ssl: { ca_path: '/path/to/certs' }).and_call_original
|
data/spec/unit/file_spec.rb
CHANGED
@@ -51,14 +51,14 @@ describe ActiveFedora::File do
|
|
51
51
|
context "and it's initialized with the URI" do
|
52
52
|
let(:file) { described_class.new(parent.uri + "/FOO1") }
|
53
53
|
it "works" do
|
54
|
-
expect(subject.to_s).to eq "#{ActiveFedora.fedora.
|
54
|
+
expect(subject.to_s).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
context "and it's initialized with an ID" do
|
59
59
|
let(:file) { described_class.new(parent.id + "/FOO1") }
|
60
60
|
it "works" do
|
61
|
-
expect(subject.to_s).to eq "#{ActiveFedora.fedora.
|
61
|
+
expect(subject.to_s).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/spec/unit/filter_spec.rb
CHANGED
@@ -55,7 +55,7 @@ describe ActiveFedora::Associations::FilterAssociation do
|
|
55
55
|
image.child_collections = [another_collection]
|
56
56
|
end
|
57
57
|
it "overwrites existing matches" do
|
58
|
-
expect(image.members).to
|
58
|
+
expect(image.members).to contain_exactly test_object, another_collection
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -75,7 +75,7 @@ describe ActiveFedora::Associations::FilterAssociation do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it "updates the parent" do
|
78
|
-
expect(image.members).to
|
78
|
+
expect(image.members).to contain_exactly test_object, test_collection, another_collection
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -128,6 +128,6 @@ describe ActiveFedora::Associations::FilterAssociation do
|
|
128
128
|
|
129
129
|
subject { image.members }
|
130
130
|
|
131
|
-
it { is_expected.to
|
131
|
+
it { is_expected.to contain_exactly test_collection, another_object }
|
132
132
|
end
|
133
133
|
end
|
@@ -24,8 +24,8 @@ describe ActiveFedora::Attributes, ".new" do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Person < ActiveFedora::Base
|
27
|
-
property :first_name, predicate: ::RDF::FOAF.firstName, multiple: false
|
28
|
-
property :gender, predicate: ::RDF::FOAF.gender, multiple: false
|
27
|
+
property :first_name, predicate: ::RDF::Vocab::FOAF.firstName, multiple: false
|
28
|
+
property :gender, predicate: ::RDF::Vocab::FOAF.gender, multiple: false
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -18,7 +18,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
18
18
|
Object.send(:remove_const, :Book)
|
19
19
|
Object.send(:remove_const, :Page)
|
20
20
|
end
|
21
|
-
subject { Book.new(
|
21
|
+
subject { Book.new('subject-a') }
|
22
22
|
|
23
23
|
context "a one way relationship " do
|
24
24
|
describe "adding memeber" do
|
@@ -114,7 +114,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
114
114
|
it "clears the object set" do
|
115
115
|
expect(collection.members).to eq [thing]
|
116
116
|
collection.member_ids = [thing2.id, thing3.id]
|
117
|
-
expect(collection.members).to
|
117
|
+
expect(collection.members).to contain_exactly thing2, thing3
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -12,8 +12,8 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
12
12
|
Object.send(:remove_const, :Book)
|
13
13
|
Object.send(:remove_const, :Page)
|
14
14
|
end
|
15
|
-
let(:book) { Book.new(
|
16
|
-
let(:page) { Page.new(
|
15
|
+
let(:book) { Book.new('subject-a') }
|
16
|
+
let(:page) { Page.new('object-b') }
|
17
17
|
|
18
18
|
describe "setting the foreign key" do
|
19
19
|
before do
|
@@ -32,34 +32,19 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe "
|
35
|
+
describe "Finding a polymorphic inverse relation" do
|
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
|
36
41
|
let(:book_reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
37
42
|
let(:association) { described_class.new(book, book_reflection) }
|
38
43
|
|
39
|
-
subject
|
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
|
44
|
+
subject { association.send(:find_polymorphic_inverse, page) }
|
59
45
|
|
60
|
-
|
61
|
-
|
62
|
-
end
|
46
|
+
it "finds the HABTM reflection" do
|
47
|
+
expect(subject.name).to eq :contents
|
63
48
|
end
|
64
49
|
end
|
65
50
|
|
@@ -20,8 +20,8 @@ EOF
|
|
20
20
|
property :publisher, predicate: ::RDF::Vocab::DC.publisher
|
21
21
|
property :creator, predicate: ::RDF::Vocab::DC.creator
|
22
22
|
property :educationLevel, predicate: ::RDF::Vocab::DC.educationLevel
|
23
|
-
property :based_near, predicate: ::RDF::FOAF.based_near
|
24
|
-
property :related_url, predicate: ::RDF::RDFS.seeAlso
|
23
|
+
property :based_near, predicate: ::RDF::Vocab::FOAF.based_near
|
24
|
+
property :related_url, predicate: ::RDF::Vocab::RDFS.seeAlso
|
25
25
|
end
|
26
26
|
@subject = MyDatastream.new(ActiveFedora::Base.id_to_uri('/test:1/descMetadata'))
|
27
27
|
@subject.content = remote_content
|
@@ -55,9 +55,6 @@ EOF
|
|
55
55
|
expect(val).to eq ["0. Title of work"]
|
56
56
|
end
|
57
57
|
|
58
|
-
it "returns fields that are not TermProxies" do
|
59
|
-
expect(@subject.created).to be_kind_of Array
|
60
|
-
end
|
61
58
|
it "has method missing" do
|
62
59
|
expect(lambda { @subject.frank }).to raise_exception NoMethodError
|
63
60
|
end
|
@@ -72,7 +69,7 @@ EOF
|
|
72
69
|
end
|
73
70
|
it "appends fields" do
|
74
71
|
@subject.publisher << "St. Martin's Press"
|
75
|
-
expect(@subject.publisher).to
|
72
|
+
expect(@subject.publisher).to contain_exactly "Penn State", "St. Martin's Press"
|
76
73
|
end
|
77
74
|
it "deletes fields" do
|
78
75
|
@subject.related_url.delete(RDF::URI("http://google.com/"))
|
@@ -98,8 +95,8 @@ EOF
|
|
98
95
|
property :created, predicate: ::RDF::Vocab::DC.created
|
99
96
|
property :title, predicate: ::RDF::Vocab::DC.title
|
100
97
|
property :publisher, predicate: ::RDF::Vocab::DC.publisher
|
101
|
-
property :based_near, predicate: ::RDF::FOAF.based_near
|
102
|
-
property :related_url, predicate: ::RDF::RDFS.seeAlso
|
98
|
+
property :based_near, predicate: ::RDF::Vocab::FOAF.based_near
|
99
|
+
property :related_url, predicate: ::RDF::Vocab::RDFS.seeAlso
|
103
100
|
end
|
104
101
|
@subject = MyDatastream.new
|
105
102
|
allow(@subject).to receive(:id).and_return 'test:1'
|
@@ -132,7 +129,7 @@ EOF
|
|
132
129
|
Object.send(:remove_const, :MyDatastream)
|
133
130
|
end
|
134
131
|
|
135
|
-
|
132
|
+
xit "supports to_s method" do
|
136
133
|
expect(@subject.publisher.to_s).to eq [].to_s
|
137
134
|
@subject.publisher = "Bob"
|
138
135
|
expect(@subject.publisher.to_s).to eq ["Bob"].to_s
|
data/spec/unit/ordered_spec.rb
CHANGED
@@ -58,16 +58,6 @@ describe ActiveFedora::Orders do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
it "can load from solr" do
|
62
|
-
member = Member.new
|
63
|
-
subject.ordered_members << member
|
64
|
-
subject.save!
|
65
|
-
solr_doc = ActiveFedora::SolrService.query("id:#{subject.id}").first
|
66
|
-
|
67
|
-
allow(Deprecation).to receive(:warn)
|
68
|
-
expect { ActiveFedora::Base.load_instance_from_solr(subject.id, solr_doc) }.not_to raise_error
|
69
|
-
end
|
70
|
-
|
71
61
|
describe "#ordered_members" do
|
72
62
|
describe "<<" do
|
73
63
|
it "appends" do
|
@@ -98,7 +88,7 @@ describe ActiveFedora::Orders do
|
|
98
88
|
subject.ordered_members = [member_2, member_2]
|
99
89
|
expect(subject.ordered_members).to eq [member_2, member_2]
|
100
90
|
# Removing from ordering is not the same as removing from aggregation.
|
101
|
-
expect(subject.members).to
|
91
|
+
expect(subject.members).to contain_exactly member, member_2
|
102
92
|
end
|
103
93
|
end
|
104
94
|
describe "+=" do
|
@@ -135,6 +125,12 @@ describe ActiveFedora::Orders do
|
|
135
125
|
expect(subject.ordered_members.delete(member)).to eq member
|
136
126
|
expect(subject.ordered_members.to_a).to eq [member_2]
|
137
127
|
end
|
128
|
+
it "can delete all" do
|
129
|
+
expect(subject.ordered_members.delete(member)).to eq member
|
130
|
+
expect(subject.ordered_members.delete(member_2)).to eq member_2
|
131
|
+
subject.save!
|
132
|
+
expect(subject.reload.ordered_members.to_a).to eq []
|
133
|
+
end
|
138
134
|
end
|
139
135
|
|
140
136
|
context "with an object not found in the list" do
|
@@ -227,6 +223,7 @@ describe ActiveFedora::Orders do
|
|
227
223
|
subject.save
|
228
224
|
subject.reload
|
229
225
|
expect(subject.ordered_members).to eq [member, member]
|
226
|
+
expect(subject.ordered_member_ids).to eq [member.id, member.id]
|
230
227
|
expect(subject.list_source.resource.query([nil, ::RDF::Vocab::ORE.proxyIn, subject.resource.rdf_subject]).to_a.length).to eq 2
|
231
228
|
expect(subject.head_ids).to eq subject.list_source.head_id
|
232
229
|
expect(subject.tail_ids).to eq subject.list_source.tail_id
|