active-fedora 7.0.0.rc2 → 7.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -3
  3. data/CONTRIBUTORS.md +1 -0
  4. data/Gemfile +2 -3
  5. data/active-fedora.gemspec +4 -3
  6. data/gemfiles/rails3.gemfile +1 -7
  7. data/gemfiles/rails4.1.gemfile +5 -0
  8. data/gemfiles/rails4.gemfile +1 -6
  9. data/lib/active_fedora.rb +6 -6
  10. data/lib/active_fedora/associations/association_scope.rb +1 -1
  11. data/lib/active_fedora/base.rb +2 -0
  12. data/lib/active_fedora/datastream.rb +29 -2
  13. data/lib/active_fedora/datastream_collections.rb +2 -2
  14. data/lib/active_fedora/datastream_hash.rb +1 -1
  15. data/lib/active_fedora/datastreams.rb +4 -23
  16. data/lib/active_fedora/file_configurator.rb +8 -7
  17. data/lib/active_fedora/om_datastream.rb +1 -1
  18. data/lib/active_fedora/rdf.rb +9 -0
  19. data/lib/active_fedora/rdf/configurable.rb +59 -0
  20. data/lib/active_fedora/rdf/identifiable.rb +59 -0
  21. data/lib/active_fedora/rdf/indexing.rb +24 -23
  22. data/lib/active_fedora/rdf/list.rb +154 -0
  23. data/lib/active_fedora/{ntriples_rdf_datastream.rb → rdf/ntriples_rdf_datastream.rb} +0 -0
  24. data/lib/active_fedora/rdf/object_resource.rb +20 -0
  25. data/lib/active_fedora/rdf/properties.rb +108 -0
  26. data/lib/active_fedora/rdf/rdf_datastream.rb +113 -0
  27. data/lib/active_fedora/{rdfxml_rdf_datastream.rb → rdf/rdfxml_rdf_datastream.rb} +0 -0
  28. data/lib/active_fedora/rdf/repositories.rb +36 -0
  29. data/lib/active_fedora/rdf/resource.rb +324 -0
  30. data/lib/active_fedora/rdf/term.rb +188 -0
  31. data/lib/active_fedora/relation.rb +1 -0
  32. data/lib/active_fedora/relation/finder_methods.rb +16 -17
  33. data/lib/active_fedora/relation/merger.rb +1 -1
  34. data/lib/active_fedora/relation/query_methods.rb +13 -5
  35. data/lib/active_fedora/reload_on_save.rb +16 -0
  36. data/lib/active_fedora/rubydora_connection.rb +0 -1
  37. data/lib/active_fedora/sharding.rb +1 -1
  38. data/lib/active_fedora/version.rb +1 -1
  39. data/script/console +10 -11
  40. data/spec/config_helper.rb +1 -1
  41. data/spec/fixtures/solr_rdf_descMetadata.nt +1 -1
  42. data/spec/integration/auditable_spec.rb +1 -1
  43. data/spec/integration/base_spec.rb +21 -3
  44. data/spec/integration/complex_rdf_datastream_spec.rb +32 -55
  45. data/spec/integration/field_to_solr_name_spec.rb +6 -8
  46. data/spec/integration/has_many_associations_spec.rb +10 -3
  47. data/spec/integration/load_from_solr_spec.rb +15 -17
  48. data/spec/integration/ntriples_datastream_spec.rb +19 -23
  49. data/spec/integration/om_datastream_spec.rb +1 -1
  50. data/spec/integration/rdf_nested_attributes_spec.rb +51 -70
  51. data/spec/integration/relation_spec.rb +24 -11
  52. data/spec/integration/scoped_query_spec.rb +5 -1
  53. data/spec/samples/hydra-mods_article_datastream.rb +4 -0
  54. data/spec/samples/hydra-rights_metadata_datastream.rb +5 -0
  55. data/spec/samples/marpa-dc_datastream.rb +6 -1
  56. data/spec/samples/special_thing.rb +5 -5
  57. data/spec/spec_helper.rb +0 -3
  58. data/spec/support/an_active_model.rb +5 -12
  59. data/spec/unit/active_fedora_spec.rb +2 -2
  60. data/spec/unit/attributes_spec.rb +4 -8
  61. data/spec/unit/base_datastream_management_spec.rb +5 -29
  62. data/spec/unit/base_spec.rb +4 -0
  63. data/spec/unit/code_configurator_spec.rb +2 -2
  64. data/spec/unit/config_spec.rb +2 -2
  65. data/spec/unit/core_spec.rb +2 -4
  66. data/spec/unit/datastream_spec.rb +15 -0
  67. data/spec/unit/datastreams_spec.rb +1 -12
  68. data/spec/unit/file_configurator_spec.rb +1 -1
  69. data/spec/unit/ntriples_datastream_spec.rb +52 -57
  70. data/spec/unit/om_datastream_spec.rb +3 -3
  71. data/spec/unit/query_spec.rb +3 -4
  72. data/spec/unit/rdf_configurable_spec.rb +37 -0
  73. data/spec/unit/rdf_datastream_spec.rb +5 -7
  74. data/spec/unit/rdf_list_nested_attributes_spec.rb +22 -36
  75. data/spec/unit/rdf_list_spec.rb +26 -38
  76. data/spec/unit/rdf_properties_spec.rb +70 -0
  77. data/spec/unit/rdf_repositories_spec.rb +28 -0
  78. data/spec/unit/rdf_resource_datastream_spec.rb +287 -0
  79. data/spec/unit/rdf_resource_spec.rb +341 -0
  80. data/spec/unit/rdfxml_rdf_datastream_spec.rb +10 -26
  81. data/spec/unit/reload_on_save_spec.rb +24 -0
  82. data/spec/unit/solr_service_spec.rb +3 -3
  83. metadata +45 -16
  84. data/lib/active_fedora/rdf_datastream.rb +0 -113
  85. data/lib/active_fedora/rdf_list.rb +0 -162
  86. data/lib/active_fedora/rdf_node.rb +0 -332
  87. data/lib/active_fedora/rdf_node/term_proxy.rb +0 -141
  88. data/lib/active_fedora/rdf_object.rb +0 -24
  89. data/lib/active_fedora/yaml_adaptor.rb +0 -12
  90. data/spec/unit/rdf_node_spec.rb +0 -36
