active-fedora 10.1.0 → 11.1.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 (208) 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/.solr_wrapper +6 -0
  6. data/.travis.yml +6 -9
  7. data/Gemfile +1 -0
  8. data/History.txt +34 -0
  9. data/README.md +1 -3
  10. data/active-fedora.gemspec +7 -13
  11. data/lib/active_fedora/aggregation/list_source.rb +2 -0
  12. data/lib/active_fedora/associations/association_scope.rb +1 -1
  13. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  14. data/lib/active_fedora/associations/builder/association.rb +1 -1
  15. data/lib/active_fedora/associations/builder/orders.rb +11 -3
  16. data/lib/active_fedora/associations/collection_association.rb +5 -5
  17. data/lib/active_fedora/associations/collection_proxy.rb +10 -10
  18. data/lib/active_fedora/associations/contained_finder.rb +2 -2
  19. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
  20. data/lib/active_fedora/associations/has_many_association.rb +2 -2
  21. data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
  22. data/lib/active_fedora/associations/orders_association.rb +4 -0
  23. data/lib/active_fedora/associations/rdf.rb +2 -0
  24. data/lib/active_fedora/attribute_assignment.rb +0 -1
  25. data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
  26. data/lib/active_fedora/attribute_methods.rb +1 -1
  27. data/lib/active_fedora/attributes.rb +1 -1
  28. data/lib/active_fedora/base.rb +4 -8
  29. data/lib/active_fedora/change_set.rb +6 -2
  30. data/lib/active_fedora/cleaner.rb +1 -1
  31. data/lib/active_fedora/containers/container.rb +1 -1
  32. data/lib/active_fedora/core.rb +33 -30
  33. data/lib/active_fedora/fedora.rb +6 -2
  34. data/lib/active_fedora/fedora_attributes.rb +1 -1
  35. data/lib/active_fedora/file/streaming.rb +1 -1
  36. data/lib/active_fedora/file.rb +2 -1
  37. data/lib/active_fedora/file_configurator.rb +3 -3
  38. data/lib/active_fedora/indexing.rb +1 -18
  39. data/lib/active_fedora/indexing_service.rb +0 -9
  40. data/lib/active_fedora/initializing_connection.rb +1 -1
  41. data/lib/active_fedora/loadable_from_json.rb +12 -1
  42. data/lib/active_fedora/model_classifier.rb +1 -1
  43. data/lib/active_fedora/nested_attributes.rb +2 -2
  44. data/lib/active_fedora/null_logger.rb +10 -0
  45. data/lib/active_fedora/orders/list_node.rb +2 -2
  46. data/lib/active_fedora/orders/ordered_list.rb +8 -4
  47. data/lib/active_fedora/orders/target_proxy.rb +4 -0
  48. data/lib/active_fedora/querying.rb +1 -1
  49. data/lib/active_fedora/railtie.rb +2 -2
  50. data/lib/active_fedora/rake_support.rb +1 -1
  51. data/lib/active_fedora/rdf/field_map_entry.rb +6 -0
  52. data/lib/active_fedora/rdf/persistence.rb +1 -0
  53. data/lib/active_fedora/rdf/value_caster.rb +15 -0
  54. data/lib/active_fedora/rdf.rb +1 -1
  55. data/lib/active_fedora/relation/delegation.rb +4 -0
  56. data/lib/active_fedora/relation/finder_methods.rb +3 -1
  57. data/lib/active_fedora/solr_hit.rb +1 -14
  58. data/lib/active_fedora/solr_query_builder.rb +17 -13
  59. data/lib/active_fedora/version.rb +1 -1
  60. data/lib/active_fedora/with_metadata/metadata_node.rb +2 -1
  61. data/lib/active_fedora.rb +1 -12
  62. data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +11 -0
  63. data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
  64. data/lib/generators/active_fedora/model/model_generator.rb +1 -1
  65. data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
  66. data/lib/tasks/active_fedora_dev.rake +1 -1
  67. data/spec/config_helper.rb +1 -1
  68. data/spec/integration/associations_spec.rb +23 -24
  69. data/spec/integration/attached_files_spec.rb +19 -9
  70. data/spec/integration/attributes_spec.rb +12 -16
  71. data/spec/integration/autosave_association_spec.rb +6 -6
  72. data/spec/integration/base_spec.rb +8 -8
  73. data/spec/integration/basic_contains_association_spec.rb +1 -1
  74. data/spec/integration/clean_connection_spec.rb +1 -1
  75. data/spec/integration/collection_association_spec.rb +2 -5
  76. data/spec/integration/date_time_properties_spec.rb +1 -17
  77. data/spec/integration/direct_container_spec.rb +12 -12
  78. data/spec/integration/directly_contains_one_association_spec.rb +11 -13
  79. data/spec/integration/eradicate_spec.rb +1 -1
  80. data/spec/integration/fedora_solr_sync_spec.rb +2 -2
  81. data/spec/integration/file_fixity_spec.rb +6 -8
  82. data/spec/integration/file_spec.rb +37 -39
  83. data/spec/integration/generators/solr_generator_spec.rb +7 -10
  84. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +7 -7
  85. data/spec/integration/has_many_associations_spec.rb +9 -11
  86. data/spec/integration/indexing_spec.rb +2 -2
  87. data/spec/integration/indirect_container_spec.rb +11 -12
  88. data/spec/integration/json_serialization_spec.rb +4 -4
  89. data/spec/integration/query_result_builder_spec.rb +9 -21
  90. data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
  91. data/spec/integration/relation_delegation_spec.rb +8 -10
  92. data/spec/integration/relation_spec.rb +13 -16
  93. data/spec/integration/scoped_query_spec.rb +3 -3
  94. data/spec/integration/scoping_spec.rb +3 -3
  95. data/spec/integration/solr_hit_spec.rb +4 -15
  96. data/spec/integration/versionable_spec.rb +73 -327
  97. data/spec/integration/with_metadata_spec.rb +1 -1
  98. data/spec/spec_helper.rb +52 -10
  99. data/spec/unit/active_fedora_spec.rb +1 -1
  100. data/spec/unit/aggregation/list_source_spec.rb +37 -37
  101. data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
  102. data/spec/unit/association_hash_spec.rb +17 -31
  103. data/spec/unit/attached_files_spec.rb +35 -32
  104. data/spec/unit/attributes_spec.rb +25 -25
  105. data/spec/unit/base_active_model_spec.rb +8 -8
  106. data/spec/unit/base_cma_spec.rb +1 -1
  107. data/spec/unit/base_extra_spec.rb +7 -22
  108. data/spec/unit/base_spec.rb +21 -27
  109. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
  110. data/spec/unit/callback_spec.rb +2 -2
  111. data/spec/unit/change_set_spec.rb +5 -5
  112. data/spec/unit/checksum_spec.rb +2 -2
  113. data/spec/unit/code_configurator_spec.rb +1 -1
  114. data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
  115. data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
  116. data/spec/unit/core/logger_spec.rb +18 -0
  117. data/spec/unit/core_spec.rb +68 -32
  118. data/spec/unit/default_model_mapper_spec.rb +6 -6
  119. data/spec/unit/fedora_spec.rb +3 -4
  120. data/spec/unit/file_configurator_spec.rb +96 -96
  121. data/spec/unit/file_path_builder_spec.rb +3 -3
  122. data/spec/unit/file_spec.rb +93 -61
  123. data/spec/unit/files_hash_spec.rb +9 -9
  124. data/spec/unit/filter_spec.rb +3 -3
  125. data/spec/unit/finder_methods_spec.rb +3 -3
  126. data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
  127. data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
  128. data/spec/unit/has_many_association_spec.rb +28 -13
  129. data/spec/unit/indexers/global_indexer_spec.rb +6 -6
  130. data/spec/unit/indexing_service_spec.rb +5 -5
  131. data/spec/unit/indexing_spec.rb +8 -8
  132. data/spec/unit/inheritance_spec.rb +11 -7
  133. data/spec/unit/loadable_from_json_spec.rb +4 -4
  134. data/spec/unit/logger_spec.rb +1 -1
  135. data/spec/unit/model_classifier_spec.rb +5 -5
  136. data/spec/unit/ordered_spec.rb +144 -147
  137. data/spec/unit/orders/list_node_spec.rb +22 -22
  138. data/spec/unit/orders/ordered_list_spec.rb +96 -96
  139. data/spec/unit/orders/reflection_spec.rb +4 -4
  140. data/spec/unit/pathing_spec.rb +4 -4
  141. data/spec/unit/persistence_spec.rb +28 -28
  142. data/spec/unit/property_spec.rb +2 -2
  143. data/spec/unit/query_spec.rb +12 -12
  144. data/spec/unit/rdf/indexing_service_spec.rb +29 -29
  145. data/spec/unit/readonly_spec.rb +5 -4
  146. data/spec/unit/reflection_spec.rb +3 -3
  147. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
  148. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
  149. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
  150. data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
  151. data/spec/unit/serializers_spec.rb +3 -4
  152. data/spec/unit/solr_config_options_spec.rb +13 -16
  153. data/spec/unit/solr_hit_spec.rb +9 -9
  154. data/spec/unit/solr_service_spec.rb +4 -10
  155. data/spec/unit/sparql_insert_spec.rb +2 -2
  156. data/spec/unit/validations_spec.rb +12 -12
  157. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
  158. data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
  159. metadata +30 -130
  160. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
  161. data/lib/active_fedora/datastreams.rb +0 -6
  162. data/lib/active_fedora/nom_datastream.rb +0 -73
  163. data/lib/active_fedora/om_datastream.rb +0 -118
  164. data/lib/active_fedora/profile_indexing_service.rb +0 -11
  165. data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
  166. data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
  167. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
  168. data/lib/active_fedora/rdf/rdf_datastream.rb +0 -167
  169. data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
  170. data/lib/active_fedora/solr_instance_loader.rb +0 -47
  171. data/solr/config/_rest_managed.json +0 -3
  172. data/solr/config/admin-extra.html +0 -31
  173. data/solr/config/elevate.xml +0 -36
  174. data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
  175. data/solr/config/protwords.txt +0 -21
  176. data/solr/config/schema.xml +0 -372
  177. data/solr/config/scripts.conf +0 -24
  178. data/solr/config/solrconfig.xml +0 -311
  179. data/solr/config/spellings.txt +0 -2
  180. data/solr/config/stopwords.txt +0 -58
  181. data/solr/config/stopwords_en.txt +0 -58
  182. data/solr/config/synonyms.txt +0 -31
  183. data/solr/config/xslt/example.xsl +0 -132
  184. data/solr/config/xslt/example_atom.xsl +0 -67
  185. data/solr/config/xslt/example_rss.xsl +0 -66
  186. data/solr/config/xslt/luke.xsl +0 -337
  187. data/spec/fixtures/damsObjectModel.xml +0 -38
  188. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
  189. data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
  190. data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
  191. data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
  192. data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
  193. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
  194. data/spec/integration/ntriples_datastream_spec.rb +0 -203
  195. data/spec/integration/om_datastream_spec.rb +0 -78
  196. data/spec/integration/solr_instance_loader_spec.rb +0 -156
  197. data/spec/samples/hydra-mods_article_datastream.rb +0 -517
  198. data/spec/samples/models/mods_article.rb +0 -9
  199. data/spec/samples/oral_history_sample.xml +0 -38
  200. data/spec/samples/oral_history_xml.xml +0 -35
  201. data/spec/samples/samples.rb +0 -2
  202. data/spec/unit/nom_datastream_spec.rb +0 -60
  203. data/spec/unit/ntriples_datastream_spec.rb +0 -170
  204. data/spec/unit/om_datastream_spec.rb +0 -294
  205. data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
  206. data/spec/unit/rdf_datastream_spec.rb +0 -84
  207. data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
  208. data/spec/unit/rdfxml_datastream_spec.rb +0 -106
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "10.1.0".freeze
2
+ VERSION = "11.1.0".freeze
3
3
  end
