active-fedora 9.10.0 → 9.11.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/.rubocop.yml +3 -0
- data/History.txt +3 -0
- data/active-fedora.gemspec +3 -2
- data/lib/active_fedora/aggregation/base_extension.rb +17 -0
- data/lib/active_fedora/aggregation/list_source.rb +103 -0
- data/lib/active_fedora/aggregation/ordered_reader.rb +27 -0
- data/lib/active_fedora/aggregation/proxy.rb +18 -0
- data/lib/active_fedora/aggregation.rb +11 -0
- data/lib/active_fedora/associations/builder/aggregation.rb +51 -0
- data/lib/active_fedora/associations/builder/filter.rb +18 -0
- data/lib/active_fedora/associations/builder/orders.rb +63 -0
- data/lib/active_fedora/associations/filter_association.rb +71 -0
- data/lib/active_fedora/associations/orders_association.rb +149 -0
- data/lib/active_fedora/associations.rb +40 -0
- data/lib/active_fedora/attached_files.rb +2 -1
- data/lib/active_fedora/attribute_methods.rb +4 -4
- data/lib/active_fedora/autosave_association.rb +14 -0
- data/lib/active_fedora/base.rb +1 -0
- data/lib/active_fedora/cleaner.rb +1 -1
- data/lib/active_fedora/errors.rb +3 -0
- data/lib/active_fedora/fedora.rb +17 -7
- data/lib/active_fedora/file/attributes.rb +6 -6
- data/lib/active_fedora/file/streaming.rb +13 -4
- data/lib/active_fedora/file.rb +1 -16
- data/lib/active_fedora/orders/collection_proxy.rb +8 -0
- data/lib/active_fedora/orders/list_node.rb +161 -0
- data/lib/active_fedora/orders/ordered_list.rb +264 -0
- data/lib/active_fedora/orders/target_proxy.rb +60 -0
- data/lib/active_fedora/orders.rb +12 -0
- data/lib/active_fedora/reflection.rb +216 -43
- data/lib/active_fedora/relation/finder_methods.rb +2 -2
- data/lib/active_fedora/validations.rb +1 -1
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/with_metadata/metadata_node.rb +1 -2
- data/lib/active_fedora.rb +7 -0
- data/lib/generators/active_fedora/config/solr/templates/solr/config/schema.xml +1 -1
- data/solr/config/schema.xml +1 -1
- data/spec/integration/attached_files_spec.rb +4 -4
- data/spec/integration/attributes_spec.rb +8 -0
- data/spec/integration/file_spec.rb +23 -1
- data/spec/integration/has_many_associations_spec.rb +23 -0
- data/spec/integration/om_datastream_spec.rb +6 -6
- data/spec/integration/versionable_spec.rb +6 -6
- data/spec/unit/active_fedora_spec.rb +1 -1
- data/spec/unit/aggregation/list_source_spec.rb +134 -0
- data/spec/unit/aggregation/ordered_reader_spec.rb +43 -0
- data/spec/unit/fedora_spec.rb +1 -1
- data/spec/unit/file_spec.rb +0 -19
- data/spec/unit/filter_spec.rb +133 -0
- data/spec/unit/ordered_spec.rb +369 -0
- data/spec/unit/orders/list_node_spec.rb +151 -0
- data/spec/unit/orders/ordered_list_spec.rb +335 -0
- data/spec/unit/orders/reflection_spec.rb +22 -0
- data/spec/unit/reflection_spec.rb +2 -4
- metadata +29 -7
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module ActiveFedora
|
|
2
|
+
module Orders
|
|
3
|
+
class TargetProxy
|
|
4
|
+
attr_reader :association
|
|
5
|
+
delegate :+, to: :to_a
|
|
6
|
+
def initialize(association)
|
|
7
|
+
@association = association
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def <<(obj)
|
|
11
|
+
association.append_target(obj)
|
|
12
|
+
self
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def concat(objs)
|
|
16
|
+
objs.each do |obj|
|
|
17
|
+
self.<<(obj)
|
|
18
|
+
end
|
|
19
|
+
self
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def insert_at(loc, record)
|
|
23
|
+
association.insert_target_at(loc, record)
|
|
24
|
+
self
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Deletes the element at the specified index, returning that element, or nil if
|
|
28
|
+
# the index is out of range.
|
|
29
|
+
def delete_at(loc)
|
|
30
|
+
result = association.delete_at(loc)
|
|
31
|
+
result.target if result
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Deletes all items from self that are equal to obj.
|
|
35
|
+
# @param obj the object to remove from the list
|
|
36
|
+
# @return the last deleted item, or nil if no matching item is found
|
|
37
|
+
def delete(obj)
|
|
38
|
+
association.delete_target(obj)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def clear
|
|
42
|
+
association.delete_at(0) while to_ary.present?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def to_ary
|
|
46
|
+
association.reader.map(&:target).dup
|
|
47
|
+
end
|
|
48
|
+
alias to_a to_ary
|
|
49
|
+
|
|
50
|
+
def ==(other)
|
|
51
|
+
case other
|
|
52
|
+
when TargetProxy
|
|
53
|
+
super
|
|
54
|
+
when Array
|
|
55
|
+
to_a == other
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -14,12 +14,32 @@ module ActiveFedora
|
|
|
14
14
|
class << self
|
|
15
15
|
def create(macro, name, scope, options, active_fedora)
|
|
16
16
|
klass = case macro
|
|
17
|
-
when :has_many
|
|
18
|
-
|
|
19
|
-
when :
|
|
17
|
+
when :has_many
|
|
18
|
+
HasManyReflection
|
|
19
|
+
when :belongs_to
|
|
20
|
+
BelongsToReflection
|
|
21
|
+
when :has_and_belongs_to_many
|
|
22
|
+
HasAndBelongsToManyReflection
|
|
23
|
+
when :contains
|
|
24
|
+
ContainsReflection
|
|
25
|
+
when :directly_contains
|
|
26
|
+
DirectlyContainsReflection
|
|
27
|
+
when :directly_contains_one
|
|
28
|
+
DirectlyContainsOneReflection
|
|
29
|
+
when :indirectly_contains
|
|
30
|
+
IndirectlyContainsReflection
|
|
31
|
+
when :rdf
|
|
20
32
|
RDFPropertyReflection
|
|
33
|
+
when :singular_rdf
|
|
34
|
+
SingularRDFPropertyReflection
|
|
35
|
+
when :filter
|
|
36
|
+
FilterReflection
|
|
37
|
+
when :aggregation, :orders
|
|
38
|
+
OrdersReflection
|
|
39
|
+
else
|
|
40
|
+
raise "Unsupported Macro: #{macro}"
|
|
21
41
|
end
|
|
22
|
-
reflection = klass.new(
|
|
42
|
+
reflection = klass.new(name, scope, options, active_fedora)
|
|
23
43
|
add_reflection(active_fedora, name, reflection)
|
|
24
44
|
reflection
|
|
25
45
|
end
|
|
@@ -79,7 +99,7 @@ module ActiveFedora
|
|
|
79
99
|
# Invoice.reflect_on_association(:line_items).macro # returns :has_many
|
|
80
100
|
#
|
|
81
101
|
def reflect_on_association(association)
|
|
82
|
-
|
|
102
|
+
_reflect_on_association(association)
|
|
83
103
|
end
|
|
84
104
|
|
|
85
105
|
def outgoing_reflections
|
|
@@ -185,11 +205,6 @@ module ActiveFedora
|
|
|
185
205
|
|
|
186
206
|
attr_reader :scope
|
|
187
207
|
|
|
188
|
-
# Returns the macro type.
|
|
189
|
-
#
|
|
190
|
-
# <tt>has_many :clients</tt> returns <tt>:has_many</tt>
|
|
191
|
-
attr_reader :macro
|
|
192
|
-
|
|
193
208
|
# Returns the hash of options used for the macro.
|
|
194
209
|
#
|
|
195
210
|
# <tt>has_many :clients</tt> returns +{}+
|
|
@@ -197,8 +212,7 @@ module ActiveFedora
|
|
|
197
212
|
|
|
198
213
|
attr_reader :active_fedora
|
|
199
214
|
|
|
200
|
-
def initialize(
|
|
201
|
-
@macro = macro
|
|
215
|
+
def initialize(name, scope, options, active_fedora)
|
|
202
216
|
@name = name
|
|
203
217
|
@scope = scope
|
|
204
218
|
@options = options
|
|
@@ -249,7 +263,7 @@ module ActiveFedora
|
|
|
249
263
|
class AssociationReflection < MacroReflection #:nodoc:
|
|
250
264
|
attr_accessor :parent_reflection # Reflection
|
|
251
265
|
|
|
252
|
-
def initialize(
|
|
266
|
+
def initialize(name, scope, options, active_fedora)
|
|
253
267
|
super
|
|
254
268
|
@constructable = calculate_constructable(macro, options)
|
|
255
269
|
end
|
|
@@ -300,13 +314,6 @@ module ActiveFedora
|
|
|
300
314
|
end
|
|
301
315
|
alias chain collect_join_chain # todo
|
|
302
316
|
|
|
303
|
-
# Returns whether or not this association reflection is for a collection
|
|
304
|
-
# association. Returns +true+ if the +macro+ is either +has_many+ or
|
|
305
|
-
# +has_and_belongs_to_many+, +false+ otherwise.
|
|
306
|
-
def collection?
|
|
307
|
-
[:has_many, :has_and_belongs_to_many, :directly_contains, :indirectly_contains].include?(macro)
|
|
308
|
-
end
|
|
309
|
-
|
|
310
317
|
def has_inverse?
|
|
311
318
|
inverse_name
|
|
312
319
|
end
|
|
@@ -317,6 +324,20 @@ module ActiveFedora
|
|
|
317
324
|
@inverse_of ||= klass._reflect_on_association inverse_name
|
|
318
325
|
end
|
|
319
326
|
|
|
327
|
+
# Returns the macro type.
|
|
328
|
+
#
|
|
329
|
+
# <tt>has_many :clients</tt> returns <tt>:has_many</tt>
|
|
330
|
+
def macro
|
|
331
|
+
raise NotImplementedError
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# Returns whether or not this association reflection is for a collection
|
|
335
|
+
# association. Returns +true+ if the +macro+ is either +has_many+ or
|
|
336
|
+
# +has_and_belongs_to_many+, +false+ otherwise.
|
|
337
|
+
def collection?
|
|
338
|
+
false
|
|
339
|
+
end
|
|
340
|
+
|
|
320
341
|
# Returns whether or not the association should be validated as part of
|
|
321
342
|
# the parent's validation.
|
|
322
343
|
#
|
|
@@ -331,26 +352,7 @@ module ActiveFedora
|
|
|
331
352
|
end
|
|
332
353
|
|
|
333
354
|
def association_class
|
|
334
|
-
|
|
335
|
-
when :contains
|
|
336
|
-
Associations::BasicContainsAssociation
|
|
337
|
-
when :belongs_to
|
|
338
|
-
Associations::BelongsToAssociation
|
|
339
|
-
when :has_and_belongs_to_many
|
|
340
|
-
Associations::HasAndBelongsToManyAssociation
|
|
341
|
-
when :has_many
|
|
342
|
-
Associations::HasManyAssociation
|
|
343
|
-
when :singular_rdf
|
|
344
|
-
Associations::SingularRDF
|
|
345
|
-
when :rdf
|
|
346
|
-
Associations::RDF
|
|
347
|
-
when :directly_contains
|
|
348
|
-
Associations::DirectlyContainsAssociation
|
|
349
|
-
when :directly_contains_one
|
|
350
|
-
Associations::DirectlyContainsOneAssociation
|
|
351
|
-
when :indirectly_contains
|
|
352
|
-
Associations::IndirectlyContainsAssociation
|
|
353
|
-
end
|
|
355
|
+
raise NotImplementedError
|
|
354
356
|
end
|
|
355
357
|
|
|
356
358
|
VALID_AUTOMATIC_INVERSE_MACROS = [:has_many, :has_and_belongs_to_many, :belongs_to].freeze
|
|
@@ -358,15 +360,15 @@ module ActiveFedora
|
|
|
358
360
|
|
|
359
361
|
# Returns +true+ if +self+ is a +belongs_to+ reflection.
|
|
360
362
|
def belongs_to?
|
|
361
|
-
|
|
363
|
+
false
|
|
362
364
|
end
|
|
363
365
|
|
|
364
366
|
def has_many?
|
|
365
|
-
|
|
367
|
+
false
|
|
366
368
|
end
|
|
367
369
|
|
|
368
370
|
def has_and_belongs_to_many?
|
|
369
|
-
|
|
371
|
+
false
|
|
370
372
|
end
|
|
371
373
|
|
|
372
374
|
private
|
|
@@ -451,12 +453,122 @@ module ActiveFedora
|
|
|
451
453
|
end
|
|
452
454
|
end
|
|
453
455
|
|
|
456
|
+
class HasManyReflection < AssociationReflection # :nodoc:
|
|
457
|
+
def macro
|
|
458
|
+
:has_many
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
def collection?
|
|
462
|
+
true
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
def has_many?
|
|
466
|
+
true
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
def association_class
|
|
470
|
+
Associations::HasManyAssociation
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
class BelongsToReflection < AssociationReflection # :nodoc:
|
|
475
|
+
def macro
|
|
476
|
+
:belongs_to
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
def belongs_to?
|
|
480
|
+
true
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
def association_class
|
|
484
|
+
Associations::BelongsToAssociation
|
|
485
|
+
end
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
class HasAndBelongsToManyReflection < AssociationReflection # :nodoc:
|
|
489
|
+
def macro
|
|
490
|
+
:has_and_belongs_to_many
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
def collection?
|
|
494
|
+
true
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
def has_and_belongs_to_many?
|
|
498
|
+
true
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
def association_class
|
|
502
|
+
Associations::HasAndBelongsToManyAssociation
|
|
503
|
+
end
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
class ContainsReflection < AssociationReflection # :nodoc:
|
|
507
|
+
def macro
|
|
508
|
+
:contains
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
def association_class
|
|
512
|
+
Associations::BasicContainsAssociation
|
|
513
|
+
end
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
class DirectlyContainsReflection < AssociationReflection # :nodoc:
|
|
517
|
+
def macro
|
|
518
|
+
:directly_contains
|
|
519
|
+
end
|
|
520
|
+
|
|
521
|
+
def collection?
|
|
522
|
+
true
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
def association_class
|
|
526
|
+
Associations::DirectlyContainsAssociation
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
class DirectlyContainsOneReflection < AssociationReflection # :nodoc:
|
|
531
|
+
def macro
|
|
532
|
+
:directly_contains_one
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
def association_class
|
|
536
|
+
Associations::DirectlyContainsOneAssociation
|
|
537
|
+
end
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
class IndirectlyContainsReflection < AssociationReflection # :nodoc:
|
|
541
|
+
def macro
|
|
542
|
+
:indirectly_contains
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
def collection?
|
|
546
|
+
true
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
def association_class
|
|
550
|
+
Associations::IndirectlyContainsAssociation
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
|
|
454
554
|
class RDFPropertyReflection < AssociationReflection
|
|
455
555
|
def initialize(*args)
|
|
456
556
|
super
|
|
457
557
|
active_fedora.index_config[name] = build_index_config
|
|
458
558
|
end
|
|
459
559
|
|
|
560
|
+
def macro
|
|
561
|
+
:rdf
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
def association_class
|
|
565
|
+
Associations::RDF
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
def collection?
|
|
569
|
+
true
|
|
570
|
+
end
|
|
571
|
+
|
|
460
572
|
def derive_foreign_key
|
|
461
573
|
name
|
|
462
574
|
end
|
|
@@ -473,5 +585,66 @@ module ActiveFedora
|
|
|
473
585
|
ActiveFedora::Indexing::Map::IndexObject.new(predicate_for_solr) { |index| index.as :symbol }
|
|
474
586
|
end
|
|
475
587
|
end
|
|
588
|
+
|
|
589
|
+
class SingularRDFPropertyReflection < RDFPropertyReflection
|
|
590
|
+
def macro
|
|
591
|
+
:singular_rdf
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
def collection?
|
|
595
|
+
false
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
def association_class
|
|
599
|
+
Associations::SingularRDF
|
|
600
|
+
end
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
class FilterReflection < AssociationReflection
|
|
604
|
+
def macro
|
|
605
|
+
:filter
|
|
606
|
+
end
|
|
607
|
+
|
|
608
|
+
def association_class
|
|
609
|
+
Associations::FilterAssociation
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
# delegates to extending_from
|
|
613
|
+
delegate :klass, to: :extending_from
|
|
614
|
+
|
|
615
|
+
def extending_from
|
|
616
|
+
@extending_from ||= active_fedora._reflect_on_association(options.fetch(:extending_from))
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
def collection?
|
|
620
|
+
true
|
|
621
|
+
end
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
class OrdersReflection < AssociationReflection
|
|
625
|
+
def macro
|
|
626
|
+
:orders
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
def association_class
|
|
630
|
+
Associations::OrdersAssociation
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
def collection?
|
|
634
|
+
true
|
|
635
|
+
end
|
|
636
|
+
|
|
637
|
+
def class_name
|
|
638
|
+
klass.to_s
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
def unordered_reflection
|
|
642
|
+
options[:unordered_reflection]
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
def klass
|
|
646
|
+
ActiveFedora::Orders::ListNode
|
|
647
|
+
end
|
|
648
|
+
end
|
|
476
649
|
end
|
|
477
650
|
end
|
|
@@ -183,9 +183,9 @@ module ActiveFedora
|
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
# @deprecated
|
|
186
|
-
def find_in_batches(*args)
|
|
186
|
+
def find_in_batches(*args, &block)
|
|
187
187
|
Deprecation.warn(ActiveFedora::Base, '.find_in_batches is deprecated and will be removed in active-fedora 10.0; use .search_in_batches instead')
|
|
188
|
-
search_in_batches(*args)
|
|
188
|
+
search_in_batches(*args, &block)
|
|
189
189
|
end
|
|
190
190
|
|
|
191
191
|
# Retrieve the Fedora object with the given id, explore the returned object
|
|
@@ -2,7 +2,6 @@ module ActiveFedora
|
|
|
2
2
|
module WithMetadata
|
|
3
3
|
class MetadataNode < ActiveTriples::Resource
|
|
4
4
|
include ActiveModel::Dirty
|
|
5
|
-
property :mime_type, predicate: ::RDF::URI("http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasMimeType")
|
|
6
5
|
attr_reader :file
|
|
7
6
|
|
|
8
7
|
def initialize(file)
|
|
@@ -46,7 +45,7 @@ module ActiveFedora
|
|
|
46
45
|
|
|
47
46
|
def changed_attributes
|
|
48
47
|
super.tap do |changed|
|
|
49
|
-
changed['type'] = true if type.present?
|
|
48
|
+
changed['type'] = true if type.present?
|
|
50
49
|
end
|
|
51
50
|
end
|
|
52
51
|
|
data/lib/active_fedora.rb
CHANGED
|
@@ -36,6 +36,7 @@ module ActiveFedora #:nodoc:
|
|
|
36
36
|
extend ActiveSupport::Autoload
|
|
37
37
|
|
|
38
38
|
eager_autoload do
|
|
39
|
+
autoload :Aggregation
|
|
39
40
|
autoload :AssociationHash
|
|
40
41
|
autoload :AssociationRelation
|
|
41
42
|
autoload :Associations
|
|
@@ -76,6 +77,7 @@ module ActiveFedora #:nodoc:
|
|
|
76
77
|
autoload :FilePersistence
|
|
77
78
|
autoload :FileRelation
|
|
78
79
|
autoload :FilesHash
|
|
80
|
+
autoload :Filter
|
|
79
81
|
autoload :FixityService
|
|
80
82
|
autoload :Identifiable
|
|
81
83
|
autoload :Indexers
|
|
@@ -94,6 +96,7 @@ module ActiveFedora #:nodoc:
|
|
|
94
96
|
autoload :NomDatastream
|
|
95
97
|
autoload :NullRelation
|
|
96
98
|
autoload :OmDatastream
|
|
99
|
+
autoload :Orders
|
|
97
100
|
autoload :Pathing
|
|
98
101
|
autoload :Persistence
|
|
99
102
|
autoload :ProfileIndexingService
|
|
@@ -227,6 +230,10 @@ module ActiveFedora #:nodoc:
|
|
|
227
230
|
ActiveFedora::SolrService.instance
|
|
228
231
|
end
|
|
229
232
|
|
|
233
|
+
def reset_fedora!
|
|
234
|
+
@fedora = nil
|
|
235
|
+
end
|
|
236
|
+
|
|
230
237
|
def fedora
|
|
231
238
|
@fedora ||= Fedora.new(fedora_config.credentials)
|
|
232
239
|
end
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
|
|
104
104
|
-->
|
|
105
105
|
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
|
|
106
|
-
geo="true" distErrPct="0.025" maxDistErr="0.000009"
|
|
106
|
+
geo="true" distErrPct="0.025" maxDistErr="0.000009" distanceUnits="degrees" />
|
|
107
107
|
|
|
108
108
|
<fieldType name="text" class="solr.TextField" omitNorms="false">
|
|
109
109
|
<analyzer>
|
data/solr/config/schema.xml
CHANGED
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
|
|
104
104
|
-->
|
|
105
105
|
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
|
|
106
|
-
geo="true" distErrPct="0.025" maxDistErr="0.000009"
|
|
106
|
+
geo="true" distErrPct="0.025" maxDistErr="0.000009" distanceUnits="degrees" />
|
|
107
107
|
|
|
108
108
|
<fieldType name="text" class="solr.TextField" omitNorms="false">
|
|
109
109
|
<analyzer>
|
|
@@ -63,13 +63,13 @@ describe ActiveFedora::AttachedFiles do
|
|
|
63
63
|
|
|
64
64
|
it "creates datastreams from the spec on new objects" do
|
|
65
65
|
has_file.file_ds.content = "blah blah blah"
|
|
66
|
-
expect(has_file.file_ds).to
|
|
67
|
-
expect(has_file.file_ds2).to_not
|
|
66
|
+
expect(has_file.file_ds).to be_changed
|
|
67
|
+
expect(has_file.file_ds2).to_not be_changed # no autocreate
|
|
68
68
|
expect(has_file.file_ds2).to be_new_record
|
|
69
69
|
has_file.save
|
|
70
70
|
has_file.reload
|
|
71
|
-
expect(has_file.file_ds).to_not
|
|
72
|
-
expect(has_file.file_ds2).to_not
|
|
71
|
+
expect(has_file.file_ds).to_not be_changed
|
|
72
|
+
expect(has_file.file_ds2).to_not be_changed # no autocreate
|
|
73
73
|
expect(has_file.file_ds2).to be_new_record
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -147,4 +147,12 @@ describe "delegating attributes" do
|
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
|
+
|
|
151
|
+
describe 'dangerous attributes' do
|
|
152
|
+
it 'raises an exception if a dangerous attribute is defined' do
|
|
153
|
+
Deprecation.silence(ActiveFedora::Attributes) do
|
|
154
|
+
expect { TitledObject.has_attributes :save, datastream: 'foo', multiple: false }.to raise_error ActiveFedora::DangerousAttributeError
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
150
158
|
end
|
|
@@ -109,7 +109,7 @@ describe ActiveFedora::File do
|
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "is not changed" do
|
|
112
|
-
expect(test_object.attached_files[path]).to_not
|
|
112
|
+
expect(test_object.attached_files[path]).to_not be_changed
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
it "is able to read the content from fedora" do
|
|
@@ -149,6 +149,28 @@ describe ActiveFedora::File do
|
|
|
149
149
|
it { should eq 'two2thre' }
|
|
150
150
|
end
|
|
151
151
|
end
|
|
152
|
+
|
|
153
|
+
context "when the request results in a redirect" do
|
|
154
|
+
before do
|
|
155
|
+
test_object.add_file('one1two2threfour', path: 'webm', mime_type: 'video/webm')
|
|
156
|
+
test_object.add_file('', path: 'redirector', mime_type: "message/external-body; access-type=URL; url=\"#{test_object.webm.uri}\"")
|
|
157
|
+
test_object.save!
|
|
158
|
+
end
|
|
159
|
+
subject { str = ''; test_object.redirector.stream.each { |chunk| str << chunk }; str }
|
|
160
|
+
it { should eq 'one1two2threfour' }
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
context "when there are more than 3 requests because of redirects" do
|
|
164
|
+
before do
|
|
165
|
+
test_object.add_file('', path: 'one', mime_type: "message/external-body; access-type=URL; url=\"#{test_object.attached_files[path].uri}\"")
|
|
166
|
+
test_object.add_file('', path: 'two', mime_type: "message/external-body; access-type=URL; url=\"#{test_object.one.uri}\"")
|
|
167
|
+
test_object.add_file('', path: 'three', mime_type: "message/external-body; access-type=URL; url=\"#{test_object.two.uri}\"")
|
|
168
|
+
test_object.save!
|
|
169
|
+
end
|
|
170
|
+
it "raises a HTTP redirect too deep Error" do
|
|
171
|
+
expect { test_object.three.stream.each { |chunk| chunk } }.to raise_error('HTTP redirect too deep')
|
|
172
|
+
end
|
|
173
|
+
end
|
|
152
174
|
end
|
|
153
175
|
end
|
|
154
176
|
end
|
|
@@ -423,4 +423,27 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
423
423
|
end
|
|
424
424
|
end
|
|
425
425
|
end
|
|
426
|
+
|
|
427
|
+
describe "when destroying the owner" do
|
|
428
|
+
before do
|
|
429
|
+
class Book < ActiveFedora::Base
|
|
430
|
+
has_many :permissions, dependent: :destroy
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
class Permission < ActiveFedora::Base
|
|
434
|
+
belongs_to :book, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
|
|
435
|
+
end
|
|
436
|
+
end
|
|
437
|
+
let(:book) { Book.create! }
|
|
438
|
+
let!(:permissions) { Permission.create!(book: book) }
|
|
439
|
+
|
|
440
|
+
after do
|
|
441
|
+
Object.send(:remove_const, :Book)
|
|
442
|
+
Object.send(:remove_const, :Permission)
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
it "the object is destroyed" do
|
|
446
|
+
expect { book.destroy }.to change { Permission.count }.by(-1)
|
|
447
|
+
end
|
|
448
|
+
end
|
|
426
449
|
end
|
|
@@ -30,15 +30,15 @@ describe ActiveFedora::OmDatastream do
|
|
|
30
30
|
end
|
|
31
31
|
it "does not be changed if the new xml matches the old xml" do
|
|
32
32
|
subject.content = subject.content
|
|
33
|
-
expect(subject).to_not
|
|
33
|
+
expect(subject).to_not be_changed
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "is changed if there are minor differences in whitespace" do
|
|
37
37
|
subject.content = "<a><b>1</b></a>"
|
|
38
38
|
obj.save
|
|
39
|
-
expect(subject).to_not
|
|
39
|
+
expect(subject).to_not be_changed
|
|
40
40
|
subject.content = "<a>\n<b>1</b>\n</a>"
|
|
41
|
-
expect(subject).to
|
|
41
|
+
expect(subject).to be_changed
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -56,11 +56,11 @@ describe ActiveFedora::OmDatastream do
|
|
|
56
56
|
obj.reload
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
it "
|
|
59
|
+
it "does not be dirty after .update_values is saved" do
|
|
60
60
|
obj.descMetadata.update_values([{ name: 0 }, { role: 0 }, :text] => "Funder")
|
|
61
|
-
expect(obj.descMetadata).to
|
|
61
|
+
expect(obj.descMetadata).to be_changed
|
|
62
62
|
obj.save
|
|
63
|
-
expect(obj.descMetadata).to_not
|
|
63
|
+
expect(obj.descMetadata).to_not be_changed
|
|
64
64
|
expect(obj.descMetadata.term_values({ name: 0 }, { role: 0 }, :text)).to eq ["Funder"]
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -179,8 +179,8 @@ describe ActiveFedora::Versionable do
|
|
|
179
179
|
@original_size = subject.size
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
-
it "
|
|
183
|
-
expect(subject.
|
|
182
|
+
it "links to versions endpoint" do
|
|
183
|
+
expect(subject.metadata.ldp_source.graph.query(predicate: ::RDF::Vocab::Fcrepo4.hasVersions).objects).to_not be_empty
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
it "has one version" do
|
|
@@ -305,8 +305,8 @@ describe ActiveFedora::Versionable do
|
|
|
305
305
|
@original_size = subject.size
|
|
306
306
|
end
|
|
307
307
|
|
|
308
|
-
it "
|
|
309
|
-
expect(subject.
|
|
308
|
+
it "links to versions endpoint" do
|
|
309
|
+
expect(subject.metadata.ldp_source.graph.query(predicate: ::RDF::Vocab::Fcrepo4.hasVersions).objects).to_not be_empty
|
|
310
310
|
end
|
|
311
311
|
|
|
312
312
|
it "has one version" do
|
|
@@ -427,8 +427,8 @@ describe ActiveFedora::Versionable do
|
|
|
427
427
|
subject.create_version
|
|
428
428
|
end
|
|
429
429
|
|
|
430
|
-
it "
|
|
431
|
-
expect(subject.
|
|
430
|
+
it "links to versions endpoint" do
|
|
431
|
+
expect(subject.metadata.ldp_source.graph.query(predicate: ::RDF::Vocab::Fcrepo4.hasVersions).objects).to_not be_empty
|
|
432
432
|
end
|
|
433
433
|
|
|
434
434
|
it "has one version" do
|