@@ -57,6 +57,7 @@ module ActiveFedora
57
57
  args[:sort] = order_values if order_values
58
58
 
59
59
  @records = to_enum(:find_each, where_values, args).to_a
60
+ @loaded = true
60
61
 
61
62
  @records
62
63
  end
@@ -151,9 +151,8 @@ module ActiveFedora
151
151
  if where_values.empty?
152
152
  load_from_fedora(pid, cast)
153
153
  else
154
- query = [ActiveFedora::SolrService.construct_query_for_rel(where_values),
155
- ActiveFedora::SolrService.raw_query(SOLR_DOCUMENT_ID, pid)].
156
- join(" AND ".freeze)
154
+ conditions = where_values + [ActiveFedora::SolrService.raw_query(SOLR_DOCUMENT_ID, pid)]
155
+ query = conditions.join(" AND ".freeze)
157
156
  to_enum(:find_each, query, {}).to_a.first
158
157
  end
159
158
  end
@@ -196,18 +195,27 @@ module ActiveFedora
196
195
  # Returns a solr query for the supplied conditions
197
196
  # @param[Hash] conditions solr conditions to match
198
197
  def create_query(conditions)
199
- conditions.kind_of?(Hash) ? create_query_from_hash(conditions) : create_query_from_string(conditions)
198
+ case conditions
199
+ when Hash
200
+ build_query([create_query_from_hash(conditions)])
201
+ when String
202
+ build_query(["(#{conditions})"])
203
+ else
204
+ build_query(conditions)
205
+ end
200
206
  end
201
207
 
202
- def create_query_from_hash(conditions)
208
+ def build_query(conditions)
203
209
  clauses = search_model_clause ? [search_model_clause] : []
204
- conditions.each_pair do |key,value|
205
- clauses << condition_to_clauses(key, value)
206
- end
210
+ clauses += conditions.reject{|c| c.blank?}
207
211
  return "*:*" if clauses.empty?
208
212
  clauses.compact.join(" AND ")
209
213
  end
210
214
 
215
+ def create_query_from_hash(conditions)
216
+ conditions.map {|key,value| condition_to_clauses(key, value)}.compact.join(" AND ")
217
+ end
218
+
211
219
  def condition_to_clauses(key, value)
212
220
  unless value.nil?