@@ -10,6 +10,7 @@ module ActiveFedora
10
10
  # this class rather than being in the DefaultSchema.
11
11
  property :mime_type, predicate: ::RDF::Vocab::EBUCore.hasMimeType
12
12
 
13
+ # @param file [ActiveFedora::File]
13
14
  def initialize(file)
14
15
  @file = file
15
16
  super(file.uri, ldp_source.graph)
@@ -44,7 +45,7 @@ module ActiveFedora
44
45
 
45
46
  def save
46
47
  raise "Save the file first" if file.new_record?
47
- SparqlInsert.new(changes_for_update, ::RDF::URI.new(file.uri)).execute(metadata_uri)
48
+ SparqlInsert.new(changes_for_update, file.uri).execute(metadata_uri)
48
49
  @ldp_source = nil
49
50
  true
50
51
  end
data/lib/active_fedora.rb CHANGED
@@ -59,7 +59,6 @@ module ActiveFedora #:nodoc:
59
59
  autoload :DirectContainer
60
60
  autoload :IndirectContainer
61
61
  end
62
- autoload :Datastreams
63
62
  autoload :DelegatedAttribute
64
63
  autoload_under 'attributes' do
65
64
  autoload :ActiveTripleAttribute
@@ -89,24 +88,15 @@ module ActiveFedora #:nodoc:
89
88
  autoload :LoadableFromJson
