active-fedora 11.0.0.rc1 → 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 (159) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +2 -7
  4. data/.rubocop_todo.yml +40 -9
  5. data/.solr_wrapper +6 -0
  6. data/README.md +1 -3
  7. data/active-fedora.gemspec +5 -9
  8. data/lib/active_fedora/associations/collection_association.rb +1 -1
  9. data/lib/active_fedora/associations/contained_finder.rb +2 -2
  10. data/lib/active_fedora/associations/has_many_association.rb +1 -1
  11. data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
  12. data/lib/active_fedora/attribute_assignment.rb +0 -1
  13. data/lib/active_fedora/attributes.rb +1 -1
  14. data/lib/active_fedora/base.rb +3 -7
  15. data/lib/active_fedora/change_set.rb +6 -2
  16. data/lib/active_fedora/containers/container.rb +1 -1
  17. data/lib/active_fedora/core.rb +22 -25
  18. data/lib/active_fedora/fedora_attributes.rb +1 -1
  19. data/lib/active_fedora/file.rb +1 -1
  20. data/lib/active_fedora/indexing_service.rb +0 -4
  21. data/lib/active_fedora/orders/ordered_list.rb +2 -2
  22. data/lib/active_fedora/querying.rb +1 -1
  23. data/lib/active_fedora/railtie.rb +2 -2
  24. data/lib/active_fedora/rake_support.rb +1 -1
  25. data/lib/active_fedora/rdf.rb +0 -1
  26. data/lib/active_fedora/relation/delegation.rb +4 -0
  27. data/lib/active_fedora/solr_hit.rb +0 -4
  28. data/lib/active_fedora/solr_query_builder.rb +16 -12
  29. data/lib/active_fedora/version.rb +1 -1
  30. data/lib/active_fedora.rb +0 -10
  31. data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +11 -0
  32. data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
  33. data/spec/config_helper.rb +1 -1
  34. data/spec/integration/associations_spec.rb +17 -18
  35. data/spec/integration/attached_files_spec.rb +18 -8
  36. data/spec/integration/attributes_spec.rb +12 -16
  37. data/spec/integration/autosave_association_spec.rb +6 -6
  38. data/spec/integration/base_spec.rb +3 -3
  39. data/spec/integration/collection_association_spec.rb +2 -5
  40. data/spec/integration/date_time_properties_spec.rb +1 -2
  41. data/spec/integration/direct_container_spec.rb +8 -8
  42. data/spec/integration/directly_contains_one_association_spec.rb +11 -13
  43. data/spec/integration/eradicate_spec.rb +1 -1
  44. data/spec/integration/fedora_solr_sync_spec.rb +2 -2
  45. data/spec/integration/file_fixity_spec.rb +6 -8
  46. data/spec/integration/file_spec.rb +32 -34
  47. data/spec/integration/generators/solr_generator_spec.rb +7 -10
  48. data/spec/integration/has_many_associations_spec.rb +6 -8
  49. data/spec/integration/indexing_spec.rb +1 -1
  50. data/spec/integration/indirect_container_spec.rb +8 -9
  51. data/spec/integration/json_serialization_spec.rb +4 -4
  52. data/spec/integration/query_result_builder_spec.rb +9 -21
  53. data/spec/integration/rdf_nested_attributes_spec.rb +6 -6
  54. data/spec/integration/relation_delegation_spec.rb +8 -10
  55. data/spec/integration/relation_spec.rb +13 -16
  56. data/spec/integration/solr_hit_spec.rb +4 -4
  57. data/spec/integration/versionable_spec.rb +73 -327
  58. data/spec/spec_helper.rb +52 -10
  59. data/spec/unit/active_fedora_spec.rb +1 -1
  60. data/spec/unit/aggregation/list_source_spec.rb +37 -37
  61. data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
  62. data/spec/unit/association_hash_spec.rb +17 -31
  63. data/spec/unit/attached_files_spec.rb +35 -32
  64. data/spec/unit/attributes_spec.rb +25 -25
  65. data/spec/unit/base_active_model_spec.rb +8 -8
  66. data/spec/unit/base_cma_spec.rb +1 -1
  67. data/spec/unit/base_extra_spec.rb +7 -22
  68. data/spec/unit/base_spec.rb +14 -20
  69. data/spec/unit/callback_spec.rb +2 -2
  70. data/spec/unit/change_set_spec.rb +5 -5
  71. data/spec/unit/checksum_spec.rb +2 -2
  72. data/spec/unit/code_configurator_spec.rb +1 -1
  73. data/spec/unit/core_spec.rb +62 -26
  74. data/spec/unit/default_model_mapper_spec.rb +6 -6
  75. data/spec/unit/fedora_spec.rb +2 -2
  76. data/spec/unit/file_configurator_spec.rb +96 -96
  77. data/spec/unit/file_path_builder_spec.rb +1 -1
  78. data/spec/unit/file_spec.rb +61 -61
  79. data/spec/unit/files_hash_spec.rb +9 -9
  80. data/spec/unit/finder_methods_spec.rb +3 -3
  81. data/spec/unit/has_and_belongs_to_many_association_spec.rb +13 -14
  82. data/spec/unit/has_many_association_spec.rb +28 -13
  83. data/spec/unit/indexers/global_indexer_spec.rb +6 -6
  84. data/spec/unit/indexing_service_spec.rb +5 -5
  85. data/spec/unit/indexing_spec.rb +6 -6
  86. data/spec/unit/inheritance_spec.rb +11 -7
  87. data/spec/unit/loadable_from_json_spec.rb +4 -4
  88. data/spec/unit/logger_spec.rb +1 -1
  89. data/spec/unit/model_classifier_spec.rb +5 -5
  90. data/spec/unit/ordered_spec.rb +142 -142
  91. data/spec/unit/orders/list_node_spec.rb +21 -21
  92. data/spec/unit/orders/ordered_list_spec.rb +96 -96
  93. data/spec/unit/orders/reflection_spec.rb +4 -4
  94. data/spec/unit/pathing_spec.rb +4 -4
  95. data/spec/unit/persistence_spec.rb +28 -28
  96. data/spec/unit/property_spec.rb +2 -2
  97. data/spec/unit/query_spec.rb +10 -10
  98. data/spec/unit/rdf/indexing_service_spec.rb +26 -26
  99. data/spec/unit/readonly_spec.rb +5 -4
  100. data/spec/unit/reflection_spec.rb +3 -3
  101. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
  102. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
  103. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
  104. data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
  105. data/spec/unit/serializers_spec.rb +3 -4
  106. data/spec/unit/solr_config_options_spec.rb +13 -16
  107. data/spec/unit/solr_hit_spec.rb +9 -9
  108. data/spec/unit/solr_service_spec.rb +4 -10
  109. data/spec/unit/sparql_insert_spec.rb +2 -2
  110. data/spec/unit/validations_spec.rb +9 -9
  111. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
  112. data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
  113. metadata +17 -118
  114. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
  115. data/lib/active_fedora/datastreams.rb +0 -6
  116. data/lib/active_fedora/nom_datastream.rb +0 -73
  117. data/lib/active_fedora/om_datastream.rb +0 -118
  118. data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
  119. data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
  120. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
  121. data/lib/active_fedora/rdf/rdf_datastream.rb +0 -173
  122. data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
  123. data/solr/config/_rest_managed.json +0 -3
  124. data/solr/config/admin-extra.html +0 -31
  125. data/solr/config/elevate.xml +0 -36
  126. data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
  127. data/solr/config/protwords.txt +0 -21
  128. data/solr/config/schema.xml +0 -372
  129. data/solr/config/scripts.conf +0 -24
  130. data/solr/config/solrconfig.xml +0 -311
  131. data/solr/config/spellings.txt +0 -2
  132. data/solr/config/stopwords.txt +0 -58
  133. data/solr/config/stopwords_en.txt +0 -58
  134. data/solr/config/synonyms.txt +0 -31
  135. data/solr/config/xslt/example.xsl +0 -132
  136. data/solr/config/xslt/example_atom.xsl +0 -67
  137. data/solr/config/xslt/example_rss.xsl +0 -66
  138. data/solr/config/xslt/luke.xsl +0 -337
  139. data/spec/fixtures/damsObjectModel.xml +0 -38
  140. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
  141. data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
  142. data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
  143. data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
  144. data/spec/integration/complex_rdf_datastream_spec.rb +0 -227
  145. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -180
  146. data/spec/integration/ntriples_datastream_spec.rb +0 -215
  147. data/spec/integration/om_datastream_spec.rb +0 -78
  148. data/spec/samples/hydra-mods_article_datastream.rb +0 -515
  149. data/spec/samples/models/mods_article.rb +0 -9
  150. data/spec/samples/oral_history_sample.xml +0 -38
  151. data/spec/samples/oral_history_xml.xml +0 -35
  152. data/spec/samples/samples.rb +0 -2
  153. data/spec/unit/nom_datastream_spec.rb +0 -60
  154. data/spec/unit/ntriples_datastream_spec.rb +0 -167
  155. data/spec/unit/om_datastream_spec.rb +0 -294
  156. data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
  157. data/spec/unit/rdf_datastream_spec.rb +0 -84
  158. data/spec/unit/rdf_resource_datastream_spec.rb +0 -208
  159. data/spec/unit/rdfxml_datastream_spec.rb +0 -106