213
221
  # if the key is a property name, turn it into a solr field
@@ -227,15 +235,6 @@ module ActiveFedora
227
235
  end
228
236
  end
229
237
 
230
- def create_query_from_string(conditions)
231
- model_clause = search_model_clause
232
- if model_clause
233
- conditions ? "#{model_clause} AND (#{conditions})" : model_clause
234
- else
235
- conditions
236
- end
237
- end
238
-
239
238
  # Return the solr clause that queries for this type of class
240
239
  def search_model_clause
241
240
  unless @klass == ActiveFedora::Base
@@ -14,7 +14,7 @@ module ActiveFedora
14
14
 
15
15
  def merge
16
16
  # TODO merge order
17
- relation.where_values = relation.where_values.merge(other.where_values)
17
+ relation.where_values += other.where_values
18
18
  relation
19
19
  end
20
20
  end
@@ -11,7 +11,7 @@ module ActiveFedora
11
11
  end
12
12
 
13
13
  def where_values
14
- @values[:where] ||= {}
14
+ @values[:where] ||= []
15
15
  end
16
16
 
17
17
  def where_values=(values)
@@ -49,12 +49,20 @@ module ActiveFedora
49
49
  end
50
50
 
51
51
  def where!(values)
52
- if values.is_a?(String)
53
- self.where_values = values
52
+ self.where_values += build_where(values)
53
+ self
54
+ end
55
+
56
+ def build_where(values)
57
+ return [] if values.blank?
58
+ case values
59
+ when Hash
60
+ [create_query_from_hash(values)]
61
+ when String
62
+ ["(#{values})"]
54
63
  else
55
- self.where_values = self.where_values.merge(values)
64
+ [values]
56
65
  end
57
- self
58
66
  end
59
67
 
60
68
  # Order the returned records by the field and direction provided
@@ -0,0 +1,16 @@
1
+ module ActiveFedora #:nodoc:
2
+ # = Active Fedora Reload On Save
3
+ module ReloadOnSave
4
+
5
+ attr_writer :reload_on_save
6
+
7
+ def reload_on_save?
8
+ !!@reload_on_save
9
+ end
10
+
11
+ def refresh
12
+ self.reload if reload_on_save?
13
+ end
14
+ end
15
+ end
16
+
@@ -15,7 +15,6 @@ module ActiveFedora
15
15
  return unless @connection.nil? or force
16
16
  allowable_options = [:url, :user, :password, :timeout, :open_timeout, :ssl_client_cert, :ssl_client_key, :validateChecksum]
17
17
  client_options = options.reject { |k,v| not allowable_options.include?(k) }
18
- #puts "CLIENT OPTS #{client_options.inspect}"
19
18
  @connection = Rubydora.connect client_options
20
19
 
21
20
  Rubydora::Transaction.after_rollback do |options|
@@ -8,7 +8,7 @@ module ActiveFedora
8
8
  end
9
9
 
10
10
  module ClassMethods
11
- # Uses {shard_index} to find or create the rubydora connection for this pid
11
+ # Uses {#shard_index} to find or create the rubydora connection for this pid
12
12
  # @param [String] pid the identifier of the object to get the connection for
13
13
  # @return [Rubydora::Repository] The repository that the identifier exists in.
14
14
  def connection_for_pid(pid)
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "7.0.0.rc2"
2
+ VERSION = "7.0.0.rc3"
3
3
  end
@@ -1,15 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
  # File: script/console
3
3
  irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
- ENV["RUBYLIB"] = "lib"
5
- libs = " -r irb/completion"
6
- libs << " -r rubygems"
7
- libs << " -r #{File.dirname(__FILE__) + '/../spec/spec_helper'}"
8
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/active_fedora.rb'}"
9
-
10
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
11
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
12
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/afed-regem.rb'}"
13
- # puts "Loading afed-regem gem"
14
- exec "#{irb} #{libs} --simple-prompt"
4
+
5
+ requires = %w{ irb/completion samples/samples }
6
+ includes = %w{ lib spec }
7
+
8
+ def to_param(flag, items)
9
+ items.map{|lib| "#{flag} #{lib}"}.join(' ')
10
+ end
11
+
12
+ exec "#{irb} #{to_param('-I', includes)} #{to_param('-r', requires)} --simple-prompt"
13
+
15
14
 