90
89
  autoload :ModelClassifier
91
90
  autoload :NestedAttributes
92
- autoload :NomDatastream
93
91
  autoload :NullRelation
94
- autoload :OmDatastream
92
+ autoload :NullLogger
95
93
  autoload :Orders
96
94
  autoload :Pathing
97
95
  autoload :Persistence
98
- autoload :ProfileIndexingService
99
96
  autoload :Property
100
- autoload :QualifiedDublinCoreDatastream
101
97
  autoload :Querying
102
98
  autoload :QueryResultBuilder
103
99
  autoload :RDF
104
- autoload_under 'rdf' do
105
- autoload :RDFDatastream
106
- autoload :RDFXMLDatastream
107
- autoload :NtriplesRDFDatastream
108
- autoload :FedoraRdfResource
109
- end
110
100
  autoload :Reflection
111
101
  autoload :Relation
112
102
 
@@ -124,7 +114,6 @@ module ActiveFedora #:nodoc:
124
114
  autoload :Serialization
125
115
  autoload :SchemaIndexingStrategy
126
116
  autoload :SolrHit
127
- autoload :SolrInstanceLoader
128
117
  autoload :SolrQueryBuilder
129
118
  autoload :SolrService
130
119
  autoload :SparqlInsert
@@ -187,6 +187,17 @@
187
187
  </lst>
