active-fedora 13.1.2 → 13.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.github_changelog_generator +2 -0
  3. data/CHANGELOG.md +3362 -0
  4. data/CONTRIBUTING.md +23 -1
  5. data/README.md +4 -0
  6. data/active-fedora.gemspec +14 -13
  7. data/lib/active_fedora/version.rb +1 -1
  8. metadata +104 -206
  9. data/spec/config_helper.rb +0 -17
  10. data/spec/fixtures/dino.jpg +0 -0
  11. data/spec/fixtures/dino_jpg_no_file_ext +0 -0
  12. data/spec/fixtures/minivan.jpg +0 -0
  13. data/spec/fixtures/rails_root/config/fake_fedora.yml +0 -7
  14. data/spec/fixtures/rails_root/config/fedora.yml +0 -12
  15. data/spec/fixtures/rails_root/config/solr.yml +0 -15
  16. data/spec/fixtures/rails_root/config/solr_mappings.yml +0 -16
  17. data/spec/fixtures/rails_root/config/solr_mappings_af_0.1.yml +0 -9
  18. data/spec/fixtures/rails_root/config/solr_mappings_bl_2.4.yml +0 -17
  19. data/spec/integration/associations/rdf_spec.rb +0 -61
  20. data/spec/integration/associations_spec.rb +0 -680
  21. data/spec/integration/attached_files_spec.rb +0 -146
  22. data/spec/integration/attributes_spec.rb +0 -73
  23. data/spec/integration/autosave_association_spec.rb +0 -24
  24. data/spec/integration/base_spec.rb +0 -184
  25. data/spec/integration/basic_contains_association_spec.rb +0 -121
  26. data/spec/integration/belongs_to_association_spec.rb +0 -260
  27. data/spec/integration/caching_spec.rb +0 -59
  28. data/spec/integration/clean_connection_spec.rb +0 -21
  29. data/spec/integration/collection_association_spec.rb +0 -166
  30. data/spec/integration/date_time_properties_spec.rb +0 -41
  31. data/spec/integration/delete_all_spec.rb +0 -64
  32. data/spec/integration/direct_container_spec.rb +0 -250
  33. data/spec/integration/directly_contains_one_association_spec.rb +0 -96
  34. data/spec/integration/eradicate_spec.rb +0 -52
  35. data/spec/integration/fedora_solr_sync_spec.rb +0 -30
  36. data/spec/integration/file_fixity_spec.rb +0 -36
  37. data/spec/integration/file_spec.rb +0 -221
  38. data/spec/integration/generators/fedora_generator_spec.rb +0 -26
  39. data/spec/integration/generators/solr_generator_spec.rb +0 -23
  40. data/spec/integration/gone_spec.rb +0 -41
  41. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +0 -414
  42. data/spec/integration/has_many_associations_spec.rb +0 -436
  43. data/spec/integration/has_subresource_spec.rb +0 -34
  44. data/spec/integration/indexing/descendant_fetcher_spec.rb +0 -64
  45. data/spec/integration/indexing_spec.rb +0 -110
  46. data/spec/integration/indirect_container_spec.rb +0 -290
  47. data/spec/integration/json_serialization_spec.rb +0 -32
  48. data/spec/integration/marshal_spec.rb +0 -39
  49. data/spec/integration/nested_attribute_spec.rb +0 -177
  50. data/spec/integration/nested_hash_resources_spec.rb +0 -43
  51. data/spec/integration/persistence_spec.rb +0 -37
  52. data/spec/integration/query_result_builder_spec.rb +0 -37
  53. data/spec/integration/rdf_nested_attributes_spec.rb +0 -85
  54. data/spec/integration/relation_delegation_spec.rb +0 -52
  55. data/spec/integration/relation_spec.rb +0 -117
  56. data/spec/integration/scoped_query_spec.rb +0 -134
  57. data/spec/integration/scoping_spec.rb +0 -48
  58. data/spec/integration/solr_hit_spec.rb +0 -32
  59. data/spec/integration/versionable_spec.rb +0 -256
  60. data/spec/integration/with_metadata_spec.rb +0 -111
  61. data/spec/lib/active_fedora/null_logger_spec.rb +0 -10
  62. data/spec/rcov.opts +0 -2
  63. data/spec/spec.opts +0 -5
  64. data/spec/spec_helper.rb +0 -106
  65. data/spec/support/an_active_model.rb +0 -29
  66. data/spec/unit/active_fedora/indexing/inserter_spec.rb +0 -35
  67. data/spec/unit/active_fedora_spec.rb +0 -118
  68. data/spec/unit/aggregation/list_source_spec.rb +0 -134
  69. data/spec/unit/aggregation/ordered_reader_spec.rb +0 -43
  70. data/spec/unit/association_hash_spec.rb +0 -64
  71. data/spec/unit/attached_files_spec.rb +0 -218
  72. data/spec/unit/attributes_spec.rb +0 -146
  73. data/spec/unit/base_active_model_spec.rb +0 -28
  74. data/spec/unit/base_cma_spec.rb +0 -15
  75. data/spec/unit/base_extra_spec.rb +0 -33
  76. data/spec/unit/base_spec.rb +0 -328
  77. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +0 -8
  78. data/spec/unit/callback_spec.rb +0 -65
  79. data/spec/unit/change_set_spec.rb +0 -60
  80. data/spec/unit/checksum_spec.rb +0 -25
  81. data/spec/unit/code_configurator_spec.rb +0 -41
  82. data/spec/unit/collection_proxy_spec.rb +0 -25
  83. data/spec/unit/config_spec.rb +0 -18
  84. data/spec/unit/core/fedora_id_translator_spec.rb +0 -29
  85. data/spec/unit/core/fedora_uri_translator_spec.rb +0 -19
  86. data/spec/unit/core/logger_spec.rb +0 -18
  87. data/spec/unit/core_spec.rb +0 -242
  88. data/spec/unit/default_model_mapper_spec.rb +0 -39
  89. data/spec/unit/fedora_spec.rb +0 -31
  90. data/spec/unit/file/streaming_spec.rb +0 -33
  91. data/spec/unit/file_configurator_spec.rb +0 -295
  92. data/spec/unit/file_io_spec.rb +0 -137
  93. data/spec/unit/file_path_builder_spec.rb +0 -18
  94. data/spec/unit/file_spec.rb +0 -489
  95. data/spec/unit/files_hash_spec.rb +0 -52
  96. data/spec/unit/filter_spec.rb +0 -133
  97. data/spec/unit/finder_methods_spec.rb +0 -154
  98. data/spec/unit/fixity_service_spec.rb +0 -128
  99. data/spec/unit/forbidden_attributes_protection_spec.rb +0 -50
  100. data/spec/unit/has_and_belongs_to_many_association_spec.rb +0 -125
  101. data/spec/unit/has_many_association_spec.rb +0 -131
  102. data/spec/unit/indexers/global_indexer_spec.rb +0 -41
  103. data/spec/unit/indexing/map/index_object_spec.rb +0 -25
  104. data/spec/unit/indexing/map_spec.rb +0 -27
  105. data/spec/unit/indexing_service_spec.rb +0 -28
  106. data/spec/unit/indexing_spec.rb +0 -86
  107. data/spec/unit/inheritance_spec.rb +0 -60
  108. data/spec/unit/ldp_resource_spec.rb +0 -15
  109. data/spec/unit/loadable_from_json_spec.rb +0 -40
  110. data/spec/unit/logger_spec.rb +0 -19
  111. data/spec/unit/model_classifier_spec.rb +0 -49
  112. data/spec/unit/ordered_spec.rb +0 -367
  113. data/spec/unit/orders/list_node_spec.rb +0 -151
  114. data/spec/unit/orders/ordered_list_spec.rb +0 -335
  115. data/spec/unit/orders/reflection_spec.rb +0 -22
  116. data/spec/unit/pathing_spec.rb +0 -35
  117. data/spec/unit/persistence_spec.rb +0 -115
  118. data/spec/unit/property_predicate_spec.rb +0 -35
  119. data/spec/unit/property_spec.rb +0 -25
  120. data/spec/unit/query_result_builder_spec.rb +0 -31
  121. data/spec/unit/query_spec.rb +0 -307
  122. data/spec/unit/querying_spec.rb +0 -24
  123. data/spec/unit/rdf/indexing_service_spec.rb +0 -114
  124. data/spec/unit/rdf_vocab_spec.rb +0 -30
  125. data/spec/unit/readonly_spec.rb +0 -24
  126. data/spec/unit/reflection_spec.rb +0 -42
  127. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +0 -37
  128. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +0 -38
  129. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +0 -38
  130. data/spec/unit/schema_indexing_strategy_spec.rb +0 -68
  131. data/spec/unit/scoping_spec.rb +0 -67
  132. data/spec/unit/serializers_spec.rb +0 -19
  133. data/spec/unit/solr_config_options_spec.rb +0 -57
  134. data/spec/unit/solr_hit_spec.rb +0 -57
  135. data/spec/unit/solr_query_builder_spec.rb +0 -18
  136. data/spec/unit/solr_service_spec.rb +0 -165
  137. data/spec/unit/sparql_insert_spec.rb +0 -31
  138. data/spec/unit/validations_spec.rb +0 -92
  139. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +0 -29
  140. data/spec/unit/with_metadata/metadata_node_spec.rb +0 -69
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Attributes, ".new" do
4
- before(:all) do
5
- class ProtectedParams < ActiveSupport::HashWithIndifferentAccess
6
- attr_accessor :permitted
7
- alias permitted? permitted
8
-
9
- def initialize(attributes)
10
- super(attributes)
11
- @permitted = false
12
- end
13
-
14
- def permit!
15
- @permitted = true
16
- self
17
- end
18
-
19
- def dup
20
- super.tap do |duplicate|
21
- duplicate.instance_variable_set :@permitted, @permitted
22
- end
23
- end
24
- end
25
-
26
- class Person < ActiveFedora::Base
27
- property :first_name, predicate: ::RDF::Vocab::FOAF.firstName, multiple: false
28
- property :gender, predicate: ::RDF::Vocab::FOAF.gender, multiple: false
29
- end
30
- end
31
-
32
- after(:all) do
33
- Object.send(:remove_const, :ProtectedParams)
34
- Object.send(:remove_const, :Person)
35
- end
36
-
37
- context "forbidden attributes" do
38
- let(:params) { ProtectedParams.new(first_name: 'Guille', gender: 'm') }
39
- it "cannot be used for mass assignment" do
40
- expect { Person.new(params) }.to raise_error ActiveModel::ForbiddenAttributesError
41
- end
42
- end
43
-
44
- context "permitted attributes" do
45
- let(:params) { ProtectedParams.new(first_name: 'Guille', gender: 'm').permit! }
46
- it "can be used for mass assignment" do
47
- expect { Person.new(params) }.not_to raise_error
48
- end
49
- end
50
- end
@@ -1,125 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Associations::HasAndBelongsToManyAssociation do
4
- context "creating the reflection" do
5
- before do
6
- class Book < ActiveFedora::Base
7
- end
8
- class Page < ActiveFedora::Base
9
- end
10
-
11
- allow(book).to receive(:new_record?).and_return(false)
12
- allow(book).to receive(:save).and_return(true)
13
- end
14
-
15
- after do
16
- Object.send(:remove_const, :Book)
17
- Object.send(:remove_const, :Page)
18
- end
19
-
20
- subject(:book) { Book.new(id: 'subject-a') }
21
-
22
- context "a one way relationship " do
23
- describe "adding memeber" do
24
- it "sets the relationship attribute" do
25
- reflection = ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Book)
26
- allow(ActiveFedora::SolrService).to receive(:query).and_return([])
27
- ac = described_class.new(book, reflection)
28
- expect(ac).to receive(:callback).twice
29
- object = Page.new
30
- allow(object).to receive(:new_record?).and_return(false)
31
- allow(object).to receive(:save).and_return(true)
32
- allow(object).to receive(:id).and_return('1234')
33
-
34
- allow(book).to receive(:[]).with('page_ids').and_return([])
35
- expect(book).to receive(:[]=).with('page_ids', ['1234'])
36
-
37
- ac.concat object
38
- end
39
- end
40
-
41
- describe "finding member" do
42
- let(:ids) { (0..15).map(&:to_s) }
43
- let(:reflection) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Book) }
44
- let(:association) { described_class.new(book, reflection) }
45
- it "calls ActiveFedora::Base.find" do
46
- expect(book).to receive(:[]).with('page_ids').and_return(ids)
47
- expect(ActiveFedora::Base).to receive(:find).with(ids)
48
- association.send(:find_target)
49
- end
50
- end
51
- end
52
-
53
- context "with an inverse reflection" do
54
- let!(:inverse) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :books, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection }, Page) }
55
- let(:reflection) { ActiveFedora::Reflection.create(:has_and_belongs_to_many, :pages, nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, inverse_of: 'books' }, Book) }
56
- let(:ac) { described_class.new(book, reflection) }
57
- let(:object) { Page.new }
58
-
59
- it "sets the relationship attribute on subject and object when inverse_of is given" do
60
- allow(ActiveFedora::SolrService).to receive(:query).and_return([])
61
- expect(ac).to receive(:callback).twice
62
- allow(object).to receive(:new_record?).and_return(false)
63
- allow(object).to receive(:save).and_return(true)
64
-
65
- allow(book).to receive(:[]).with('page_ids').and_return([])
66
- expect(book).to receive(:[]=).with('page_ids', [object.id])
67
-
68
- expect(object).to receive(:[]).with('book_ids').and_return([]).twice
69
- expect(object).to receive(:[]=).with('book_ids', [book.id])
70
-
71
- ac.concat object
72
- end
73
- end
74
- end
75
-
76
- context "class with association" do
77
- before do
78
- class Collection < ActiveFedora::Base
79
- has_and_belongs_to_many :members, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base", after_remove: :remove_member
80
- def remove_member(_m); end
81
- end
82
-
83
- class Thing < ActiveFedora::Base
84
- has_many :collections, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasCollectionMember, class_name: "ActiveFedora::Base"
85
- end
86
- end
87
-
88
- after do
89
- Collection.destroy_all
90
- Thing.destroy_all
91
-
92
- Object.send(:remove_const, :Collection)
93
- Object.send(:remove_const, :Thing)
94
- end
95
-
96
- context "with a new collection" do
97
- let(:collection) { Collection.new }
98
- it "has an empty list of collection members" do
99
- expect(collection.member_ids).to eq []
100
- expect(collection.members).to eq []
101
- end
102
- end
103
-
104
- context "with a persisted collection" do
105
- let(:collection) { Collection.create.tap { |c| c.members << thing } }
106
- let(:thing) { Thing.create }
107
-
108
- context "when the ids are set" do
109
- let(:thing2) { Thing.create }
110
- let(:thing3) { Thing.create }
111
-
112
- it "clears the object set" do
113
- expect(collection.members).to eq [thing]
114
- collection.member_ids = [thing2.id, thing3.id]
115
- expect(collection.members).to contain_exactly thing2, thing3
116
- end
117
- end
118
-
119
- it "calls destroy" do
120
- # this is a pretty weak test
121
- expect { collection.destroy }.to_not raise_error
122
- end
123
- end
124
- end
125
- end
@@ -1,131 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Associations::HasManyAssociation do
4
- before do
5
- class Book < ActiveFedora::Base
6
- end
7
- class Page < ActiveFedora::Base
8
- end
9
- end
10
-
11
- after do
12
- Object.send(:remove_const, :Book)
13
- Object.send(:remove_const, :Page)
14
- end
15
- let(:book) { Book.new(id: 'subject-a') }
16
- let(:page) { Page.new(id: 'object-b') }
17
-
18
- describe "setting the foreign key" do
19
- before do
20
- allow(book).to receive(:new_record?).and_return(false)
21
- allow(page).to receive(:save).and_return(true)
22
- allow(ActiveFedora::SolrService).to receive(:query).and_return([])
23
- end
24
-
25
- let(:reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
26
- let(:association) { described_class.new(book, reflection) }
27
-
28
- it "sets the book_id attribute" do
29
- expect(association).to receive(:callback).twice
30
- expect(page).to receive(:[]=).with('book_id', book.id)
31
- association.concat page
32
- end
33
- end
34
-
35
- describe "#find_polymorphic_inverse" do
36
- subject(:af_page) { association.send(:find_polymorphic_inverse, page) }
37
-
38
- let(:book_reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
39
- let(:association) { described_class.new(book, book_reflection) }
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
59
-
60
- it "finds the belongs_to reflection" do
61
- expect(af_page.name).to eq :bar
62
- end
63
- end
64
- end
65
-
66
- context "when inverse doesn't have a predictable name" do
67
- before do
68
- class TimeSpan < ActiveFedora::Base
69
- has_many :images, inverse_of: :created # predicate: ::RDF::Vocab::DC.created
70
- end
71
-
72
- class Image < ActiveFedora::Base
73
- has_and_belongs_to_many :created, predicate: ::RDF::Vocab::DC.created, class_name: 'TimeSpan'
74
- end
75
- end
76
-
77
- after do
78
- Object.send(:remove_const, :TimeSpan)
79
- Object.send(:remove_const, :Image)
80
- end
81
-
82
- let(:owner) { TimeSpan.new }
83
- let(:reflection) { TimeSpan._reflect_on_association(:images) }
84
-
85
- it "finds the predicate" do
86
- expect { described_class.new(owner, reflection) }.not_to raise_error
87
- end
88
- end
89
-
90
- describe "scope" do
91
- before do
92
- class Library < ActiveFedora::Base
93
- has_many :images
94
- end
95
-
96
- class Image < ActiveFedora::Base
97
- belongs_to :library, predicate: ::RDF::URI('http://example.com/library')
98
- end
99
- end
100
-
101
- after do
102
- Object.send(:remove_const, :Library)
103
- Object.send(:remove_const, :Image)
104
- end
105
-
106
- context "of an unsaved target" do
107
- subject { Library.new.images.scope }
108
- it { is_expected.to be_kind_of ActiveFedora::NullRelation }
109
- end
110
- end
111
-
112
- describe "#ids_reader" do
113
- let(:owner) { instance_double(ActiveFedora::Base) }
114
- let(:reflection) { instance_double(ActiveFedora::Reflection::AssociationReflection, check_validity!: true) }
115
- let(:association) { described_class.new(owner, reflection) }
116
-
117
- let(:r1) { ActiveFedora::Base.new(id: 'r1-id', &:mark_for_destruction) }
118
- let(:r2) { ActiveFedora::Base.new(id: 'r2-id') }
119
-
120
- context "when some records are marked_for_destruction" do
121
- before do
122
- allow(association).to receive(:loaded?).and_return(true)
123
- allow(association).to receive(:load_target).and_return([r1, r2])
124
- end
125
-
126
- it "only returns the records not marked for destruction" do
127
- expect(association.ids_reader).to eq ['r2-id']
128
- end
129
- end
130
- end
131
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::Indexers::GlobalIndexer do
4
- let(:global_indexer) { described_class.new(index_types) }
5
- let(:index_types) {}
6
-
7
- describe "#new" do
8
- # The global indexer acts as both an indexer factory and an indexer, since
9
- # the property doesn't matter.
10
- it "returns itself" do
11
- expect(global_indexer.new("bla")).to eq global_indexer
12
- end
13
- end
14
- describe "#index" do
15
- let(:index_obj) { instance_double(ActiveFedora::Indexing::Map::IndexObject, as: nil) }
16
- context "with one index type" do
17
- let(:index_types) { :symbol }
18
- it "passes that to index_obj" do
19
- global_indexer.index(index_obj)
20
-
21
- expect(index_obj).to have_received(:as).with(:symbol)
22
- end
23
- end
24
- context "with multiple index types" do
25
- let(:index_types) { [:symbol, :stored_searchable] }
26
- it "passes that to index_obj" do
27
- global_indexer.index(index_obj)
28
-
29
- expect(index_obj).to have_received(:as).with(:symbol, :stored_searchable)
30
- end
31
- end
32
- context "with no index types" do
33
- let(:global_indexer) { described_class.new }
34
- it "does not pass anything to index_obj" do
35
- global_indexer.index(index_obj)
36
-
37
- expect(index_obj).not_to have_received(:as)
38
- end
39
- end
40
- end
41
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::Indexing::Map::IndexObject do
4
- describe "with a block" do
5
- subject(:instance) do
6
- described_class.new(:name) do |index|
7
- index.as :stored_searchable, :facetable
8
- end
9
- end
10
-
11
- it "can set behaviors" do
12
- expect(instance.behaviors).to eq [:stored_searchable, :facetable]
13
- end
14
- end
15
-
16
- describe "with an initializer parameters" do
17
- subject(:instance) do
18
- described_class.new(:name, behaviors: [:stored_searchable, :facetable])
19
- end
20
-
21
- it "can set behaviors" do
22
- expect(instance.behaviors).to eq [:stored_searchable, :facetable]
23
- end
24
- end
25
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe ActiveFedora::Indexing::Map do
4
- describe ".merge" do
5
- subject(:merged) { first_map.merge(extra) }
6
- let(:index_object1) { instance_double(described_class::IndexObject) }
7
- let(:index_object2) { instance_double(described_class::IndexObject) }
8
- let(:index_object3) { instance_double(described_class::IndexObject) }
9
- let(:first_map) { described_class.new(one: index_object1, two: index_object2) }
10
-
11
- context "with a hash" do
12
- let(:extra) { { three: index_object3 } }
13
- it "merges with a hash" do
14
- expect(merged).to be_instance_of described_class
15
- expect(merged.keys).to match_array [:one, :two, :three]
16
- end
17
- end
18
-
19
- context "with another Indexing::Map" do
20
- let(:extra) { described_class.new(three: index_object3) }
21
- it "merges with the other map" do
22
- expect(merged).to be_instance_of described_class
23
- expect(merged.keys).to match_array [:one, :two, :three]
24
- end
25
- end
26
- end
27
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::IndexingService do
4
- let(:indexer) { described_class.new(object) }
5
- let(:object) { ActiveFedora::Base.new }
6
-
7
- describe "#generate_solr_document" do
8
- context "when no block is passed" do
9
- subject(:solr_doc) { indexer.generate_solr_document }
10
- it "produces a document" do
11
- expect(solr_doc['has_model_ssim']).to eq ['ActiveFedora::Base']
12
- end
13
- end
14
-
15
- context "when a block is passed" do
16
- subject(:solr_doc) do
17
- indexer.generate_solr_document do |solr_doc|
18
- solr_doc['noid'] = '12345'
19
- end
20
- end
21
-
22
- it "produces and yield the document" do
23
- expect(solr_doc['has_model_ssim']).to eq ['ActiveFedora::Base']
24
- expect(solr_doc['noid']).to eq '12345'
25
- end
26
- end
27
- end
28
- end
@@ -1,86 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::Indexing do
4
- describe '.indexer' do
5
- let(:indexing_class) { Class.new }
6
- let(:klass) { Class.new }
7
- before do
8
- klass.include described_class
9
- end
10
-
11
- it "is settable as a class attribute" do
12
- expect(klass.indexer).to eq ActiveFedora::IndexingService
13
- klass.indexer = indexing_class
14
- expect(klass.indexer).to eq indexing_class
15
- end
16
- end
17
-
18
- context "internal methods" do
19
- before :all do
20
- class SpecNode
21
- include ActiveFedora::Indexing
22
- end
23
- end
24
- after :all do
25
- Object.send(:remove_const, :SpecNode)
26
- end
27
-
28
- subject(:node) { SpecNode.new }
29
-
30
- describe "#create_needs_index?" do
31
- subject { SpecNode.new.send(:create_needs_index?) }
32
- it { is_expected.to be true }
33
- end
34
-
35
- describe "#update_needs_index?" do
36
- subject { SpecNode.new.send(:update_needs_index?) }
37
- it { is_expected.to be true }
38
- end
39
- end
40
-
41
- describe "#to_solr" do
42
- before :all do
43
- class SpecNode < ActiveFedora::Base
44
- property :title, predicate: ::RDF::Vocab::DC.title do |index|
45
- index.as :stored_searchable
46
- end
47
- property :abstract, predicate: ::RDF::Vocab::DC.abstract, multiple: false do |index|
48
- index.as :stored_sortable
49
- end
50
- end
51
- end
52
- after :all do
53
- Object.send(:remove_const, :SpecNode)
54
- end
55
-
56
- subject(:solr_doc) { test_object.to_solr }
57
- let(:test_object) { SpecNode.new(title: ['first title'], abstract: 'The abstract') }
58
-
59
- it "indexs the rdf properties" do
60
- expect(solr_doc).to include('title_tesim' => ['first title'], 'abstract_ssi' => 'The abstract')
61
- end
62
-
63
- it "adds id, system_create_date, system_modified_date from object attributes" do
64
- expect(test_object).to receive(:create_date).and_return(DateTime.parse("2012-03-04T03:12:02Z")).twice
65
- expect(test_object).to receive(:modified_date).and_return(DateTime.parse("2012-03-07T03:12:02Z")).twice
66
- allow(test_object).to receive(:id).and_return('changeme:123')
67
- solr_doc = test_object.to_solr
68
- expect(solr_doc[ActiveFedora.index_field_mapper.solr_name("system_create", :stored_sortable, type: :date)]).to eql("2012-03-04T03:12:02Z")
69
- expect(solr_doc[ActiveFedora.index_field_mapper.solr_name("system_modified", :stored_sortable, type: :date)]).to eql("2012-03-07T03:12:02Z")
70
- expect(solr_doc[:id]).to eql("changeme:123")
71
- end
72
-
73
- context "with attached files" do
74
- let(:mock1) { instance_double(ActiveFedora::File) }
75
- let(:mock2) { instance_double(ActiveFedora::File) }
76
-
77
- it "calls .to_solr on all datastreams, passing the resulting document to solr" do
78
- expect(mock1).to receive(:to_solr).and_return("one" => "title one")
79
- expect(mock2).to receive(:to_solr).and_return("two" => "title two")
80
-
81
- allow(test_object).to receive(:declared_attached_files).and_return(ds1: mock1, ds2: mock2)
82
- expect(solr_doc).to include('one' => 'title one', 'two' => 'title two')
83
- end
84
- end
85
- end
86
- end