@@ -2,7 +2,7 @@ def mock_yaml(hash, path)
2
2
  mock_file = double(path.split("/")[-1])
3
3
  File.stub(:exist?).with(path).and_return(true)
4
4
  File.stub(:open).with(path).and_return(mock_file)
5
- YAMLAdaptor.stub(:load).and_return(hash)
5
+ Psych.stub(:load).and_return(hash)
6
6
  end
7
7
 
8
8
  def default_predicate_mapping_file
@@ -1,4 +1,4 @@
1
- <info:fedora/test:1> <http://purl.org/dc/terms/created> "2009-10-10" .
1
+ <info:fedora/test:1> <http://purl.org/dc/terms/created> "2009-10-10"^^<http://www.w3.org/2001/XMLSchema#date> .
2
2
  <info:fedora/test:1> <http://purl.org/dc/terms/title> "fake-title" .
3
3
  <info:fedora/test:1> <http://purl.org/dc/terms/publisher> "publisher1" .
4
4
  <info:fedora/test:1> <http://xmlns.com/foaf/0.1/based_near> "coverage1" .
@@ -22,7 +22,7 @@ describe ActiveFedora::Auditable do
22
22
  record.action.should == "addDatastream"
23
23
  record.component_id.should == "RELS-EXT"
24
24
  record.responsibility.should == "fedoraAdmin"
25
- record.date.should == @test_object.modified_date
25
+ expect(DateTime.parse(record.date)).to eq DateTime.parse(@test_object.modified_date)
26
26
  record.justification.should == ""
27
27
  end
28
28
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe "A base object with metadata" do
4
4
  before :all do
5
5
  class MockAFBaseRelationship < ActiveFedora::Base
6
- has_metadata :name=>'foo', :type=>Hydra::ModsArticleDatastream
6
+ has_metadata 'foo', type: Hydra::ModsArticleDatastream
7
7
  end
8
8
  end
9
9
  after :all do
@@ -20,7 +20,7 @@ describe "A base object with metadata" do
20
20
  obj = ActiveFedora::Base.find(@obj.pid)
21
21
  obj.foo.should_not be_new
22
22
  obj.foo.person.should == ['bob']
23
- person_field = ActiveFedora::SolrService.solr_name('person', type: :string)
23
+ person_field = ActiveFedora::SolrService.solr_name('foo__person', type: :string)
24
24
  solr_result = ActiveFedora::SolrService.query("{!raw f=id}#{@obj.pid}", :fl=>"id #{person_field}").first
25
25
  expect(solr_result).to eq("id"=>@obj.pid, person_field =>['bob'])
26
26
  end
@@ -51,7 +51,7 @@ describe "A base object with metadata" do
51
51
  end
52
52
  it "should save the datastream." do
53
53
  MockAFBaseRelationship.find(@release.pid).foo.person.should == ['frank']
54
- person_field = ActiveFedora::SolrService.solr_name('person', type: :string)
54
+ person_field = ActiveFedora::SolrService.solr_name('foo__person', type: :string)
55
55
  ActiveFedora::SolrService.query("id:#{@release.pid.gsub(":", "\\:")}", :fl=>"id #{person_field}").first.should == {"id"=>@release.pid, person_field =>['frank']}
56
56
  end
57
57
  end
@@ -248,6 +248,24 @@ describe ActiveFedora::Base do
248
248
  inner_object.pid.should == @test_object2.pid
249
249
  inner_object.should respond_to(:lastModifiedDate)
250
250
  end
251
+
252
+ it 'when the object is updated, it also updates modification time field in solr' do
253
+ @test_object2.save
254
+
255
+ # Make sure the modification time changes by at least 1 second
256
+ sleep 1
257
+
258
+ @test_object2.state = 'I'
259
+ @test_object2.save
260
+ @test_object2.reload
261
+
262
+ pid = @test_object2.pid.sub(':', '\:')
263
+ solr_doc = ActiveFedora::SolrService.query("id:#{pid}")
264
+
265
+ new_time_fedora = Time.parse(@test_object2.modified_date).to_i
266
+ new_time_solr = Time.parse(solr_doc.first['system_modified_dtsi']).to_i
267
+ new_time_solr.should == new_time_fedora
268
+ end
251
269
  end
252
270
 
253
271
  describe ".datastreams" do