188
188
  </requestHandler>
189
189
 
190
+ <searchComponent name="termsComponent" class="solr.TermsComponent" />
191
+
192
+ <requestHandler name="/terms" class="solr.SearchHandler">
193
+ <lst name="defaults">
194
+ <bool name="terms">true</bool>
195
+ </lst>
196
+ <arr name="components">
197
+ <str>termsComponent</str>
198
+ </arr>
199
+ </requestHandler>
200
+
190
201
  <!-- Spell Check
191
202
 
192
203
  The spell check component can return a list of alternative spelling
@@ -1,5 +1,5 @@
1
1
  #config/solr_wrapper_test.yml
2
- # version: 6.0.0
2
+ # version: 6.1.0
3
3
  port: 8985
4
4
  instance_dir: tmp/solr-test
5
5
  collection:
@@ -7,7 +7,7 @@ module ActiveFedora
7
7
 
8
8
  class_option :directory, type: :string, default: 'models', desc: "Which directory to generate? (i.e. app/DIRECTORY)"
9
9
  class_option :datastream_directory, type: :string, default: 'models/datastreams', desc: "Which datastream directory to generate? (i.e. models/datastreams)"
10
- class_option :contains, type: :string, default: nil, desc: "Name a file to attach"
10
+ class_option :has_subresource, type: :string, default: nil, desc: "Name a file to attach"
11
11
  class_option :datastream, type: :string, default: nil, desc: "Name a metadata datastream to create"
12
12
 
13
13
  def install
@@ -2,7 +2,7 @@
2
2
  # `rails generate active_fedora:model <%= class_name %>`
3
3
  class <%= class_name %> < ActiveFedora::Base
4
4
  <% if options['datastream'] %>
5
- contains :descMetadata, class_name: "<%= options['datastream'] %>"
5
+ has_subresource :descMetadata, class_name: "<%= options['datastream'] %>"
6
6
  <% else %>
7
7
  # Define some properties to store:
8
8
  #
@@ -19,12 +19,12 @@ class <%= class_name %> < ActiveFedora::Base
19
19
  index.as :stored_searchable
20
20
  end
21
21
  <%- end -%>
22
- <% if options['contains'] %>
23
- contains :<%= options['contains'] %>"
22
+ <% if options['has_subresource'] %>
23
+ has_subresource :<%= options['has_subresource'] %>"
24
24
  <% else %>
25
25
  # Uncomment the following lines to add an #attachment method that is a file
26
26
  #
27
- # contains "attachment"
27
+ # has_subresource "attachment"
28
28
  <% end %>
29
29
  #
30
30
  # If you need to add additional attributes to the SOLR document, extend the default indexer:
@@ -43,9 +43,9 @@ namespace :active_fedora do
43
43
 
44
44
  desc "CI build"
45
45
  task :ci do
46
+ Rake::Task['active_fedora:rubocop'].invoke unless ENV['NO_RUBOCOP']
46
47
  ENV['environment'] = "test"
47
48
  with_test_server do
48
- Rake::Task['active_fedora:rubocop'].invoke unless ENV['NO_RUBOCOP']
49
49
  Rake::Task['active_fedora:coverage'].invoke
50
50
  end
51
51
  end
@@ -1,5 +1,5 @@
1
1
  def mock_yaml(hash, path)
2
- mock_file = double(path.split("/")[-1])
2
+ mock_file = instance_double(File, path.split("/")[-1])
3
3
  allow(File).to receive(:exist?).with(path).and_return(true)
4
4
  allow(File).to receive(:open).with(path).and_return(mock_file)
5
5
  allow(Psych).to receive(:load).and_return(hash)
@@ -17,7 +17,7 @@ describe ActiveFedora::Base do
17
17
  end
18
18
 
19
19
  let(:person) { Person.create }
20
- let(:book) { Book.new(author: person) }
20
+ subject(:book) { Book.new(author: person) }
21
21
 
22
22
  it "goes" do
23
23
  book.save
@@ -197,7 +197,7 @@ describe ActiveFedora::Base do
197
197
 
198
198
  it "lets you set an array of objects" do
199
199
  @library.books = [@book, @book2]
200
- expect(@library.books).to eq [@book, @book2]
200
+ expect(@library.books).to contain_exactly @book, @book2
201
201
  @library.save