@@ -130,18 +130,17 @@ describe "Indirect containers" do
130
130
  end
131
131
 
132
132
  describe "#first" do
133
- subject { reloaded.related_objects.first }
133
+ subject(:first) { reloaded.related_objects.first }
134
134
  it "has the content" do
135
- expect(subject.title).to eq 'HMMM'
135
+ expect(first.title).to eq 'HMMM'
136
136
  end
137
137
  end
138
138
 
139
139
  describe "#==" do
140
140
  subject { reloaded.related_objects }
141
141
 
142
- it "delegates to to_a" do
143
- expect(subject).to eq [file]
144
- end
142
+ # it delegates to to_a
143
+ it { is_expected.to eq [file] }
145
144
  end
146
145
 
147
146
  describe "#concat" do
@@ -242,9 +241,9 @@ describe "Indirect containers" do
242
241
  end
243
242
 
244
243
  describe "#first" do
245
- subject { reloaded.related_objects.first }
244
+ subject(:first) { reloaded.related_objects.first }
246
245
  it "has the content" do
247
- expect(subject.title).to eq 'HMMM'
246
+ expect(first.title).to eq 'HMMM'
248
247
  end
249
248
  end
250
249
  end
@@ -280,9 +279,9 @@ describe "Indirect containers" do
280
279
  end
