active-fedora 10.3.0 → 11.0.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.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +6 -7
  4. data/.rubocop_todo.yml +55 -0
  5. data/active-fedora.gemspec +6 -10
  6. data/lib/active_fedora/aggregation/list_source.rb +2 -0
  7. data/lib/active_fedora/associations/association_scope.rb +1 -1
  8. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  9. data/lib/active_fedora/associations/builder/association.rb +1 -1
  10. data/lib/active_fedora/associations/builder/orders.rb +11 -3
  11. data/lib/active_fedora/associations/collection_association.rb +3 -3
  12. data/lib/active_fedora/associations/contained_finder.rb +2 -2
  13. data/lib/active_fedora/associations/has_many_association.rb +1 -1
  14. data/lib/active_fedora/associations/orders_association.rb +4 -0
  15. data/lib/active_fedora/associations/rdf.rb +2 -0
  16. data/lib/active_fedora/attribute_assignment.rb +0 -1
  17. data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
  18. data/lib/active_fedora/attributes.rb +1 -1
  19. data/lib/active_fedora/base.rb +4 -8
  20. data/lib/active_fedora/change_set.rb +6 -2
  21. data/lib/active_fedora/core.rb +22 -27
  22. data/lib/active_fedora/fedora.rb +2 -6
  23. data/lib/active_fedora/fedora_attributes.rb +1 -1
  24. data/lib/active_fedora/file/streaming.rb +1 -1
  25. data/lib/active_fedora/indexing.rb +1 -18
  26. data/lib/active_fedora/indexing_service.rb +0 -9
  27. data/lib/active_fedora/loadable_from_json.rb +12 -1
  28. data/lib/active_fedora/nested_attributes.rb +2 -2
  29. data/lib/active_fedora/orders/list_node.rb +2 -2
  30. data/lib/active_fedora/orders/ordered_list.rb +7 -3
  31. data/lib/active_fedora/orders/target_proxy.rb +4 -0
  32. data/lib/active_fedora/querying.rb +1 -1
  33. data/lib/active_fedora/railtie.rb +2 -2
  34. data/lib/active_fedora/rdf/persistence.rb +1 -0
  35. data/lib/active_fedora/rdf.rb +0 -1
  36. data/lib/active_fedora/relation/delegation.rb +4 -0
  37. data/lib/active_fedora/solr_hit.rb +0 -13
  38. data/lib/active_fedora/solr_query_builder.rb +17 -13
  39. data/lib/active_fedora/version.rb +1 -1
  40. data/lib/active_fedora.rb +0 -12
  41. data/lib/generators/active_fedora/model/model_generator.rb +1 -1
  42. data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
  43. data/lib/tasks/active_fedora_dev.rake +1 -1
  44. data/spec/config_helper.rb +1 -1
  45. data/spec/integration/associations_spec.rb +23 -24
  46. data/spec/integration/attached_files_spec.rb +18 -8
  47. data/spec/integration/attributes_spec.rb +12 -16
  48. data/spec/integration/autosave_association_spec.rb +6 -6
  49. data/spec/integration/base_spec.rb +3 -3
  50. data/spec/integration/basic_contains_association_spec.rb +1 -1
  51. data/spec/integration/clean_connection_spec.rb +1 -1
  52. data/spec/integration/collection_association_spec.rb +2 -5
  53. data/spec/integration/date_time_properties_spec.rb +1 -17
  54. data/spec/integration/direct_container_spec.rb +12 -12
  55. data/spec/integration/directly_contains_one_association_spec.rb +11 -13
  56. data/spec/integration/fedora_solr_sync_spec.rb +2 -2
  57. data/spec/integration/file_fixity_spec.rb +6 -8
  58. data/spec/integration/file_spec.rb +32 -34
  59. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
  60. data/spec/integration/has_many_associations_spec.rb +9 -11
  61. data/spec/integration/indexing_spec.rb +2 -2
  62. data/spec/integration/indirect_container_spec.rb +11 -12
  63. data/spec/integration/json_serialization_spec.rb +4 -4
  64. data/spec/integration/query_result_builder_spec.rb +9 -21
  65. data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
  66. data/spec/integration/relation_delegation_spec.rb +8 -10
  67. data/spec/integration/relation_spec.rb +13 -16
  68. data/spec/integration/scoped_query_spec.rb +3 -3
  69. data/spec/integration/solr_hit_spec.rb +4 -15
  70. data/spec/integration/versionable_spec.rb +73 -327
  71. data/spec/integration/with_metadata_spec.rb +1 -1
  72. data/spec/spec_helper.rb +52 -10
  73. data/spec/unit/active_fedora_spec.rb +1 -1
  74. data/spec/unit/aggregation/list_source_spec.rb +37 -37
  75. data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
  76. data/spec/unit/association_hash_spec.rb +17 -31
  77. data/spec/unit/attached_files_spec.rb +35 -32
  78. data/spec/unit/attributes_spec.rb +25 -25
  79. data/spec/unit/base_active_model_spec.rb +8 -8
  80. data/spec/unit/base_cma_spec.rb +1 -1
  81. data/spec/unit/base_extra_spec.rb +7 -22
  82. data/spec/unit/base_spec.rb +17 -24
  83. data/spec/unit/callback_spec.rb +2 -2
  84. data/spec/unit/change_set_spec.rb +5 -5
  85. data/spec/unit/checksum_spec.rb +2 -2
  86. data/spec/unit/code_configurator_spec.rb +1 -1
  87. data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
  88. data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
  89. data/spec/unit/core_spec.rb +65 -29
  90. data/spec/unit/default_model_mapper_spec.rb +6 -6
  91. data/spec/unit/fedora_spec.rb +3 -4
  92. data/spec/unit/file_configurator_spec.rb +96 -96
  93. data/spec/unit/file_path_builder_spec.rb +1 -1
  94. data/spec/unit/file_spec.rb +61 -61
  95. data/spec/unit/files_hash_spec.rb +9 -9
  96. data/spec/unit/filter_spec.rb +3 -3
  97. data/spec/unit/finder_methods_spec.rb +3 -3
  98. data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
  99. data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
  100. data/spec/unit/has_many_association_spec.rb +5 -5
  101. data/spec/unit/indexers/global_indexer_spec.rb +6 -6
  102. data/spec/unit/indexing_service_spec.rb +5 -5
  103. data/spec/unit/indexing_spec.rb +6 -6
  104. data/spec/unit/inheritance_spec.rb +11 -7
  105. data/spec/unit/loadable_from_json_spec.rb +4 -4
  106. data/spec/unit/logger_spec.rb +1 -1
  107. data/spec/unit/model_classifier_spec.rb +5 -5
  108. data/spec/unit/ordered_spec.rb +144 -147
  109. data/spec/unit/orders/list_node_spec.rb +21 -21
  110. data/spec/unit/orders/ordered_list_spec.rb +96 -96
  111. data/spec/unit/orders/reflection_spec.rb +4 -4
  112. data/spec/unit/pathing_spec.rb +4 -4
  113. data/spec/unit/persistence_spec.rb +28 -28
  114. data/spec/unit/property_spec.rb +2 -2
  115. data/spec/unit/query_spec.rb +6 -6
  116. data/spec/unit/rdf/indexing_service_spec.rb +29 -29
  117. data/spec/unit/readonly_spec.rb +5 -4
  118. data/spec/unit/reflection_spec.rb +3 -3
  119. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
  120. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
  121. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
  122. data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
  123. data/spec/unit/serializers_spec.rb +3 -4
  124. data/spec/unit/solr_config_options_spec.rb +13 -16
  125. data/spec/unit/solr_hit_spec.rb +9 -9
  126. data/spec/unit/solr_service_spec.rb +4 -10
  127. data/spec/unit/sparql_insert_spec.rb +2 -2
  128. data/spec/unit/validations_spec.rb +9 -9
  129. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
  130. data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
  131. metadata +18 -92
  132. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
  133. data/lib/active_fedora/datastreams.rb +0 -6
  134. data/lib/active_fedora/nom_datastream.rb +0 -73
  135. data/lib/active_fedora/om_datastream.rb +0 -118
  136. data/lib/active_fedora/profile_indexing_service.rb +0 -11
  137. data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
  138. data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
  139. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
  140. data/lib/active_fedora/rdf/rdf_datastream.rb +0 -167
  141. data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
  142. data/lib/active_fedora/solr_instance_loader.rb +0 -47
  143. data/spec/fixtures/damsObjectModel.xml +0 -38
  144. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
  145. data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
  146. data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
  147. data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
  148. data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
  149. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
  150. data/spec/integration/ntriples_datastream_spec.rb +0 -203
  151. data/spec/integration/om_datastream_spec.rb +0 -78
  152. data/spec/integration/solr_instance_loader_spec.rb +0 -156
  153. data/spec/samples/hydra-mods_article_datastream.rb +0 -517
  154. data/spec/samples/models/mods_article.rb +0 -9
  155. data/spec/samples/oral_history_sample.xml +0 -38
  156. data/spec/samples/oral_history_xml.xml +0 -35
  157. data/spec/samples/samples.rb +0 -2
  158. data/spec/unit/nom_datastream_spec.rb +0 -60
  159. data/spec/unit/ntriples_datastream_spec.rb +0 -170
  160. data/spec/unit/om_datastream_spec.rb +0 -294
  161. data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
  162. data/spec/unit/rdf_datastream_spec.rb +0 -84
  163. data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
  164. data/spec/unit/rdfxml_datastream_spec.rb +0 -106