@@ -2,29 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe "Nested Rdf Objects" do
4
4
  describe "without type" do
5
- before(:each) do
5
+ before(:each) do
6
6
  class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
7
- map_predicates do |map|
8
- map.parts(:in=> RDF::DC, :to=>'hasPart', :class_name=>'Component')
9
- end
7
+ property :parts, predicate: RDF::DC.hasPart, class_name: 'Component'
10
8
 
11
- class Component
12
- include ActiveFedora::RdfObject
13
- map_predicates do |map|
14
- map.label(:in=> RDF::DC, :to=>'title')
15
- end
9
+ class Component < ActiveFedora::Rdf::Resource
10
+ property :label, predicate: RDF::DC.title
16
11
  end
17
12
  end
18
13
 
19
14
  end
20
-
15
+
21
16
  after(:each) do
22
17
  Object.send(:remove_const, :SpecDatastream)
23
18
  end
24
19
 
25
20
  let (:ds) do
26
- mock_obj = double(:mock_obj, :pid=>'test:124', :new_record? => true)
27
- ds = SpecDatastream.new(mock_obj)
21
+ test_obj = ActiveFedora::Base.new(pid: 'test:124')
22
+ ds = SpecDatastream.new(test_obj, 'descMd')
28
23
  end
29
24
 
30
25
  describe "#new_record?" do
@@ -36,16 +31,11 @@ describe "Nested Rdf Objects" do
36
31
  it "should not be new when it's loaded from fedora" do
37
32
  ds.content = '_:g70324142325120 <http://purl.org/dc/terms/title> "Alternator" .
38
33
  <info:fedora/test:124> <http://purl.org/dc/terms/hasPart> _:g70324142325120 .'
34
+ ds.resource.persist!
39
35
  ds.parts.first.should_not be_new_record
40
36
  end
41
37
  end
42
38
 
43
- it "should not choke on invalid data" do
44
- # set a string in the graph where model expects a node
45
- ds.parts = ["foo"]
46
- expect {ds.parts.inspect}.to raise_error(ArgumentError, "Expected the value of http://purl.org/dc/terms/hasPart to be an RDF object but it is a String \"foo\"")
47
- end
48
-
49
39
  it "should be able to nest a complex object" do
50
40
  comp = SpecDatastream::Component.new(ds.graph)
51
41
  comp.label = ["Alternator"]
@@ -139,30 +129,25 @@ END
139
129
 
140
130
 
141
131
  describe "with type" do
142
- describe "one class per assertion" do
143
- before(:each) do
132
+ describe "one class per assertion" do
133
+ before(:each) do
144
134
  class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
145
- map_predicates do |map|
146
- map.mediator(:in=> RDF::DC, :class_name=>'MediatorUser')
147
- end
135
+ property :mediator, predicate: RDF::DC.mediator, class_name: 'MediatorUser'
148
136
 
149
- class MediatorUser
150
- include ActiveFedora::RdfObject
151
- rdf_type RDF::DC.AgentClass
152
- map_predicates do |map|
153
- map.title(:in=> RDF::DC)
154
- end
137
+ class MediatorUser < ActiveFedora::Rdf::Resource
138
+ configure type: RDF::DC.AgentClass
139
+ property :title, predicate: RDF::DC.title
155
140
  end
156
141
  end
157
142
  end
158
-
143
+
159
144
  after(:each) do
160
145
  Object.send(:remove_const, :SpecDatastream)
161
146
  end
162
147
 
163
148
  let (:ds) do
164
- mock_obj = double(:mock_obj, :pid=>'test:124', :new_record? => true)
165
- ds = SpecDatastream.new(mock_obj)
149
+ mock_obj = double(:mock_obj, pid: 'test:124', :new_record? => true)
150
+ ds = SpecDatastream.new(mock_obj, 'descMd')
166
151
  end
167
152
 
168
153
 
@@ -194,44 +179,36 @@ END
194
179
  end
195
180
 
196
181
  describe "shared assertion to different classes" do
197
- before(:each) do
182
+ before(:each) do
198
183
  class EbuCore < RDF::Vocabulary("http://www.ebu.ch/metadata/ontologies/ebucore#")
199
184
  property :isEpisodeOf
200
185
  property :title
201
186
  end
202
-
187
+
203
188
  class SpecDatastream < ActiveFedora::NtriplesRDFDatastream