281
280
 
282
281
  describe "#first" do
283
- subject { reloaded.related_objects.first }
282
+ subject(:first) { reloaded.related_objects.first }
284
283
  it "has the content" do
285
- expect(subject.title).to eq 'HMMM'
284
+ expect(first.title).to eq 'HMMM'
286
285
  end
287
286
  end
288
287
  end
@@ -21,12 +21,12 @@ describe "Objects should be serialized to JSON" do
21
21
 
22
22
  before { allow(obj).to receive(:id).and_return('test-123') }
23
23
 
24
- subject { JSON.parse(obj.to_json) }
24
+ let(:json) { JSON.parse(obj.to_json) }
25
25
 
26
26
  it "has to_json" do
27
- expect(subject['id']).to eq "test-123"
28
- expect(subject['title']).to eq ["My Title"]
29
- expect(subject['description']).to eq "Wonderful stuff"
27
+ expect(json['id']).to eq "test-123"
28
+ expect(json['title']).to eq ["My Title"]
29
+ expect(json['description']).to eq "Wonderful stuff"
30
30
  end
31
31
  end
32
32
  end
@@ -2,35 +2,23 @@ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::QueryResultBuilder do
4
4
  describe "#reify_solr_results" do
5
- before(:each) do
5
+ before do
6
6
  class FooObject < ActiveFedora::Base
7
7
  def self.id_namespace
8
8
  "foo"
9
9
  end
10
-
11
- has_subresource :descMetadata, class_name: 'ActiveFedora::QualifiedDublinCoreDatastream'
12
10
  end
13
- @test_object = ActiveFedora::Base.new
14
- @foo_object = FooObject.new
15
- attributes = { "language" => { 0 => "Italian" },
16
- "creator" => { 0 => "Linguist, A." },
17
- "geography" => { 0 => "Italy" },
18
- "title" => { 0 => "Italian and Spanish: A Comparison of Common Phrases" } }
19
- @foo_object.descMetadata.update_indexed_attributes(attributes)
20
- @test_object.save
21
- @foo_object.save
22
- @profiles = {
23
- # 'test' => @test_object.profile,
24
- # 'foo' => @foo_object.profile,
25
- # 'foo_descMetadata' => @foo_object.datastreams['descMetadata'].profile
26
- }
27
- @foo_content = @foo_object.attached_files['descMetadata'].content
28
11
  end
29
- after(:each) do
12
+
13
+ let(:test_object) { ActiveFedora::Base.create }
14
+ let(:foo_object) { FooObject.create }
15
+
16
+ after do
30
17
  Object.send(:remove_const, :FooObject)
31
18
  end
19
+
32
20
  it "returns an array of objects that are of the class stored in active_fedora_model_s" do
33
- query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([@test_object.id, @foo_object.id])
21
+ query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([test_object.id, foo_object.id])
34
22
  solr_result = ActiveFedora::SolrService.query(query)
35
23
  result = described_class.reify_solr_results(solr_result)
36
24
  expect(result.length).to eq 2
@@ -40,7 +28,7 @@ describe ActiveFedora::QueryResultBuilder do
40
28
  end
41
29
 
42
30
  it '#reifies a lightweight object as a new instance' do
43
- query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([@foo_object.id])
31
+ query = ActiveFedora::SolrQueryBuilder.construct_query_for_ids([foo_object.id])
44
32
  solr_result = ActiveFedora::SolrService.query(query)
45
33
  result = described_class.reify_solr_results(solr_result, load_from_solr: true)
46
34
  expect(result.first).to be_instance_of FooObject
@@ -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 contain_exactly ['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.keys).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 contain_exactly 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 contain_exactly 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
@@ -19,14 +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'
28
+ expect(solr_reified).to be_instance_of Foo
29
+ expect(solr_reified.title).to eq 'My Title'
30
30
  end
31
31
  end
32
32
  end