@@ -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
@@ -38,25 +38,25 @@ describe "Nesting attribute behavior of RDF resources" do
38
38
  end
39
39
 
40
40
  context "with an AT resource as a property" do
41
- subject { ComplexResource.new }
41
+ subject(:complex_resource) { ComplexResource.new }
42
42
 
43
43
  let(:params) { [{ subject: 'Foo' }, { subject: 'Bar' }] }
44
44
 
45
45
  before do
46
46
  ComplexResource.accepts_nested_attributes_for(*args)
47
- subject.topic_attributes = params
47
+ complex_resource.topic_attributes = params
48
48
  end
49
49
 
50
50
  context "when no options are set" do
51
51
  let(:args) { [:topic] }
52
52
 
53
53
  it "sets the attributes" do
54
- expect(subject.topic.size).to eq 2
55
- expect(subject.topic.map(&:subject)).to eq [['Foo'], ['Bar']]
54
+ expect(complex_resource.topic.size).to eq 2
55
+ expect(complex_resource.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('topic' => [])
59
+ expect(complex_resource.changed_attributes.keys).to eq ["topic"]
60
60
  end
61
61
  end
62
62
 
@@ -66,7 +66,7 @@ describe "Nesting attribute behavior of RDF resources" do
66
66
  let(:params) { [{ subject: 'Foo' }, { subject: 'Bar' }] }
67
67
 
68
68
  it "does not add terms for which the proc is true" do
69
- expect(subject.topic.map(&:subject)).to eq [['Foo']]
69
+ expect(complex_resource.topic.map(&:subject)).to eq [['Foo']]
70
70
  end
71
71
  end
72
72
  end
@@ -25,30 +25,28 @@ describe ActiveFedora::Base do
25
25
  let!(:instance2) { TestClass.create!(foo: ['Alpha'], bar: ['Peanuts']) }
26
26
  let!(:instance3) { TestClass.create!(foo: ['Sigma'], bar: ['Peanuts']) }
27
27
 
28
- subject { TestClass.where(bar: 'Peanuts') }
28
+ subject(:peanuts) { TestClass.where(bar: 'Peanuts') }
29
29
 
30
30
  it "maps" do
31
- expect(subject.map(&:id)).to eq [instance2.id, instance3.id]
31
+ expect(peanuts.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 eq [instance2.id, instance3.id]
35
+ expect(peanuts.collect(&:id)).to contain_exactly instance2.id, instance3.id
36
36
  end
37
37
 
38
38
  it "has each" do
39
- t = double
40
- expect(t).to receive(:foo).twice
41
- subject.each { t.foo }
39
+ expect(peanuts.each.to_a.length).to eq 2
42
40
  end
43
41
 
44
42
  it "has all?" do
45
- expect(subject.all? { |t| t.foo == ['Alpha'] }).to be false
46
- expect(subject.all? { |t| t.bar == ['Peanuts'] }).to be true
43
+ expect(peanuts.all? { |t| t.foo == ['Alpha'] }).to be false
44
+ expect(peanuts.all? { |t| t.bar == ['Peanuts'] }).to be true
47
45
  end
48
46
 
49
47
  it "has include?" do
50
- expect(subject.include?(instance1)).to be false
51
- expect(subject.include?(instance2)).to be true
48
+ expect(peanuts.include?(instance1)).to be false
49
+ expect(peanuts.include?(instance2)).to be true
52
50
  end
53
51
  end
54
52
  end
@@ -15,15 +15,13 @@ describe ActiveFedora::Base do
15
15
  Object.send(:remove_const, :Book)
16
16
  end
17
17
 
18
- subject { Library.all }
18
+ subject(:libraries) { Library.all }
19
19
 
20
20
  it "is a relation" do
21
- expect(subject.class).to be ActiveFedora::Relation
21
+ expect(libraries.class).to be ActiveFedora::Relation
22
22
  end
23
23
 
24
- it "is enumerable" do
25
- expect(subject).to respond_to(:each_with_index)
26
- end
24
+ it { is_expected.to respond_to(:each_with_index) }
27
25
 
28
26
  context "when some records exist" do
29
27
  before do
@@ -34,43 +32,42 @@ describe ActiveFedora::Base do
34
32
 
35
33
  describe "is cached" do
36
34
  before do
37
- subject.to_a # trigger initial load
35
+ libraries.to_a # trigger initial load
38
36
  end
39
37
 
40
- it "is loaded" do
41
- expect(subject).to be_loaded
42
- end
38
+ it { is_expected.to be_loaded }
39
+
43
40
  it "does not reload" do
44
41
  expect_any_instance_of(ActiveFedora::Relation).to_not receive :find_each
45
- subject[0]
42
+ libraries[0]
46
43
  end
47
44
  end
48
45
 
49
46
  describe "#find" do
50
47
  it "finds one of them" do
51
- expect(subject.find(library1.id)).to eq library1
48
+ expect(libraries.find(library1.id)).to eq library1
52
49
  end
53
50
  it "finds with a block" do
54
- expect(subject.find { |l| l.id == library1.id }).to eq library1
51
+ expect(libraries.find { |l| l.id == library1.id }).to eq library1
55
52
  end
56
53
  end
57
54
 
58
55
  describe "#select" do
59
56
  it "finds with a block" do
60
- expect(subject.select { |l| l.id == library1.id }).to eq [library1]
57
+ expect(libraries.select { |l| l.id == library1.id }).to eq [library1]
61
58
  end
62
59
  end
63
60
 
64
61
  context "unpermitted methods" do
65
62
  it "excludes them" do
66
- expect { subject.sort! }.to raise_error NoMethodError
63
+ expect { libraries.sort! }.to raise_error NoMethodError
67
64
  end
68
65
  end
69
66
 
70
67
  context "when limit is applied" do
71
- subject { Library.create books: [Book.create, Book.create] }
68
+ subject(:libraries) { Library.create books: [Book.create, Book.create] }
72
69
  it "limits the number of books" do
73
- expect(subject.books.limit(1).size).to eq 1
70
+ expect(libraries.books.limit(1).size).to eq 1
74
71
  end
75
72
  end
76
73
  end
@@ -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 eq [test_instance2, test_instance1, test_instance3]
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 eq [test_instance2, test_instance3]
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 eq [test_instance1, test_instance3]
130
+ expect(ModelIntegrationSpec::Basic.all).to contain_exactly test_instance1, test_instance3
131
131
  end
132
132
  end
133
133
  end
@@ -19,25 +19,14 @@ describe ActiveFedora::SolrHit do
19
19
  ) }
20
20
 
21
21
  let(:doc) { obj.to_solr }
22
- let(:solr_hit) { described_class.new(doc) }
22
+ subject(:solr_hit) { described_class.new(doc) }
23
23
 
24
24
  describe "#reify" do
25
- subject { solr_hit.reify }
25
+ let(:solr_reified) { solr_hit.reify }
26
26
 
27
27
  it "finds the document in solr" do
28
- expect(subject).to be_instance_of Foo
29
- expect(subject.title).to eq 'My Title'
30
- end
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'
28
+ expect(solr_reified).to be_instance_of Foo
29
+ expect(solr_reified.title).to eq 'My Title'
41
30
  end
42
31
  end
43
32
  end