202
202
 
203
203
  @library.books = [@book]
@@ -205,7 +205,7 @@ describe ActiveFedora::Base do
205
205
  end
206
206
  it "lets you set an array of object ids" do
207
207
  @library.book_ids = [@book.id, @book2.id]
208
- expect(@library.books).to eq [@book, @book2]
208
+ expect(@library.books).to contain_exactly @book, @book2
209
209
  end
210
210
 
211
211
  it "setter should wipe out previously saved relations" do
@@ -219,7 +219,7 @@ describe ActiveFedora::Base do
219
219
  @library.books = [@book, @book2]
220
220
  @library.save
221
221
  @library = Library.find(@library.id)
222
- expect(@library.books).to eq [@book, @book2]
222
+ expect(@library.books).to contain_exactly @book, @book2
223
223
  end
224
224
 
225
225
  it "lets you lookup an array of objects with solr" do
@@ -230,7 +230,7 @@ describe ActiveFedora::Base do
230
230
  @book2.save
231
231
 
232
232
  @library = Library.find(@library.id)
233
- expect(@library.books).to eq [@book, @book2]
233
+ expect(@library.books).to contain_exactly @book, @book2
234
234
 
235
235
  solr_resp = @library.books(response_format: :solr)
236
236
  expect(solr_resp.size).to eq 2
@@ -462,7 +462,7 @@ describe ActiveFedora::Base do
462
462
 
463
463
  it "loads the association stored in the parent" do
464
464
  @reloaded_course = Course.find(@course.id)
465
- expect(@reloaded_course.textbooks).to eq [@t1, @t2]
465
+ expect(@reloaded_course.textbooks).to contain_exactly @t1, @t2
466
466
  end
467
467
 
468
468
  it "allows a parent to be deleted from the has_many association" do
@@ -480,7 +480,7 @@ describe ActiveFedora::Base do
480
480
  @course.textbooks = [@t3, @t4]
481
481
  @course.save
482
482
 
483
- expect(@course.reload.textbooks).to eq [@t3, @t4]
483
+ expect(@course.reload.textbooks).to contain_exactly @t3, @t4
484
484
  end
485
485
 
486
486
  it "allows a child to be deleted from the has_and_belongs_to_many association" do
@@ -524,18 +524,19 @@ describe ActiveFedora::Base do
524
524
  end
525
525
 
526
526
  describe "removing association" do
527
- subject { LibraryBook.create }
528
- before do
529
- @p1 = Page.create
530
- @p2 = Page.create
531
- subject.pages << @p1 << @p2
532
- subject.save!
527
+ let(:p1) { Page.create }
528
+ let(:p2) { Page.create }
529
+ subject(:book) do
530
+ book = LibraryBook.create
531
+ book.pages << p1 << p2
532
+ book.save!
533
+ book
533
534
  end
534
535
  it "saves between the before and after hooks" do
535
- expect(subject).to receive(:before_count).with(1)
536
- expect(subject).to receive(:after_count).with(0)
537
- expect(subject).to receive(:say_hi).with(@p2).twice
538
- subject.pages.delete(@p2)
536
+ expect(book).to receive(:before_count).with(1)
537
+ expect(book).to receive(:after_count).with(0)
538
+ expect(book).to receive(:say_hi).with(p2).twice
539
+ book.pages.delete(p2)
539
540
  end
540
541
  end
541
542
  end
@@ -555,14 +556,12 @@ describe ActiveFedora::Base do
555
556
  end
556
557
 
557
558
  describe "removing association" do
558
- subject { LibraryBook.new }
559
- before do
560
- @p1 = subject.pages.build
561
- @p2 = subject.pages.build
562
- end
559
+ let(:p1) { book.pages.build }
560
+ let(:p2) { book.pages.build }
561
+ let(:book) { LibraryBook.new }
563
562
  it "runs the hooks" do
564
- expect(subject).to receive(:say_hi).with(@p2)
565
- subject.pages.delete(@p2)
563
+ expect(book).to receive(:say_hi).with(p2)
564
+ book.pages.delete(p2)
566
565
  end
567
566
  end
568
567
  end
@@ -46,7 +46,7 @@ describe ActiveFedora::AttachedFiles do
46
46
  Object.send(:remove_const, :DSTest)
47
47
  end
48
48
 
49
- it { should == 'XXX' }
49
+ it { is_expected.to eq('XXX') }
50
50
 
51
51
  context "After updating" do
52
52
  before do
@@ -65,30 +65,40 @@ describe ActiveFedora::AttachedFiles do
65
65
  let(:obj) { ActiveFedora::Base.new }
66
66
 
67
67
  describe ".attached_files" do
