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
|
@@ -10,26 +10,26 @@ describe ActiveFedora::FilesHash do
|
|
|
10
10
|
|
|
11
11
|
after { Object.send(:remove_const, :FilesContainer) }
|
|
12
12
|
|
|
13
|
-
let(:reflection) {
|
|
14
|
-
let(:association) {
|
|
13
|
+
let(:reflection) { instance_double(ActiveFedora::Reflection::MacroReflection) }
|
|
14
|
+
let(:association) { instance_double(ActiveFedora::Associations::SingularAssociation, reader: object) }
|
|
15
15
|
let(:object) { double('object') }
|
|
16
16
|
let(:container) { FilesContainer.new }
|
|
17
17
|
|
|
18
|
-
subject { described_class.new(container) }
|
|
18
|
+
subject(:file_hash) { described_class.new(container) }
|
|
19
19
|
|
|
20
20
|
describe "#key?" do
|
|
21
21
|
context 'when the key is present' do
|
|
22
22
|
it "is true" do
|
|
23
|
-
expect(
|
|
23
|
+
expect(file_hash.key?(:file)).to be true
|
|
24
24
|
end
|
|
25
25
|
it "returns true if a string is passed" do
|
|
26
|
-
expect(
|
|
26
|
+
expect(file_hash.key?('file')).to be true
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
context 'when the key is not present' do
|
|
31
31
|
it "is false" do
|
|
32
|
-
expect(
|
|
32
|
+
expect(file_hash.key?(:foo)).to be false
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -37,16 +37,16 @@ describe ActiveFedora::FilesHash do
|
|
|
37
37
|
describe "#[]" do
|
|
38
38
|
context 'when the key is present' do
|
|
39
39
|
it "returns the object" do
|
|
40
|
-
expect(
|
|
40
|
+
expect(file_hash[:file]).to eq object
|
|
41
41
|
end
|
|
42
42
|
it "returns the object if a string is passed" do
|
|
43
|
-
expect(
|
|
43
|
+
expect(file_hash['file']).to eq object
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
context 'when the key is not present' do
|
|
48
48
|
it "is nil" do
|
|
49
|
-
expect(
|
|
49
|
+
expect(file_hash[:foo]).to be_nil
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -57,9 +57,9 @@ describe ActiveFedora::FinderMethods do
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
describe "#search_in_batches" do
|
|
60
|
-
let(:docs) {
|
|
60
|
+
let(:docs) { instance_double(RSolr::Response::PaginatedDocSet, has_next?: false) }
|
|
61
61
|
let(:select_handler) { 'select' }
|
|
62
|
-
let(:connection) {
|
|
62
|
+
let(:connection) { instance_double(RSolr::Client) }
|
|
63
63
|
before do
|
|
64
64
|
expect(finder).to receive(:create_query).with('age_t' => '21').and_return('dummy query')
|
|
65
65
|
allow(ActiveFedora::SolrService.instance).to receive(:conn).and_return(connection)
|
|
@@ -84,7 +84,7 @@ describe ActiveFedora::FinderMethods do
|
|
|
84
84
|
|
|
85
85
|
describe '#search_by_id' do
|
|
86
86
|
context 'with a document in solr' do
|
|
87
|
-
let(:doc) {
|
|
87
|
+
let(:doc) { instance_double(Hash) }
|
|
88
88
|
|
|
89
89
|
before do
|
|
90
90
|
expect(finder).to receive(:search_with_conditions).with({ id: 'x' }, hash_including(rows: 1)).and_return([doc])
|
|
@@ -7,33 +7,32 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
|
7
7
|
end
|
|
8
8
|
class Page < ActiveFedora::Base
|
|
9
9
|
end
|
|
10
|
-
allow_any_instance_of(Book).to receive(:load_datastreams).and_return(false)
|
|
11
|
-
allow_any_instance_of(Page).to receive(:load_datastreams).and_return(false)
|
|
12
10
|
|
|
13
|
-
allow(
|
|
14
|
-
allow(
|
|
11
|
+
allow(book).to receive(:new_record?).and_return(false)
|
|
12
|
+
allow(book).to receive(:save).and_return(true)
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
after do
|
|
18
16
|
Object.send(:remove_const, :Book)
|
|
19
17
|
Object.send(:remove_const, :Page)
|
|
20
18
|
end
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
subject(:book) { Book.new(id: 'subject-a') }
|
|
22
21
|
|
|
23
22
|
context "a one way relationship " do
|
|
24
23
|
describe "adding memeber" do
|
|
25
24
|
it "sets the relationship attribute" do
|
|
26
25
|
reflection = ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Book)
|
|
27
26
|
allow(ActiveFedora::SolrService).to receive(:query).and_return([])
|
|
28
|
-
ac = described_class.new(
|
|
27
|
+
ac = described_class.new(book, reflection)
|
|
29
28
|
expect(ac).to receive(:callback).twice
|
|
30
29
|
object = Page.new
|
|
31
30
|
allow(object).to receive(:new_record?).and_return(false)
|
|
32
31
|
allow(object).to receive(:save).and_return(true)
|
|
33
32
|
allow(object).to receive(:id).and_return('1234')
|
|
34
33
|
|
|
35
|
-
allow(
|
|
36
|
-
expect(
|
|
34
|
+
allow(book).to receive(:[]).with('page_ids').and_return([])
|
|
35
|
+
expect(book).to receive(:[]=).with('page_ids', ['1234'])
|
|
37
36
|
|
|
38
37
|
ac.concat object
|
|
39
38
|
end
|
|
@@ -42,9 +41,9 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
|
42
41
|
describe "finding member" do
|
|
43
42
|
let(:ids) { (0..15).map(&:to_s) }
|
|
44
43
|
let(:reflection) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Book) }
|
|
45
|
-
let(:association) { described_class.new(
|
|
44
|
+
let(:association) { described_class.new(book, reflection) }
|
|
46
45
|
it "calls ActiveFedora::Base.find" do
|
|
47
|
-
expect(
|
|
46
|
+
expect(book).to receive(:[]).with('page_ids').and_return(ids)
|
|
48
47
|
expect(ActiveFedora::Base).to receive(:find).with(ids)
|
|
49
48
|
association.send(:find_target)
|
|
50
49
|
end
|
|
@@ -54,7 +53,7 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
|
54
53
|
context "with an inverse reflection" do
|
|
55
54
|
let!(:inverse) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :books, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Page) }
|
|
56
55
|
let(:reflection) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, inverse_of: 'books' }, Book) }
|
|
57
|
-
let(:ac) { described_class.new(
|
|
56
|
+
let(:ac) { described_class.new(book, reflection) }
|
|
58
57
|
let(:object) { Page.new }
|
|
59
58
|
|
|
60
59
|
it "sets the relationship attribute on subject and object when inverse_of is given" do
|
|
@@ -63,11 +62,11 @@ describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
|
|
|
63
62
|
allow(object).to receive(:new_record?).and_return(false)
|
|
64
63
|
allow(object).to receive(:save).and_return(true)
|
|
65
64
|
|
|
66
|
-
allow(
|
|
67
|
-
expect(
|
|
65
|
+
allow(book).to receive(:[]).with('page_ids').and_return([])
|
|
66
|
+
expect(book).to receive(:[]=).with('page_ids', [object.id])
|
|
68
67
|
|
|
69
68
|
expect(object).to receive(:[]).with('book_ids').and_return([]).twice
|
|
70
|
-
expect(object).to receive(:[]=).with('book_ids', [
|
|
69
|
+
expect(object).to receive(:[]=).with('book_ids', [book.id])
|
|
71
70
|
|
|
72
71
|
ac.concat object
|
|
73
72
|
end
|
|
@@ -12,8 +12,8 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
12
12
|
Object.send(:remove_const, :Book)
|
|
13
13
|
Object.send(:remove_const, :Page)
|
|
14
14
|
end
|
|
15
|
-
let(:book) { Book.new('subject-a') }
|
|
16
|
-
let(:page) { Page.new('object-b') }
|
|
15
|
+
let(:book) { Book.new(id: 'subject-a') }
|
|
16
|
+
let(:page) { Page.new(id: 'object-b') }
|
|
17
17
|
|
|
18
18
|
describe "setting the foreign key" do
|
|
19
19
|
before do
|
|
@@ -32,19 +32,34 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
describe "
|
|
36
|
-
before do
|
|
37
|
-
# :books must come first, so that we can test that is being passed over in favor of :contents
|
|
38
|
-
Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
39
|
-
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
40
|
-
end
|
|
35
|
+
describe "#find_polymorphic_inverse" do
|
|
41
36
|
let(:book_reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
|
42
37
|
let(:association) { described_class.new(book, book_reflection) }
|
|
43
38
|
|
|
44
|
-
subject { association.send(:find_polymorphic_inverse, page) }
|
|
39
|
+
subject(:af_page) { association.send(:find_polymorphic_inverse, page) }
|
|
40
|
+
|
|
41
|
+
context "when a has_many is present" do
|
|
42
|
+
before do
|
|
43
|
+
# :books must come first, so that we can test that is being passed over in favor of :contents
|
|
44
|
+
Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
45
|
+
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "finds the HABTM reflection" do
|
|
49
|
+
expect(af_page.name).to eq :contents
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context "when multiple belongs_to are present" do
|
|
54
|
+
before do
|
|
55
|
+
# :foo must come first, so that we can test that is being passed over in favor of :bar
|
|
56
|
+
Page.belongs_to :foo, predicate: ::RDF::Vocab::DC.isPartOf, class_name: 'ActiveFedora::Base'
|
|
57
|
+
Page.belongs_to :bar, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
58
|
+
end
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
it "finds the belongs_to reflection" do
|
|
61
|
+
expect(af_page.name).to eq :bar
|
|
62
|
+
end
|
|
48
63
|
end
|
|
49
64
|
end
|
|
50
65
|
|
|
@@ -95,8 +110,8 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
95
110
|
end
|
|
96
111
|
|
|
97
112
|
describe "#ids_reader" do
|
|
98
|
-
let(:owner) {
|
|
99
|
-
let(:reflection) {
|
|
113
|
+
let(:owner) { instance_double(ActiveFedora::Base) }
|
|
114
|
+
let(:reflection) { instance_double(ActiveFedora::Reflection::AssociationReflection, check_validity!: true) }
|
|
100
115
|
let(:association) { described_class.new(owner, reflection) }
|
|
101
116
|
|
|
102
117
|
let(:r1) { ActiveFedora::Base.new(id: 'r1-id', &:mark_for_destruction) }
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
RSpec.describe ActiveFedora::Indexers::GlobalIndexer do
|
|
4
|
-
|
|
4
|
+
let(:global_indexer) { described_class.new(index_types) }
|
|
5
5
|
let(:index_types) {}
|
|
6
6
|
|
|
7
7
|
describe "#new" do
|
|
8
8
|
# The global indexer acts as both an indexer factory and an indexer, since
|
|
9
9
|
# the property doesn't matter.
|
|
10
10
|
it "returns itself" do
|
|
11
|
-
expect(
|
|
11
|
+
expect(global_indexer.new("bla")).to eq global_indexer
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
describe "#index" do
|
|
@@ -16,7 +16,7 @@ RSpec.describe ActiveFedora::Indexers::GlobalIndexer do
|
|
|
16
16
|
context "with one index type" do
|
|
17
17
|
let(:index_types) { :symbol }
|
|
18
18
|
it "passes that to index_obj" do
|
|
19
|
-
|
|
19
|
+
global_indexer.index(index_obj)
|
|
20
20
|
|
|
21
21
|
expect(index_obj).to have_received(:as).with(:symbol)
|
|
22
22
|
end
|
|
@@ -24,15 +24,15 @@ RSpec.describe ActiveFedora::Indexers::GlobalIndexer do
|
|
|
24
24
|
context "with multiple index types" do
|
|
25
25
|
let(:index_types) { [:symbol, :stored_searchable] }
|
|
26
26
|
it "passes that to index_obj" do
|
|
27
|
-
|
|
27
|
+
global_indexer.index(index_obj)
|
|
28
28
|
|
|
29
29
|
expect(index_obj).to have_received(:as).with(:symbol, :stored_searchable)
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
context "with no index types" do
|
|
33
|
-
|
|
33
|
+
let(:global_indexer) { described_class.new }
|
|
34
34
|
it "does not pass anything to index_obj" do
|
|
35
|
-
|
|
35
|
+
global_indexer.index(index_obj)
|
|
36
36
|
|
|
37
37
|
expect(index_obj).not_to have_received(:as)
|
|
38
38
|
end
|
|
@@ -6,22 +6,22 @@ describe ActiveFedora::IndexingService do
|
|
|
6
6
|
|
|
7
7
|
describe "#generate_solr_document" do
|
|
8
8
|
context "when no block is passed" do
|
|
9
|
-
subject { indexer.generate_solr_document }
|
|
9
|
+
subject(:solr_doc) { indexer.generate_solr_document }
|
|
10
10
|
it "produces a document" do
|
|
11
|
-
expect(
|
|
11
|
+
expect(solr_doc['has_model_ssim']).to eq ['ActiveFedora::Base']
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
context "when a block is passed" do
|
|
16
|
-
subject do
|
|
16
|
+
subject(:solr_doc) do
|
|
17
17
|
indexer.generate_solr_document do |solr_doc|
|
|
18
18
|
solr_doc['noid'] = '12345'
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "produces and yield the document" do
|
|
23
|
-
expect(
|
|
24
|
-
expect(
|
|
23
|
+
expect(solr_doc['has_model_ssim']).to eq ['ActiveFedora::Base']
|
|
24
|
+
expect(solr_doc['noid']).to eq '12345'
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
data/spec/unit/indexing_spec.rb
CHANGED
|
@@ -25,7 +25,7 @@ describe ActiveFedora::Indexing do
|
|
|
25
25
|
Object.send(:remove_const, :SpecNode)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
subject { SpecNode.new }
|
|
28
|
+
subject(:node) { SpecNode.new }
|
|
29
29
|
|
|
30
30
|
describe "#create_needs_index?" do
|
|
31
31
|
subject { SpecNode.new.send(:create_needs_index?) }
|
|
@@ -55,10 +55,10 @@ describe ActiveFedora::Indexing do
|
|
|
55
55
|
|
|
56
56
|
let(:test_object) { SpecNode.new(title: ['first title'], abstract: 'The abstract') }
|
|
57
57
|
|
|
58
|
-
subject { test_object.to_solr }
|
|
58
|
+
subject(:solr_doc) { test_object.to_solr }
|
|
59
59
|
|
|
60
60
|
it "indexs the rdf properties" do
|
|
61
|
-
expect(
|
|
61
|
+
expect(solr_doc).to include('title_tesim' => ['first title'], 'abstract_ssi' => 'The abstract')
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it "adds id, system_create_date, system_modified_date from object attributes" do
|
|
@@ -72,15 +72,15 @@ describe ActiveFedora::Indexing do
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
context "with attached files" do
|
|
75
|
-
let(:mock1) {
|
|
76
|
-
let(:mock2) {
|
|
75
|
+
let(:mock1) { instance_double(ActiveFedora::File) }
|
|
76
|
+
let(:mock2) { instance_double(ActiveFedora::File) }
|
|
77
77
|
|
|
78
78
|
it "calls .to_solr on all datastreams, passing the resulting document to solr" do
|
|
79
79
|
expect(mock1).to receive(:to_solr).and_return("one" => "title one")
|
|
80
80
|
expect(mock2).to receive(:to_solr).and_return("two" => "title two")
|
|
81
81
|
|
|
82
82
|
allow(test_object).to receive(:declared_attached_files).and_return(ds1: mock1, ds2: mock2)
|
|
83
|
-
expect(
|
|
83
|
+
expect(solr_doc).to include('one' => 'title one', 'two' => 'title two')
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
end
|
|
@@ -2,28 +2,32 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe ActiveFedora::Base do
|
|
4
4
|
before do
|
|
5
|
-
class MyDS < ActiveFedora::
|
|
5
|
+
class MyDS < ActiveFedora::File
|
|
6
6
|
end
|
|
7
|
+
|
|
8
|
+
class MySample < ActiveFedora::File
|
|
9
|
+
end
|
|
10
|
+
|
|
7
11
|
class Foo < ActiveFedora::Base
|
|
8
12
|
has_subresource 'foostream', class_name: 'MyDS'
|
|
9
|
-
has_subresource 'dcstream', class_name: '
|
|
13
|
+
has_subresource 'dcstream', class_name: 'MySample'
|
|
10
14
|
end
|
|
15
|
+
|
|
11
16
|
class Bar < ActiveFedora::Base
|
|
12
17
|
has_subresource 'barstream', class_name: 'MyDS'
|
|
13
18
|
end
|
|
14
19
|
end
|
|
20
|
+
let(:f) { Foo.new }
|
|
21
|
+
subject(:attached_files) { f.attached_files }
|
|
15
22
|
|
|
16
23
|
it "doesn't overwrite stream specs" do
|
|
17
|
-
|
|
18
|
-
expect(f.attached_files.size).to eq 2
|
|
19
|
-
streams = f.attached_files.values.map { |x| x.class.to_s }.sort
|
|
20
|
-
expect(streams.pop).to eq "MyDS"
|
|
21
|
-
expect(streams.pop).to eq "ActiveFedora::QualifiedDublinCoreDatastream"
|
|
24
|
+
expect(attached_files.values).to match_array [MyDS, MySample]
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
after do
|
|
25
28
|
Object.send(:remove_const, :Bar)
|
|
26
29
|
Object.send(:remove_const, :Foo)
|
|
27
30
|
Object.send(:remove_const, :MyDS)
|
|
31
|
+
Object.send(:remove_const, :MySample)
|
|
28
32
|
end
|
|
29
33
|
end
|
|
@@ -23,17 +23,17 @@ describe ActiveFedora::LoadableFromJson::SolrBackedResource do
|
|
|
23
23
|
|
|
24
24
|
describe "#query" do
|
|
25
25
|
describe "a known relationship" do
|
|
26
|
-
subject { resource.query(predicate: ::RDF::Vocab::DC.extent) }
|
|
26
|
+
subject(:resources) { resource.query(predicate: ::RDF::Vocab::DC.extent) }
|
|
27
27
|
|
|
28
28
|
it "is enumerable" do
|
|
29
|
-
expect(
|
|
29
|
+
expect(resources.map(&:object)).to eq [RDF::URI('http://example.org/123')]
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
describe "a unknown relationship" do
|
|
34
|
-
subject { resource.query(predicate: ::RDF::Vocab::DC.accrualPeriodicity) }
|
|
34
|
+
subject(:resources) { resource.query(predicate: ::RDF::Vocab::DC.accrualPeriodicity) }
|
|
35
35
|
it "raises an error" do
|
|
36
|
-
expect {
|
|
36
|
+
expect { resources }.to raise_error "Unable to find reflection for http://purl.org/dc/terms/accrualPeriodicity in Foo"
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
end
|
data/spec/unit/logger_spec.rb
CHANGED
|
@@ -11,11 +11,11 @@ describe ActiveFedora::ModelClassifier do
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
let(:class_names) { ["ParentClass::SiblingClass", "ParentClass::OtherSiblingClass", "ParentClass::SubclassClass", "ParentClass::NoSuchClass"] }
|
|
14
|
-
subject { described_class.new class_names }
|
|
14
|
+
subject(:classifier) { described_class.new class_names }
|
|
15
15
|
|
|
16
16
|
describe ".class_from_string" do
|
|
17
17
|
it "returns class constants based on strings" do
|
|
18
|
-
expect(described_class.class_from_string("
|
|
18
|
+
expect(described_class.class_from_string("String")).to eq String
|
|
19
19
|
expect(described_class.class_from_string("ActiveFedora::RDF::IndexingService")).to eq ActiveFedora::RDF::IndexingService
|
|
20
20
|
expect(described_class.class_from_string("IndexingService", ActiveFedora::RDF)).to eq ActiveFedora::RDF::IndexingService
|
|
21
21
|
end
|
|
@@ -33,17 +33,17 @@ describe ActiveFedora::ModelClassifier do
|
|
|
33
33
|
|
|
34
34
|
describe '#models' do
|
|
35
35
|
it 'converts class names to classes' do
|
|
36
|
-
expect(
|
|
36
|
+
expect(classifier.models).to match_array [ParentClass::SiblingClass, ParentClass::OtherSiblingClass, ParentClass::SubclassClass]
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
describe '#best_model' do
|
|
41
41
|
it 'selects the most specific matching model' do
|
|
42
|
-
expect(
|
|
42
|
+
expect(classifier.best_model(default: nil)).to eq ParentClass::SubclassClass
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it 'filters models to subclasses of the default' do
|
|
46
|
-
expect(
|
|
46
|
+
expect(classifier.best_model(default: ActiveFedora::Base)).to eq ActiveFedora::Base
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
end
|