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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -7
- data/.rubocop_todo.yml +40 -9
- data/.solr_wrapper +6 -0
- data/README.md +1 -3
- data/active-fedora.gemspec +5 -9
- data/lib/active_fedora/associations/collection_association.rb +1 -1
- data/lib/active_fedora/associations/contained_finder.rb +2 -2
- data/lib/active_fedora/associations/has_many_association.rb +1 -1
- data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
- data/lib/active_fedora/attribute_assignment.rb +0 -1
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/base.rb +3 -7
- data/lib/active_fedora/change_set.rb +6 -2
- data/lib/active_fedora/containers/container.rb +1 -1
- data/lib/active_fedora/core.rb +22 -25
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file.rb +1 -1
- data/lib/active_fedora/indexing_service.rb +0 -4
- data/lib/active_fedora/orders/ordered_list.rb +2 -2
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/railtie.rb +2 -2
- data/lib/active_fedora/rake_support.rb +1 -1
- data/lib/active_fedora/rdf.rb +0 -1
- data/lib/active_fedora/relation/delegation.rb +4 -0
- data/lib/active_fedora/solr_hit.rb +0 -4
- data/lib/active_fedora/solr_query_builder.rb +16 -12
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora.rb +0 -10
- data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +11 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
- data/spec/config_helper.rb +1 -1
- data/spec/integration/associations_spec.rb +17 -18
- data/spec/integration/attached_files_spec.rb +18 -8
- data/spec/integration/attributes_spec.rb +12 -16
- data/spec/integration/autosave_association_spec.rb +6 -6
- data/spec/integration/base_spec.rb +3 -3
- data/spec/integration/collection_association_spec.rb +2 -5
- data/spec/integration/date_time_properties_spec.rb +1 -2
- data/spec/integration/direct_container_spec.rb +8 -8
- data/spec/integration/directly_contains_one_association_spec.rb +11 -13
- data/spec/integration/eradicate_spec.rb +1 -1
- data/spec/integration/fedora_solr_sync_spec.rb +2 -2
- data/spec/integration/file_fixity_spec.rb +6 -8
- data/spec/integration/file_spec.rb +32 -34
- data/spec/integration/generators/solr_generator_spec.rb +7 -10
- data/spec/integration/has_many_associations_spec.rb +6 -8
- data/spec/integration/indexing_spec.rb +1 -1
- data/spec/integration/indirect_container_spec.rb +8 -9
- data/spec/integration/json_serialization_spec.rb +4 -4
- data/spec/integration/query_result_builder_spec.rb +9 -21
- data/spec/integration/rdf_nested_attributes_spec.rb +6 -6
- data/spec/integration/relation_delegation_spec.rb +8 -10
- data/spec/integration/relation_spec.rb +13 -16
- data/spec/integration/solr_hit_spec.rb +4 -4
- data/spec/integration/versionable_spec.rb +73 -327
- data/spec/spec_helper.rb +52 -10
- data/spec/unit/active_fedora_spec.rb +1 -1
- data/spec/unit/aggregation/list_source_spec.rb +37 -37
- data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
- data/spec/unit/association_hash_spec.rb +17 -31
- data/spec/unit/attached_files_spec.rb +35 -32
- data/spec/unit/attributes_spec.rb +25 -25
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_cma_spec.rb +1 -1
- data/spec/unit/base_extra_spec.rb +7 -22
- data/spec/unit/base_spec.rb +14 -20
- data/spec/unit/callback_spec.rb +2 -2
- data/spec/unit/change_set_spec.rb +5 -5
- data/spec/unit/checksum_spec.rb +2 -2
- data/spec/unit/code_configurator_spec.rb +1 -1
- data/spec/unit/core_spec.rb +62 -26
- data/spec/unit/default_model_mapper_spec.rb +6 -6
- data/spec/unit/fedora_spec.rb +2 -2
- data/spec/unit/file_configurator_spec.rb +96 -96
- data/spec/unit/file_path_builder_spec.rb +1 -1
- data/spec/unit/file_spec.rb +61 -61
- data/spec/unit/files_hash_spec.rb +9 -9
- data/spec/unit/finder_methods_spec.rb +3 -3
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +13 -14
- data/spec/unit/has_many_association_spec.rb +28 -13
- data/spec/unit/indexers/global_indexer_spec.rb +6 -6
- data/spec/unit/indexing_service_spec.rb +5 -5
- data/spec/unit/indexing_spec.rb +6 -6
- data/spec/unit/inheritance_spec.rb +11 -7
- data/spec/unit/loadable_from_json_spec.rb +4 -4
- data/spec/unit/logger_spec.rb +1 -1
- data/spec/unit/model_classifier_spec.rb +5 -5
- data/spec/unit/ordered_spec.rb +142 -142
- data/spec/unit/orders/list_node_spec.rb +21 -21
- data/spec/unit/orders/ordered_list_spec.rb +96 -96
- data/spec/unit/orders/reflection_spec.rb +4 -4
- data/spec/unit/pathing_spec.rb +4 -4
- data/spec/unit/persistence_spec.rb +28 -28
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/query_spec.rb +10 -10
- data/spec/unit/rdf/indexing_service_spec.rb +26 -26
- data/spec/unit/readonly_spec.rb +5 -4
- data/spec/unit/reflection_spec.rb +3 -3
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
- data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
- data/spec/unit/serializers_spec.rb +3 -4
- data/spec/unit/solr_config_options_spec.rb +13 -16
- data/spec/unit/solr_hit_spec.rb +9 -9
- data/spec/unit/solr_service_spec.rb +4 -10
- data/spec/unit/sparql_insert_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +9 -9
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
- data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
- metadata +17 -118
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
- data/lib/active_fedora/datastreams.rb +0 -6
- data/lib/active_fedora/nom_datastream.rb +0 -73
- data/lib/active_fedora/om_datastream.rb +0 -118
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
- data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
- data/lib/active_fedora/rdf/rdf_datastream.rb +0 -173
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
- data/solr/config/_rest_managed.json +0 -3
- data/solr/config/admin-extra.html +0 -31
- data/solr/config/elevate.xml +0 -36
- data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
- data/solr/config/protwords.txt +0 -21
- data/solr/config/schema.xml +0 -372
- data/solr/config/scripts.conf +0 -24
- data/solr/config/solrconfig.xml +0 -311
- data/solr/config/spellings.txt +0 -2
- data/solr/config/stopwords.txt +0 -58
- data/solr/config/stopwords_en.txt +0 -58
- data/solr/config/synonyms.txt +0 -31
- data/solr/config/xslt/example.xsl +0 -132
- data/solr/config/xslt/example_atom.xsl +0 -67
- data/solr/config/xslt/example_rss.xsl +0 -66
- data/solr/config/xslt/luke.xsl +0 -337
- data/spec/fixtures/damsObjectModel.xml +0 -38
- data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
- data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
- data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
- data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +0 -227
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -180
- data/spec/integration/ntriples_datastream_spec.rb +0 -215
- data/spec/integration/om_datastream_spec.rb +0 -78
- data/spec/samples/hydra-mods_article_datastream.rb +0 -515
- data/spec/samples/models/mods_article.rb +0 -9
- data/spec/samples/oral_history_sample.xml +0 -38
- data/spec/samples/oral_history_xml.xml +0 -35
- data/spec/samples/samples.rb +0 -2
- data/spec/unit/nom_datastream_spec.rb +0 -60
- data/spec/unit/ntriples_datastream_spec.rb +0 -167
- data/spec/unit/om_datastream_spec.rb +0 -294
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
- data/spec/unit/rdf_datastream_spec.rb +0 -84
- data/spec/unit/rdf_resource_datastream_spec.rb +0 -208
- 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(
|
|
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
|
|
143
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
24
|
+
let(:json) { JSON.parse(obj.to_json) }
|
|
25
25
|
|
|
26
26
|
it "has to_json" do
|
|
27
|
-
expect(
|
|
28
|
-
expect(
|
|
29
|
-
expect(
|
|
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
|
|
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
|
-
|
|
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([
|
|
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([
|
|
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
|
-
|
|
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(
|
|
55
|
-
expect(
|
|
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(
|
|
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(
|
|
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(
|
|
31
|
+
expect(peanuts.map(&:id)).to contain_exactly instance2.id, instance3.id
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "collects" do
|
|
35
|
-
expect(
|
|
35
|
+
expect(peanuts.collect(&:id)).to contain_exactly instance2.id, instance3.id
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it "has each" do
|
|
39
|
-
|
|
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(
|
|
46
|
-
expect(
|
|
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(
|
|
51
|
-
expect(
|
|
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(
|
|
21
|
+
expect(libraries.class).to be ActiveFedora::Relation
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
it
|
|
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
|
-
|
|
35
|
+
libraries.to_a # trigger initial load
|
|
38
36
|
end
|
|
39
37
|
|
|
40
|
-
it
|
|
41
|
-
|
|
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
|
-
|
|
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(
|
|
48
|
+
expect(libraries.find(library1.id)).to eq library1
|
|
52
49
|
end
|
|
53
50
|
it "finds with a block" do
|
|
54
|
-
expect(
|
|
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(
|
|
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 {
|
|
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(
|
|
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
|
-
|
|
22
|
+
subject(:solr_hit) { described_class.new(doc) }
|
|
23
23
|
|
|
24
24
|
describe "#reify" do
|
|
25
|
-
|
|
25
|
+
let(:solr_reified) { solr_hit.reify }
|
|
26
26
|
|
|
27
27
|
it "finds the document in solr" do
|
|
28
|
-
expect(
|
|
29
|
-
expect(
|
|
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
|