68
- subject { obj.attached_files }
68
+ subject(:attached_files) { obj.attached_files }
69
69
  it "returns a Hash of datastreams from fedora" do
70
- expect(subject).to be_a_kind_of(ActiveFedora::FilesHash)
71
- expect(subject).to be_empty
70
+ expect(attached_files).to be_a_kind_of(ActiveFedora::FilesHash)
71
+ expect(attached_files).to be_empty
72
72
  end
73
73
 
74
74
  it "initializes the datastream pointers with @new_object=false" do
75
- subject.each_value do |ds|
75
+ attached_files.each_value do |ds|
76
76
  expect(ds).to_not be_new
77
77
  end
78
78
  end
79
79
  end
80
80
 
81
81
  describe ".metadata_streams" do
82
- let(:mds1) { ActiveFedora::QualifiedDublinCoreDatastream.new }
83
- let(:mds2) { ActiveFedora::QualifiedDublinCoreDatastream.new }
84
- let(:fds) { ActiveFedora::File.new }
85
82
  before do
86
- fds = ActiveFedora::File.new
83
+ class Metadata < ActiveFedora::File
84
+ def metadata?
85
+ true
86
+ end
87
+ end
88
+
87
89
  obj.attach_file(mds1, 'md1')
88
90
  obj.attach_file(mds2, 'qdc')
89
91
  obj.attach_file(fds, 'fds')
90
92
  end
91
93
 
94
+ let(:mds1) { Metadata.new }
95
+ let(:mds2) { Metadata.new }
96
+ let(:fds) { ActiveFedora::File.new }
97
+
98
+ after do
99
+ Object.send(:remove_const, :Metadata)
100
+ end
101
+
92
102
  it "returns all of the datastreams from the object that are kinds of OmDatastream" do
93
103
  expect(obj.metadata_streams).to match_array [mds1, mds2]
94
104
  end
@@ -20,9 +20,9 @@ describe "delegating attributes" do
20
20
 
21
21
  describe "#index_config" do
22
22
  context "on a class with properties" do
23
- subject { RdfObject.index_config }
23
+ subject(:index_config) { RdfObject.index_config }
24
24
  it "has configuration" do