204
- map_predicates do |map|
205
- map.series(:to => 'isEpisodeOf', :in=> EbuCore, :class_name=>'Series')
206
- map.program(:to => 'isEpisodeOf', :in=> EbuCore, :class_name=>'Program')
207
- end
189
+ property :series, predicate: EbuCore.isEpisodeOf, class_name: 'Series'
190
+ property :program, predicate: EbuCore.isEpisodeOf, class_name: 'Program'
208
191
 
209
- class Series
210
- include ActiveFedora::RdfObject
211
- rdf_type 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
212
- map_predicates do |map|
213
- map.title(:in=> EbuCore)
214
- end
192
+ class Series < ActiveFedora::Rdf::Resource
193
+ configure type: 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
194
+ property :title, predicate: EbuCore.title
215
195
  end
216
196
 
217
- class Program
218
- include ActiveFedora::RdfObject
219
- rdf_type 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
220
- map_predicates do |map|
221
- map.title(:in=> EbuCore)
222
- end
197
+ class Program < ActiveFedora::Rdf::Resource
198
+ configure type: 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
199
+ property :title, predicate: EbuCore.title
223
200
  end
224
201
  end
225
202
 
226
203
  end
227
-
204
+
228
205
  after(:each) do
229
206
  Object.send(:remove_const, :SpecDatastream)
230
207
  end
231
208
 
232
209
  let (:ds) do
233
- mock_obj = double(:mock_obj, :pid=>'test:124', :new_record? => true)
234
- ds = SpecDatastream.new(mock_obj)
210
+ mock_obj = double(:mock_obj, pid: 'test:124', :new_record? => true)
211
+ ds = SpecDatastream.new(mock_obj, 'descMd')
235
212
  end
236
213
 
237
214
 
@@ -245,9 +222,9 @@ END
245
222
  ds.program = program
246
223
 
247
224
  ds.program.first.type.size.should == 1
248
- ds.program.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
225
+ ds.program.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Programme'
249
226
  ds.series.first.type.size.should == 1
250
- ds.series.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
227
+ ds.series.first.type.first.to_s.should == 'http://www.ebu.ch/metadata/ontologies/ebucore#Series'
251
228
  end
252
229
 
253
230
  it "should create an object of the correct type" do
@@ -5,14 +5,12 @@ describe "An object with RDF backed attributes" do
5
5
  before do
6
6
  class TestOne < ActiveFedora::Base
7
7
  class MyMetadata < ActiveFedora::NtriplesRDFDatastream
8
- map_predicates do |map|
9
- map.title(in: RDF::DC) do |index|
10
- index.as :stored_searchable
11
- end
12
- map.date_uploaded(to: "dateSubmitted", in: RDF::DC) do |index|
13
- index.type :date
14
- index.as :stored_searchable, :sortable
15
- end
8
+ property :title, predicate: RDF::DC.title do |index|
9
+ index.as :stored_searchable
10
+ end
11
+ property :date_uploaded, predicate: RDF::DC.dateSubmitted do |index|
12
+ index.type :date
13
+ index.as :stored_searchable, :sortable
16
14
  end
17
15
  end
18
16
  has_metadata 'descMetadata', type: MyMetadata
@@ -7,7 +7,7 @@ describe "Looking up collection members" do
7
7
  end
8
8
 
9
9
  class Book < ActiveFedora::Base
10
- belongs_to :library, :property=>:has_constituent
10
+ belongs_to :library, property: :has_constituent
11
11
  end
12
12
  end
13
13
  after :all do
@@ -20,12 +20,19 @@ describe "Looking up collection members" do
20
20
  before do
21
21
  library.books = [book]
22
22
  library.save!
23
+ library.reload
23
24
  end
24
25
  it "should read book_ids from solr" do
25
- library.reload.book_ids.should ==[book.pid]
26
+ expect(library.book_ids).to eq [book.pid]
26
27
  end
27
28
  it "should read books from solr" do
28
- library.reload.books.should ==[book]
29
+ expect(library.books).to eq [book]
30
+ end
31
+
32
+ it "should cache the results" do
33
+ expect(library.books.loaded?).to be_false
34
+ expect(library.books).to eq [book]
35
+ expect(library.books.loaded?).to be_true
29
36
  end
30
37
  end
31
38
  end