active-fedora 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +97 -0
- data/README.md +40 -28
- data/active-fedora.gemspec +2 -1
- data/lib/active_fedora/associations/builder/contains.rb +5 -1
- data/lib/active_fedora/associations/builder/has_many.rb +1 -1
- data/lib/active_fedora/associations/collection_association.rb +1 -18
- data/lib/active_fedora/associations/contains_association.rb +3 -1
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +12 -10
- data/lib/active_fedora/associations.rb +1 -1
- data/lib/active_fedora/attached_files.rb +7 -4
- data/lib/active_fedora/attributes/property_builder.rb +1 -0
- data/lib/active_fedora/attributes.rb +36 -9
- data/lib/active_fedora/change_set.rb +2 -2
- data/lib/active_fedora/clean_connection.rb +40 -0
- data/lib/active_fedora/core/fedora_id_translator.rb +12 -0
- data/lib/active_fedora/core/fedora_uri_translator.rb +9 -0
- data/lib/active_fedora/core.rb +26 -38
- data/lib/active_fedora/errors.rb +4 -0
- data/lib/active_fedora/fedora.rb +22 -4
- data/lib/active_fedora/fedora_attributes.rb +25 -1
- data/lib/active_fedora/file.rb +30 -24
- data/lib/active_fedora/indexing/map.rb +46 -0
- data/lib/active_fedora/indexing.rb +14 -0
- data/lib/active_fedora/inheritable_accessors.rb +26 -0
- data/lib/active_fedora/loadable_from_json.rb +5 -1
- data/lib/active_fedora/nom_datastream.rb +6 -4
- data/lib/active_fedora/persistence.rb +11 -7
- data/lib/active_fedora/rdf/datastream_indexing.rb +4 -0
- data/lib/active_fedora/rdf/fcrepo4.rb +1 -0
- data/lib/active_fedora/rdf/indexing_service.rb +18 -11
- data/lib/active_fedora/rdf/ldp.rb +3 -0
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -4
- data/lib/active_fedora/rdf/rdf_datastream.rb +12 -1
- data/lib/active_fedora/reflection.rb +3 -1
- data/lib/active_fedora/relation/finder_methods.rb +36 -5
- data/lib/active_fedora/solr_query_builder.rb +1 -1
- data/lib/active_fedora/solr_service.rb +1 -1
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versions_graph.rb +7 -8
- data/lib/active_fedora.rb +6 -0
- data/spec/integration/associations_spec.rb +64 -21
- data/spec/integration/attached_files_spec.rb +24 -0
- data/spec/integration/attributes_spec.rb +49 -3
- data/spec/integration/belongs_to_association_spec.rb +118 -47
- data/spec/integration/clean_connection_spec.rb +21 -0
- data/spec/integration/collection_association_spec.rb +46 -0
- data/spec/integration/field_to_solr_name_spec.rb +11 -7
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +180 -137
- data/spec/integration/has_many_associations_spec.rb +6 -2
- data/spec/integration/json_serialization_spec.rb +11 -5
- data/spec/integration/nested_attribute_spec.rb +3 -1
- data/spec/integration/ntriples_datastream_spec.rb +23 -17
- data/spec/integration/persistence_spec.rb +3 -1
- data/spec/integration/query_result_builder_spec.rb +2 -2
- data/spec/integration/relation_delegation_spec.rb +3 -1
- data/spec/integration/scoped_query_spec.rb +3 -1
- data/spec/integration/solr_instance_loader_spec.rb +4 -2
- data/spec/integration/versionable_spec.rb +38 -1
- data/spec/samples/samples.rb +0 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/active_fedora_spec.rb +4 -2
- data/spec/unit/attributes_spec.rb +52 -12
- data/spec/unit/base_active_model_spec.rb +5 -3
- data/spec/unit/base_spec.rb +102 -2
- data/spec/unit/callback_spec.rb +4 -2
- data/spec/unit/change_set_spec.rb +4 -2
- data/spec/unit/core/fedora_id_translator_spec.rb +20 -0
- data/spec/unit/core/fedora_uri_translator_spec.rb +19 -0
- data/spec/unit/core_spec.rb +54 -2
- data/spec/unit/has_many_association_spec.rb +27 -2
- data/spec/unit/ntriples_datastream_spec.rb +24 -20
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -6
- data/spec/unit/query_result_builder_spec.rb +1 -1
- data/spec/unit/rdf/indexing_service_spec.rb +19 -17
- data/spec/unit/rdf_resource_datastream_spec.rb +14 -10
- data/spec/unit/reflection_spec.rb +44 -0
- data/spec/unit/simple_datastream_spec.rb +34 -0
- data/spec/unit/solr_query_builder_spec.rb +1 -1
- data/spec/unit/validations_spec.rb +4 -2
- metadata +28 -13
- data/spec/samples/marpa-dc_datastream.rb +0 -102
- data/spec/samples/models/audio_record.rb +0 -29
- data/spec/samples/models/image.rb +0 -5
- data/spec/samples/models/oral_history.rb +0 -36
- data/spec/samples/models/seminar.rb +0 -29
- data/spec/samples/models/seminar_audio_file.rb +0 -32
- data/spec/samples/oral_history_sample_model.rb +0 -30
- data/spec/samples/special_thing.rb +0 -44
|
@@ -5,16 +5,20 @@ describe "An object with RDF backed attributes" do
|
|
|
5
5
|
before do
|
|
6
6
|
class TestOne < ActiveFedora::Base
|
|
7
7
|
class MyMetadata < ActiveFedora::NtriplesRDFDatastream
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
Deprecation.silence(ActiveFedora::RDFDatastream) do
|
|
9
|
+
property :title, predicate: ::RDF::DC.title do |index|
|
|
10
|
+
index.as :stored_searchable
|
|
11
|
+
end
|
|
12
|
+
property :date_uploaded, predicate: ::RDF::DC.dateSubmitted do |index|
|
|
13
|
+
index.type :date
|
|
14
|
+
index.as :stored_searchable, :sortable
|
|
15
|
+
end
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
18
|
has_metadata 'descMetadata', type: MyMetadata
|
|
17
|
-
|
|
19
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
20
|
+
has_attributes :title, :date_uploaded, datastream: 'descMetadata'
|
|
21
|
+
end
|
|
18
22
|
end
|
|
19
23
|
end
|
|
20
24
|
|
|
@@ -2,109 +2,131 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::Base do
|
|
4
4
|
describe "with inverse" do
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
context "that is also a HABTM" do
|
|
6
|
+
before do
|
|
7
|
+
class Book < ActiveFedora::Base
|
|
8
|
+
has_and_belongs_to_many :topics, predicate: ::RDF::FOAF.primaryTopic, inverse_of: :books
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Topic < ActiveFedora::Base
|
|
12
|
+
has_and_belongs_to_many :books, predicate: ::RDF::FOAF.isPrimaryTopicOf
|
|
13
|
+
end
|
|
9
14
|
end
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
after do
|
|
17
|
+
Object.send(:remove_const, :Book)
|
|
18
|
+
Object.send(:remove_const, :Topic)
|
|
12
19
|
end
|
|
13
20
|
|
|
21
|
+
describe "an unsaved instance" do
|
|
22
|
+
let(:topic1) { Topic.create }
|
|
23
|
+
let(:book) { Book.create }
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
it "habtm should set and remove relationships bidirectionally" do
|
|
26
|
+
book.topics << topic1
|
|
27
|
+
expect(book.topics).to eq [topic1]
|
|
28
|
+
expect(topic1.books).to eq [book]
|
|
29
|
+
expect(topic1.reload.books).to eq [book]
|
|
17
30
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
book.topics.delete(topic1)
|
|
32
|
+
expect(book.topics).to be_empty
|
|
33
|
+
expect(topic1.books).to be_empty
|
|
34
|
+
end
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
it "Should allow for more than 10 items" do
|
|
37
|
+
(1..12).each do
|
|
38
|
+
book.topics << Topic.create
|
|
39
|
+
end
|
|
40
|
+
book.save
|
|
41
|
+
expect(book.topics.count).to eq 12
|
|
42
|
+
book2 = Book.find(book.id)
|
|
43
|
+
expect(book2.topics.count).to eq 12
|
|
44
|
+
end
|
|
29
45
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
context "with subclassed objects" do
|
|
47
|
+
before do
|
|
48
|
+
class SpecialInheritedBook < Book
|
|
49
|
+
end
|
|
50
|
+
end
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
expect(topic1.books).to eq [@book]
|
|
40
|
-
expect(topic1.reload.books).to eq [@book]
|
|
52
|
+
after do
|
|
53
|
+
Object.send(:remove_const, :SpecialInheritedBook)
|
|
54
|
+
end
|
|
41
55
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
let!(:special_book) { SpecialInheritedBook.create }
|
|
57
|
+
it "Should find inherited objects along with base objects" do
|
|
58
|
+
book.topics << topic1
|
|
59
|
+
special_book.topics << topic1
|
|
60
|
+
expect(topic1.books).to match_array [book, special_book]
|
|
61
|
+
expect(topic1.reload.books).to match_array [book, special_book]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
45
64
|
end
|
|
46
65
|
|
|
47
|
-
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
let!(:special_book) { SpecialInheritedBook.create }
|
|
59
|
-
it "Should find inherited objects along with base objects" do
|
|
60
|
-
@book.topics << topic1
|
|
61
|
-
special_book.topics << topic1
|
|
62
|
-
expect(topic1.books).to eq [@book, special_book]
|
|
63
|
-
expect(topic1.reload.books).to eq [@book, special_book]
|
|
66
|
+
describe "a saved instance" do
|
|
67
|
+
let!(:book) { Book.create }
|
|
68
|
+
let!(:topic1) { Topic.create }
|
|
69
|
+
let!(:topic2) { Topic.create }
|
|
70
|
+
|
|
71
|
+
it "should set relationships bidirectionally" do
|
|
72
|
+
book.topics << topic1
|
|
73
|
+
expect(book.topics).to eq [topic1]
|
|
74
|
+
expect(book['topic_ids']).to eq [topic1.id]
|
|
75
|
+
expect(topic1['book_ids']).to eq [book.id]
|
|
76
|
+
expect(Topic.find(topic1.id).books).to eq [book] #Can't have saved it because book isn't saved yet.
|
|
64
77
|
end
|
|
65
|
-
end
|
|
66
78
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
it "should save new child objects" do
|
|
80
|
+
book.topics << Topic.new
|
|
81
|
+
expect(book.topics.first.id).to_not be_nil
|
|
82
|
+
end
|
|
71
83
|
|
|
72
|
-
|
|
84
|
+
it "should clear out the old associtions" do
|
|
85
|
+
book.topics = [topic1]
|
|
86
|
+
book.topics = [topic2]
|
|
87
|
+
expect(book.topic_ids).to eq [topic2.id]
|
|
88
|
+
end
|
|
73
89
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
context "with members" do
|
|
91
|
+
before do
|
|
92
|
+
book.topics = [topic1, topic2]
|
|
93
|
+
book.save
|
|
94
|
+
end
|
|
78
95
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
96
|
+
context "destroy" do
|
|
97
|
+
it "should remove the associations" do
|
|
98
|
+
book.destroy
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
85
102
|
end
|
|
103
|
+
end
|
|
86
104
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
context "that is a has_many" do
|
|
106
|
+
before do
|
|
107
|
+
class Book < ActiveFedora::Base
|
|
108
|
+
has_many :collections
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
class Collection < ActiveFedora::Base
|
|
112
|
+
has_and_belongs_to_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection
|
|
113
|
+
end
|
|
90
114
|
end
|
|
91
115
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
expect(book.topic_ids).to eq [topic2.id]
|
|
116
|
+
after do
|
|
117
|
+
Object.send(:remove_const, :Book)
|
|
118
|
+
Object.send(:remove_const, :Collection)
|
|
96
119
|
end
|
|
97
120
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
book.save
|
|
102
|
-
end
|
|
121
|
+
describe "add and remove members" do
|
|
122
|
+
let(:collection) { Collection.create }
|
|
123
|
+
let(:book) { Book.create }
|
|
103
124
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
125
|
+
it "is successful" do
|
|
126
|
+
collection.books << book
|
|
127
|
+
expect {
|
|
128
|
+
collection.books.delete(book)
|
|
129
|
+
}.to change { collection.books.size }.from(1).to(0)
|
|
108
130
|
end
|
|
109
131
|
end
|
|
110
132
|
end
|
|
@@ -297,87 +319,108 @@ describe ActiveFedora::Base do
|
|
|
297
319
|
end
|
|
298
320
|
end
|
|
299
321
|
end
|
|
300
|
-
end
|
|
301
322
|
|
|
302
|
-
describe "create" do
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
323
|
+
describe "create" do
|
|
324
|
+
before do
|
|
325
|
+
class Book < ActiveFedora::Base
|
|
326
|
+
has_and_belongs_to_many :collections, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection
|
|
327
|
+
end
|
|
307
328
|
|
|
308
|
-
|
|
309
|
-
|
|
329
|
+
class Collection < ActiveFedora::Base
|
|
330
|
+
property :title, predicate: ::RDF::DC.title
|
|
331
|
+
end
|
|
310
332
|
end
|
|
311
|
-
end
|
|
312
333
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
334
|
+
after do
|
|
335
|
+
Object.send(:remove_const, :Book)
|
|
336
|
+
Object.send(:remove_const, :Collection)
|
|
337
|
+
end
|
|
317
338
|
|
|
318
|
-
|
|
339
|
+
let(:book) { Book.create }
|
|
319
340
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
341
|
+
it "should create" do
|
|
342
|
+
collection = book.collections.create(title: ["Permanent"])
|
|
343
|
+
expect(collection).to be_kind_of Collection
|
|
344
|
+
expect(book.collections).to include collection
|
|
345
|
+
book.save
|
|
346
|
+
expect(book.reload.collections.first.title).to eq ['Permanent']
|
|
347
|
+
end
|
|
326
348
|
end
|
|
327
|
-
end
|
|
328
349
|
|
|
329
350
|
|
|
330
|
-
describe "Autosave" do
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
351
|
+
describe "Autosave" do
|
|
352
|
+
before do
|
|
353
|
+
class Item < ActiveFedora::Base
|
|
354
|
+
has_many :components
|
|
355
|
+
has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m|
|
|
356
|
+
m.field "title", :string
|
|
357
|
+
end
|
|
358
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
359
|
+
has_attributes :title, datastream: 'foo'
|
|
360
|
+
end
|
|
336
361
|
end
|
|
337
|
-
has_attributes :title, datastream: 'foo'
|
|
338
|
-
end
|
|
339
362
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
363
|
+
class Component < ActiveFedora::Base
|
|
364
|
+
has_and_belongs_to_many :items, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
|
365
|
+
has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m|
|
|
366
|
+
m.field "description", :string
|
|
367
|
+
end
|
|
368
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
369
|
+
has_attributes :description, datastream: 'foo'
|
|
370
|
+
end
|
|
344
371
|
end
|
|
345
|
-
has_attributes :description, datastream: 'foo'
|
|
346
372
|
end
|
|
347
|
-
end
|
|
348
373
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
374
|
+
after do
|
|
375
|
+
Object.send(:remove_const, :Item)
|
|
376
|
+
Object.send(:remove_const, :Component)
|
|
377
|
+
end
|
|
353
378
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
379
|
+
describe "From the has_and_belongs_to_many side" do
|
|
380
|
+
describe "dependent records" do
|
|
381
|
+
let(:component) { Component.create(items: [Item.new(title: 'my title')]) }
|
|
357
382
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
383
|
+
it "should be saved" do
|
|
384
|
+
component.reload
|
|
385
|
+
expect(component.items.first.title).to eq 'my title'
|
|
386
|
+
end
|
|
361
387
|
end
|
|
362
|
-
end
|
|
363
388
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
389
|
+
describe "shifting" do
|
|
390
|
+
let(:component) { Component.new }
|
|
391
|
+
let(:item) { Item.create }
|
|
367
392
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
393
|
+
it "should set item_ids" do
|
|
394
|
+
component.items << item
|
|
395
|
+
expect(component.item_ids).to eq [item.id]
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
context "when the has_and_belongs_to_many provides an inverse_of" do
|
|
400
|
+
let(:reflection) { Component.reflect_on_association(:items) }
|
|
401
|
+
before do
|
|
402
|
+
reflection.options[:inverse_of] = :components
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
describe "shifting" do
|
|
406
|
+
let(:component) { Component.create }
|
|
407
|
+
let(:item) { Item.new }
|
|
408
|
+
|
|
409
|
+
it "should set item_ids" do
|
|
410
|
+
component.items << item
|
|
411
|
+
expect(component.item_ids).to eq [item.id]
|
|
412
|
+
end
|
|
413
|
+
end
|
|
371
414
|
end
|
|
372
415
|
end
|
|
373
|
-
end
|
|
374
416
|
|
|
375
|
-
|
|
376
|
-
|
|
417
|
+
describe "From the has_many side" do
|
|
418
|
+
let(:item) { Item.create(components: [Component.new(description: 'my description')]) }
|
|
377
419
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
420
|
+
it "should save dependent records" do
|
|
421
|
+
item.reload
|
|
422
|
+
expect(item.components.first.description).to eq 'my description'
|
|
423
|
+
end
|
|
381
424
|
end
|
|
382
425
|
end
|
|
383
426
|
end
|
|
@@ -276,14 +276,18 @@ describe "Autosave" do
|
|
|
276
276
|
has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m|
|
|
277
277
|
m.field "title", :string
|
|
278
278
|
end
|
|
279
|
-
|
|
279
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
280
|
+
has_attributes :title, datastream: 'foo'
|
|
281
|
+
end
|
|
280
282
|
end
|
|
281
283
|
class Component < ActiveFedora::Base
|
|
282
284
|
belongs_to :item, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
|
283
285
|
has_metadata "foo", type: ActiveFedora::SimpleDatastream do |m|
|
|
284
286
|
m.field "description", :string
|
|
285
287
|
end
|
|
286
|
-
|
|
288
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
289
|
+
has_attributes :description, datastream: 'foo'
|
|
290
|
+
end
|
|
287
291
|
end
|
|
288
292
|
end
|
|
289
293
|
|
|
@@ -12,8 +12,10 @@ describe "Objects should be serialized to JSON" do
|
|
|
12
12
|
m.field "foo", :text
|
|
13
13
|
m.field "bar", :text
|
|
14
14
|
end
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
16
|
+
has_attributes :foo, datastream: 'descMetadata', multiple: true
|
|
17
|
+
has_attributes :bar, datastream: 'descMetadata', multiple: false
|
|
18
|
+
end
|
|
17
19
|
property :title, predicate: ::RDF::DC.title
|
|
18
20
|
end
|
|
19
21
|
end
|
|
@@ -43,8 +45,10 @@ describe "Objects should be serialized to JSON" do
|
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
class DummyResource < ActiveFedora::RDFDatastream
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
Deprecation.silence(ActiveFedora::RDFDatastream) do
|
|
49
|
+
property :license, predicate: ::RDF::DC[:license], class_name: DummySubnode do |index|
|
|
50
|
+
index.as :searchable, :displayable
|
|
51
|
+
end
|
|
48
52
|
end
|
|
49
53
|
def serialization_format
|
|
50
54
|
:ntriples
|
|
@@ -53,7 +57,9 @@ describe "Objects should be serialized to JSON" do
|
|
|
53
57
|
|
|
54
58
|
class DummyAsset < ActiveFedora::Base
|
|
55
59
|
has_metadata 'descMetadata', type: DummyResource
|
|
56
|
-
|
|
60
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
61
|
+
has_attributes :relation, datastream: 'descMetadata', at: [:license, :relation], multiple: false
|
|
62
|
+
end
|
|
57
63
|
end
|
|
58
64
|
end
|
|
59
65
|
|
|
@@ -8,7 +8,9 @@ describe "NestedAttribute behavior" do
|
|
|
8
8
|
m.field "uno", :string
|
|
9
9
|
m.field "dos", :string
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
12
|
+
has_attributes :uno, :dos, datastream: 'someData', multiple: false
|
|
13
|
+
end
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
# base Car class, used in test for association updates and :allow_destroy flag
|
|
@@ -7,27 +7,31 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
|
7
7
|
property :size
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
Deprecation.silence(ActiveFedora::RDFDatastream) do
|
|
11
|
+
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
|
12
|
+
property :title, predicate: ::RDF::DC.title do |index|
|
|
13
|
+
index.as :stored_searchable, :facetable
|
|
14
|
+
end
|
|
15
|
+
property :date_uploaded, predicate: ::RDF::DC.dateSubmitted do |index|
|
|
16
|
+
index.type :date
|
|
17
|
+
index.as :stored_searchable, :sortable
|
|
18
|
+
end
|
|
19
|
+
property :filesize, predicate: FileVocabulary.size do |index|
|
|
20
|
+
index.type :integer
|
|
21
|
+
index.as :stored_sortable
|
|
22
|
+
end
|
|
23
|
+
property :part, predicate: ::RDF::DC.hasPart
|
|
24
|
+
property :based_near, predicate: ::RDF::FOAF.based_near
|
|
25
|
+
property :related_url, predicate: ::RDF::RDFS.seeAlso
|
|
21
26
|
end
|
|
22
|
-
property :part, predicate: ::RDF::DC.hasPart
|
|
23
|
-
property :based_near, predicate: ::RDF::FOAF.based_near
|
|
24
|
-
property :related_url, predicate: ::RDF::RDFS.seeAlso
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
class RdfTest < ActiveFedora::Base
|
|
28
30
|
has_metadata 'rdf', type: MyDatastream
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
32
|
+
has_attributes :based_near, :related_url, :part, :date_uploaded, datastream: 'rdf', multiple: true
|
|
33
|
+
has_attributes :title, :filesize, datastream: 'rdf', multiple: false
|
|
34
|
+
end
|
|
31
35
|
end
|
|
32
36
|
@subject = RdfTest.new
|
|
33
37
|
end
|
|
@@ -216,7 +220,9 @@ describe ActiveFedora::NtriplesRDFDatastream do
|
|
|
216
220
|
end
|
|
217
221
|
class Foobar < ActiveFedora::Base
|
|
218
222
|
has_metadata 'rdf', type: TitleDatastream
|
|
219
|
-
|
|
223
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
224
|
+
has_attributes :title, datastream: 'rdf', multiple: true
|
|
225
|
+
end
|
|
220
226
|
end
|
|
221
227
|
@subject = Foobar.new
|
|
222
228
|
@subject.title = ["title1", "title2", "title3"]
|
|
@@ -6,7 +6,9 @@ describe "persisting objects" do
|
|
|
6
6
|
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"foo" do |m|
|
|
7
7
|
m.field "name", :string
|
|
8
8
|
end
|
|
9
|
-
|
|
9
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
10
|
+
has_attributes :name, datastream: 'foo', multiple: false
|
|
11
|
+
end
|
|
10
12
|
validates :name, presence: true
|
|
11
13
|
end
|
|
12
14
|
end
|
|
@@ -30,7 +30,7 @@ describe ActiveFedora::QueryResultBuilder do
|
|
|
30
30
|
Object.send(:remove_const, :FooObject)
|
|
31
31
|
end
|
|
32
32
|
it "should return an array of objects that are of the class stored in active_fedora_model_s" do
|
|
33
|
-
query =
|
|
33
|
+
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([@test_object.id, @foo_object.id])
|
|
34
34
|
solr_result = ActiveFedora::SolrService.query(query)
|
|
35
35
|
result = ActiveFedora::QueryResultBuilder.reify_solr_results(solr_result)
|
|
36
36
|
expect(result.length).to eq 2
|
|
@@ -40,7 +40,7 @@ describe ActiveFedora::QueryResultBuilder do
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it 'should #reify a lightweight object as a new instance' do
|
|
43
|
-
query =
|
|
43
|
+
query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([@foo_object.id])
|
|
44
44
|
solr_result = ActiveFedora::SolrService.query(query)
|
|
45
45
|
result = ActiveFedora::QueryResultBuilder.reify_solr_results(solr_result,{:load_from_solr=>true})
|
|
46
46
|
expect(result.first).to be_instance_of FooObject
|
|
@@ -11,7 +11,9 @@ describe ActiveFedora::Model do
|
|
|
11
11
|
m.field "baz", :string
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
15
|
+
has_attributes :foo, :bar, :baz, datastream: 'properties', multiple: true
|
|
16
|
+
end
|
|
15
17
|
|
|
16
18
|
def to_solr(doc = {})
|
|
17
19
|
doc = super
|
|
@@ -11,7 +11,9 @@ describe "scoped queries" do
|
|
|
11
11
|
m.field "baz", :string
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
15
|
+
has_attributes :foo, :bar, :baz, datastream: 'properties', multiple: true
|
|
16
|
+
end
|
|
15
17
|
|
|
16
18
|
def to_solr(doc = {})
|
|
17
19
|
doc = super
|
|
@@ -7,8 +7,10 @@ describe ActiveFedora::SolrInstanceLoader do
|
|
|
7
7
|
m.field "foo", :text
|
|
8
8
|
m.field "bar", :text
|
|
9
9
|
end
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
11
|
+
has_attributes :foo, datastream: 'descMetadata', multiple: true
|
|
12
|
+
has_attributes :bar, datastream: 'descMetadata', multiple: false
|
|
13
|
+
end
|
|
12
14
|
property :title, predicate: ::RDF::DC.title, multiple: false
|
|
13
15
|
property :description, predicate: ::RDF::DC.description
|
|
14
16
|
belongs_to :another, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'Foo'
|