25
- expect(subject[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
25
+ expect(index_config[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
26
26
  end
27
27
  end
28
28
 
@@ -36,42 +36,38 @@ describe "delegating attributes" do
36
36
  Object.send(:remove_const, :InheritedObject)
37
37
  end
38
38
 
39
- subject { InheritedObject.index_config }
39
+ subject(:index_config) { InheritedObject.index_config }
40
40
 
41
41
  it "has configuration" do
42
- expect(subject[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
42
+ expect(index_config[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
43
43
  end
44
44
 
45
45
  context "when the inherited config is modifed" do
46
46
  before do
47
47
  InheritedObject.index_config[:resource_type].behaviors.delete(:stored_searchable)
48
48
  end
49
- subject { RdfObject.index_config }
49
+ subject(:index_config) { RdfObject.index_config }
50
50
 
51
51
  it "the parent config is unchanged" do
52
- expect(subject[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
52
+ expect(index_config[:resource_type].behaviors).to eq [:stored_searchable, :facetable]
53
53
  end
54
54
  end
55
55
  end
56
56
  end
57
57
 
58
58
  describe "previous_changes" do
59
- subject do
60
- TitledObject.create(title: ["Hydra for Dummies"])
61
- end
59
+ subject(:titled_object) { TitledObject.create(title: ["Hydra for Dummies"]) }
62
60
  it "keeps a list of changes after a successful save" do
63
- expect(subject.previous_changes).to_not be_empty
64
- expect(subject.previous_changes.keys).to include("title")
61
+ expect(titled_object.previous_changes).to_not be_empty
62
+ expect(titled_object.previous_changes.keys).to include("title")
65
63
  end
66
64
  end
67
65
 
68
66
  describe "#changes" do
69
- subject do
70
- TitledObject.create(title: ["Hydra for Dummies"])
71
- end
67
+ let(:titled_object) { TitledObject.create(title: ["Hydra for Dummies"]) }
72
68
  it "cleans out changes" do
73
- expect(subject).to_not be_title_changed
74
- expect(subject.changes).to be_empty
69
+ expect(titled_object).to_not be_title_changed
70
+ expect(titled_object.changes).to be_empty
75
71
  end
76
72
  end
77
73
  end
@@ -9,16 +9,16 @@ describe ActiveFedora::Base do
9
9
  Object.send(:remove_const, :MockAFBaseRelationship)
10
10
  end
11
11
 
12
- subject { MockAFBaseRelationship.new }
12
+ subject(:relationship) { MockAFBaseRelationship.new }
13
13
 
14
14
  context '#changed_for_autosave?' do
15
- before(:each) do
16
- expect(subject).to receive(:new_record?).and_return(false)
17
- expect(subject).to receive(:changed?).and_return(false)
18
- expect(subject).to receive(:marked_for_destruction?).and_return(false)
15
+ before do
16
+ expect(relationship).to receive(:new_record?).and_return(false)
17
+ expect(relationship).to receive(:changed?).and_return(false)
18
+ expect(relationship).to receive(:marked_for_destruction?).and_return(false)
19
19
  end
20
20
  it {
21
- expect { subject.changed_for_autosave? }.to_not raise_error
21
+ expect { relationship.changed_for_autosave? }.to_not raise_error
22
22
  }
23
23
  end
24
24
  end
@@ -48,12 +48,12 @@ describe ActiveFedora::Base do
48
48
 
49
49
  describe "#errors" do
50
50
  subject { obj.errors }
51
- it { should be_empty }
51
+ it { is_expected.to be_empty }
52
52
  end
53
53
 
54
54
  describe "#id" do
55
55
  subject { obj.id }
56
- it { should_not be_nil }
56
+ it { is_expected.to_not be_nil }
57
57
  end
58
58
 
59
59
  context "when updated with changes after one second" do
@@ -71,12 +71,12 @@ describe ActiveFedora::Base do
71
71
 
72
72
  describe "#create_date" do
73
73
  subject { obj.create_date }
74
- it { should_not be_nil }
74
+ it { is_expected.to_not be_nil }
75
75
  end
76
76
 
77
77
  describe "#modified_date" do
78
78
  subject { obj.modified_date }
79
- it { should_not be_nil }
79
+ it { is_expected.to_not be_nil }
80
80
  end
81
81
 
82
82
  describe "delete" do
@@ -130,7 +130,7 @@ describe ActiveFedora::Base do
130
130
  expect(described_class.exists?(obj.id)).to be true
131
131
  end
132
132
  it "returns false for ids that don't exist" do
133
- expect(described_class.exists?('test:missing_object')).to be false
133
+ expect(described_class.exists?('test_missing_object')).to be false
134
134
  end
135
135
  it "returns false for nil" do
136
136
  expect(described_class.exists?(nil)).to be false
@@ -145,7 +145,7 @@ describe ActiveFedora::Base do
145
145
  let(:conditions) { { foo: "bar" } }
146
146
  context "and at least one object matches the conditions" do
147
147
  it "returns true" do
148
- allow(ActiveFedora::SolrService).to receive(:query) { [double("solr document")] }
148
+ allow(ActiveFedora::SolrService).to receive(:query) { [instance_double(RSolr::HashWithResponse)] }
149
149
  expect(described_class.exists?(conditions)).to be true
150
150
  end
151
151
  end
@@ -159,7 +159,7 @@ describe ActiveFedora::Base do
159
159
  end
160
160
 
161
161
  describe "overriding resource_class_factory" do
162
- subject { TestBase.new }
162
+ subject(:test_base) { TestBase.new }
163
163
  before do
164
164
  class TestResource < ActiveTriples::Resource
165
165
  end
@@ -174,7 +174,7 @@ describe ActiveFedora::Base do
174
174
  Object.send(:remove_const, :TestBase)
175
175
  end
176
176
  it "uses that factory for #resource" do
177
- expect(subject.resource.class.ancestors).to include TestResource
177
+ expect(test_base.resource.class.ancestors).to include TestResource
178
178
  end
179
179
  end
180
180
  end
@@ -86,7 +86,7 @@ describe ActiveFedora::Base do
86
86
 
87
87
  it "has the two contained objects" do
88
88
  expect(model.contains.size).to eq 2
89
- expect(model.contains.map(&:title)).to eq [['title 1'], ['title 2']]
89
+ expect(model.contains.map(&:title)).to contain_exactly ['title 1'], ['title 2']
90
90
  end
91
91
  end
92
92
 
@@ -14,7 +14,7 @@ RSpec.describe ActiveFedora::CleanConnection do
14
14
  it "returns a clean graph" do
15
15
  graph = result.graph
16
16
  expect(graph.statements.to_a.length).to eq 1
17
- expect(graph.statements.to_a.first).to eq [asset.rdf_subject, RDF::Vocab::DC.title, "test"]
17
+ expect(graph.statements.to_a.first).to contain_exactly asset.rdf_subject, RDF::Vocab::DC.title, RDF::Literal.new("test")
18
18
  end
19
19
  end
20
20
  end
@@ -135,10 +135,9 @@ describe ActiveFedora::Base do
135
135
  end
136
136
 
137
137
  let(:instance) { SpecContainer.new }
138
- subject { instance.items }
139
138
 
140
139
  it "raises an error" do
141
- expect { subject }.to raise_error "No :inverse_of or :predicate attribute was set or could be inferred for has_many :items on SpecContainer"
140
+ expect { instance.items }.to raise_error "No :inverse_of or :predicate attribute was set or could be inferred for has_many :items on SpecContainer"
142
141
  end
143
142
  end
144
143
 
@@ -161,9 +160,7 @@ describe ActiveFedora::Base do
161
160
  let(:instance) { Foo::Container.new }
162
161
  subject { instance.items }
163
162
 
164
- it "finds the association" do
165
- expect(subject).to eq []
166
- end
163
+ it { is_expected.to eq [] }
167
164
  end
168
165
  end
169
166
  end
@@ -34,24 +34,8 @@ describe ActiveFedora::Base do
34
34
  describe 'serializing' do
35
35
  let(:object) { Foo.new(date: [date]) }
36
36
  let(:triple) { object.resource.query(predicate: ::RDF::Vocab::DC.date).to_a.first }
37
- subject { triple.to_s }
38
37
  it 'time zone must have semicolin to be a cannonical XMLSchema#dateTime' do
39
- expect(subject).to match(/\+01:00/)
40
- end
41
- end
42
-
43
- describe "saving and loading in Solr" do
44
- let(:object) { Foo.create!(date: [date], single_date: date2, empty_date: '', integer: 1) }
45
- before { allow(Deprecation).to receive(:warn) }
46
-
47
- let(:subject_solr) { object.class.load_instance_from_solr(object.id) }
48
- it "uses DateTime objects" do
49
- expect(subject_solr.date.first).to be_a DateTime
50
- expect(subject_solr.single_date).to be_a DateTime
51
- end
52
- it "loads the correct time" do
53
- expect(subject_solr.date.first).to eql date
54
- expect(subject_solr.single_date).to eql date2
38
+ expect(triple.to_s).to match(/\+01:00/)
55
39
  end
56
40
  end
57
41
  end
@@ -32,23 +32,23 @@ describe "Direct containers" do
32
32
  end
33
33
 
34
34
  describe "#first" do
35
- subject { reloaded.files.first }
35
+ subject(:first_file) { reloaded.files.first }
36
36
  it "has the content" do
37
- expect(subject.content).to eq 'HMMM'
37
+ expect(first_file.content).to eq 'HMMM'
38
38
  end
39
39
  end
40
40
 
41
41
  describe "#to_a" do
42
- subject { reloaded.files }
42
+ subject(:files) { reloaded.files }
43
43
  it "has the content" do
44
- expect(subject.to_a).to eq [file]
44
+ expect(files.to_a).to eq [file]
45
45
  end
46
46
  end
47
47
 
48
48
  describe "#append" do
49
49
  let(:file2) { o.files.build }
50
50
  it "has two files" do
51
- expect(o.files).to eq [file, file2]
51
+ expect(o.files).to contain_exactly file, file2
52
52
  end
53
53
 
54
54
  context "and then saved/reloaded" do
@@ -57,7 +57,7 @@ describe "Direct containers" do
57
57
  o.save!
58
58
  end
59
59
  it "has two files" do
60
- expect(reloaded.files).to eq [file, file2]
60
+ expect(reloaded.files).to contain_exactly file, file2
61
61
  end
62
62
  end
63
63
  end
@@ -102,9 +102,9 @@ describe "Direct containers" do
102
102
  end
103
103
 
104
104
  describe "#first" do
105
- subject { reloaded.files.first }
105
+ subject(:first_file) { reloaded.files.first }
106
106
  it "has the content" do
107
- expect(subject.content).to eq 'HMMM'
107
+ expect(first_file.content).to eq 'HMMM'
108
108
  end
109
109
  end
110
110
  end
@@ -140,9 +140,9 @@ describe "Direct containers" do
140
140
  end
141
141
 
142
142
  describe "#first" do
143
- subject { reloaded.files.first }
143
+ subject(:first_file) { reloaded.files.first }
144
144
  it "has the content" do
145
- expect(subject.content).to eq 'HMMM'
145
+ expect(first_file.content).to eq 'HMMM'
146
146
  end
147
147
  end
148
148
  end
@@ -171,7 +171,7 @@ describe "Direct containers" do
171
171
  end
172
172
 
173
173
  it "deletes the contained resource directly" do
174
- expect(history.files).to eq [file1, file2]
174
+ expect(history.files).to contain_exactly file1, file2
175
175
  file1.delete
176
176
  history.reload
177
177
  expect(history.files).to eq [file2]
@@ -191,7 +191,7 @@ describe "Direct containers" do
191
191
  end
192
192
 
193
193
  it "deletes the contained resource via the collection proxy" do
194
- expect(history.reload.files).to eq [file1, file2]
194
+ expect(history.reload.files).to contain_exactly file1, file2
195
195
  history.files.delete(file1)
196
196
  expect(history.reload.files).to eq [file2]
197
197
  end