active-fedora 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,42 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active-fedora (4.3.0)
4
+ active-fedora (4.4.0)
5
5
  activeresource (>= 3.0.0)
6
6
  activesupport (>= 3.0.0)
7
7
  equivalent-xml
8
8
  mediashelf-loggable
9
- mime-types (>= 1.16)
10
- multipart-post
11
- nokogiri
12
9
  om (~> 1.6.0)
13
10
  rdf
14
11
  rdf-rdfxml (~> 0.3.8)
15
12
  rsolr
16
- rubydora (~> 0.5.9)
13
+ rubydora (~> 0.5.10)
17
14
  solrizer (~> 1.2.0)
18
- xml-simple (>= 1.0.12)
19
15
 
20
16
  GEM
21
17
  remote: http://rubygems.org/
22
18
  specs:
23
19
  RedCloth (4.2.9)
24
- activemodel (3.2.3)
25
- activesupport (= 3.2.3)
20
+ activemodel (3.2.6)
21
+ activesupport (= 3.2.6)
26
22
  builder (~> 3.0.0)
27
- activeresource (3.2.3)
28
- activemodel (= 3.2.3)
29
- activesupport (= 3.2.3)
30
- activesupport (3.2.3)
23
+ activeresource (3.2.6)
24
+ activemodel (= 3.2.6)
25
+ activesupport (= 3.2.6)
26
+ activesupport (3.2.6)
31
27
  i18n (~> 0.6)
32
28
  multi_json (~> 1.0)
33
29
  addressable (2.2.8)
34
- akami (1.1.0)
30
+ akami (1.2.0)
35
31
  gyoku (>= 0.4.0)
36
- nokogiri (>= 1.5.2)
32
+ nokogiri (>= 1.4.0)
37
33
  backports (2.6.1)
38
34
  builder (3.0.0)
39
- childprocess (0.3.2)
35
+ childprocess (0.3.3)
40
36
  ffi (~> 1.0.6)
41
37
  columnize (0.3.6)
42
38
  daemons (1.1.8)
@@ -45,12 +41,12 @@ GEM
45
41
  nokogiri (>= 1.4.3)
46
42
  fastercsv (1.5.5)
47
43
  ffi (1.0.11)
48
- gyoku (0.4.5)
44
+ gyoku (0.4.6)
49
45
  builder (>= 2.1.2)
50
- httpi (1.0.0)
46
+ httpi (1.1.0)
51
47
  rack
52
48
  i18n (0.6.0)
53
- jettywrapper (1.2.1)
49
+ jettywrapper (1.3.0)
54
50
  activesupport (>= 3.0.0)
55
51
  childprocess
56
52
  i18n
@@ -61,21 +57,20 @@ GEM
61
57
  logger (1.2.8)
62
58
  mediashelf-loggable (0.4.9)
63
59
  metaclass (0.0.1)
64
- mime-types (1.18)
60
+ mime-types (1.19)
65
61
  mocha (0.10.5)
66
62
  metaclass (~> 0.0.1)
67
- multi_json (1.3.5)
68
- multipart-post (1.1.2)
69
- nokogiri (1.5.3)
63
+ multi_json (1.3.6)
64
+ nokogiri (1.5.5)
70
65
  nori (1.1.0)
71
- om (1.6.0)
66
+ om (1.6.1)
72
67
  mediashelf-loggable
73
68
  nokogiri (>= 1.4.2)
74
69
  rack (1.4.1)
75
70
  rake (0.9.2.2)
76
71
  rbx-require-relative (0.0.9)
77
72
  rcov (1.0.0)
78
- rdf (0.3.5.2)
73
+ rdf (0.3.7)
79
74
  addressable (>= 2.2.6)
80
75
  rdf-rdfxml (0.3.8)
81
76
  rdf (>= 0.3.4)
@@ -101,7 +96,7 @@ GEM
101
96
  ruby-debug-base (~> 0.10.4.0)
102
97
  ruby-debug-base (0.10.4)
103
98
  linecache (>= 0.3)
104
- rubydora (0.5.9)
99
+ rubydora (0.5.10)
105
100
  activemodel
106
101
  activesupport
107
102
  fastercsv
@@ -109,14 +104,14 @@ GEM
109
104
  nokogiri
110
105
  rest-client
111
106
  savon
112
- savon (0.9.14)
113
- akami (~> 1.1)
107
+ savon (1.1.0)
108
+ akami (~> 1.2.0)
114
109
  builder (>= 2.1.2)
115
- gyoku (>= 0.4.0)
116
- httpi (~> 1.0)
110
+ gyoku (~> 0.4.5)
111
+ httpi (~> 1.1.0)
117
112
  nokogiri (>= 1.4.0)
118
- nori (~> 1.1)
119
- wasabi (~> 2.2)
113
+ nori (~> 1.1.0)
114
+ wasabi (~> 2.5.0)
120
115
  simplecov (0.6.4)
121
116
  multi_json (~> 1.0)
122
117
  simplecov-html (~> 0.5.3)
@@ -130,11 +125,12 @@ GEM
130
125
  om (>= 1.5.0)
131
126
  stomp
132
127
  xml-simple
133
- stomp (1.2.2)
134
- wasabi (2.3.0)
128
+ stomp (1.2.4)
129
+ wasabi (2.5.0)
130
+ httpi (~> 1.0)
135
131
  nokogiri (>= 1.4.0)
136
132
  xml-simple (1.1.1)
137
- yard (0.8.1)
133
+ yard (0.8.2.1)
138
134
 
139
135
  PLATFORMS
140
136
  ruby
@@ -1,3 +1,11 @@
1
+ 4.4.0
2
+ Updated gem dependencies
3
+ Deprecated #find_by_solr()
4
+ Added compatibility with Rubydora 0.5.10
5
+ HYDRA-833 find_by_conditions should accept conditions as a string or a hash
6
+ HYDRA-696 ActiveModel::Dirty to track @ng_xml
7
+ HYDRA-830: Parsing has_model_s for model name
8
+
1
9
  4.3.0
2
10
  Added the #delegate_to method for easier delegation of multiple terms to the same datastream.
3
11
  Deprecated AF::Base#file_streams
@@ -16,17 +16,13 @@ Gem::Specification.new do |s|
16
16
  s.rubygems_version = %q{1.3.7}
17
17
 
18
18
  s.add_dependency('rsolr')
19
- s.add_dependency('xml-simple', '>= 1.0.12')
20
- s.add_dependency('mime-types', '>= 1.16')
21
- s.add_dependency('multipart-post')
22
- s.add_dependency('nokogiri')
23
19
  s.add_dependency('om', '~> 1.6.0')
24
20
  s.add_dependency('solrizer', '~>1.2.0')
25
21
  s.add_dependency("activeresource", '>= 3.0.0')
26
22
  s.add_dependency("activesupport", '>= 3.0.0')
27
23
  s.add_dependency("mediashelf-loggable")
28
24
  s.add_dependency("equivalent-xml")
29
- s.add_dependency("rubydora", '~>0.5.9')
25
+ s.add_dependency("rubydora", '~>0.5.10')
30
26
  s.add_dependency("rdf")
31
27
  s.add_dependency("rdf-rdfxml", '~>0.3.8')
32
28
  s.add_development_dependency("yard")
@@ -102,7 +102,7 @@ module ActiveFedora
102
102
  ## Replace existing unchanged datastreams with the definitions found in this class if they have a different type.
103
103
  ## Any datastream that is deleted here will cause a reload from fedora, so avoid it whenever possible
104
104
  ds_specs.keys.each do |key|
105
- if !@inner_object.datastreams[key].changed.include?(:content) && @inner_object.datastreams[key].class != self.class.ds_specs[key][:type]
105
+ if !@inner_object.datastreams[key].changed.include?('content') && @inner_object.datastreams[key].class != self.class.ds_specs[key][:type]
106
106
  @inner_object.datastreams.delete(key)
107
107
  end
108
108
  end
@@ -165,7 +165,6 @@ module ActiveFedora
165
165
  rels = Nokogiri::XML( rels_ext.content)
166
166
  rels.xpath("//rdf:Description/@rdf:about").first.value = new_object.internal_uri
167
167
  new_object.rels_ext.content = rels.to_xml
168
- new_object.rels_ext.dirty = false
169
168
 
170
169
  datastreams.each do |k, v|
171
170
  next if k == 'RELS-EXT'
@@ -389,16 +388,17 @@ module ActiveFedora
389
388
  # be loaded and if needed you should use find instead.
390
389
  def self.load_instance_from_solr(pid,solr_doc=nil)
391
390
  if solr_doc.nil?
392
- result = find_by_solr(pid)
393
- raise ActiveFedora::ObjectNotFoundError, "Object #{pid} not found in solr" if result.nil?
391
+ result = find_with_conditions(:id=>pid)
392
+ raise ActiveFedora::ObjectNotFoundError, "Object #{pid} not found in solr" if result.empty?
394
393
  solr_doc = result.first
395
394
  #double check pid and id in record match
396
395
  raise ActiveFedora::ObjectNotFoundError, "Object #{pid} not found in Solr" unless !result.nil? && !solr_doc.nil? && pid == solr_doc[SOLR_DOCUMENT_ID]
397
396
  else
398
397
  raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
399
398
  end
400
- klass = if class_str = solr_doc['active_fedora_model_s']
401
- class_str.first.constantize
399
+ klass = if class_str = solr_doc['has_model_s']
400
+ # Parse RDF string "info:fedora/afmodel:ActiveFedora_Base"
401
+ class_str.first.split(/:/).last.gsub(/_/,"::").constantize
402
402
  else
403
403
  ActiveFedora::Base
404
404
  end
@@ -4,13 +4,12 @@ module ActiveFedora
4
4
  class Datastream < Rubydora::Datastream
5
5
 
6
6
  attr_writer :digital_object
7
- attr_accessor :dirty, :last_modified, :fields
7
+ attr_accessor :last_modified, :fields
8
8
  before_create :add_mime_type, :add_ds_location, :validate_content_present
9
9
 
10
10
  def initialize(digital_object, dsid, options={})
11
11
  ## When you use the versions feature of rubydora (0.5.x), you need to have a 3 argument constructor
12
12
  self.fields={}
13
- self.dirty = false
14
13
  super
15
14
  end
16
15
 
@@ -39,8 +38,23 @@ module ActiveFedora
39
38
  end
40
39
 
41
40
  # Test whether this datastream been modified since it was last saved
41
+ # Deprecated
42
42
  def dirty?
43
- dirty || changed?
43
+ changed?
44
+ end
45
+
46
+ # Deprecated
47
+ def dirty
48
+ changed?
49
+ end
50
+
51
+ # Deprecated
52
+ def dirty=(value)
53
+ if value
54
+ lastModifiedDate_will_change! # an innocent hack to pretend something has changed
55
+ else
56
+ changed_attributes.clear
57
+ end
44
58
  end
45
59
 
46
60
  def new_object?
@@ -84,7 +98,6 @@ module ActiveFedora
84
98
  # @param [ActiveFedora::Datastream] tmpl the Datastream object that you are building
85
99
  # @param [Nokogiri::XML::Node] node the "foxml:datastream" node from a FOXML file
86
100
  def self.from_xml(tmpl, node)
87
- tmpl.instance_variable_set(:@dirty, false)
88
101
  tmpl.controlGroup= node['CONTROL_GROUP']
89
102
  tmpl
90
103
  end
@@ -178,10 +178,9 @@ module ActiveFedora
178
178
  # Get a count of the number of objects from solr
179
179
  # Takes :conditions as an argument
180
180
  def count(args = {})
181
- escaped_class_uri = SolrService.escape_uri_for_query(self.to_class_uri)
182
- q = "#{ActiveFedora::SolrService.solr_name(:has_model, :symbol)}:#{escaped_class_uri}"
183
- q << " AND #{args[:conditions]}" if args[:conditions]
184
- SolrService.query(q, :raw=>true, :rows=>0)['response']['numFound']
181
+ q = search_model_clause
182
+ q << " AND #{args[:conditions]}" if args[:conditions]
183
+ SolrService.query(q, :raw=>true, :rows=>0)['response']['numFound']
185
184
  end
186
185
 
187
186
  #@deprecated
@@ -191,7 +190,7 @@ module ActiveFedora
191
190
  SolrService.instance.conn.query(query, args)
192
191
  end
193
192
 
194
-
193
+ # @deprecated
195
194
  # If query is :all, this method will query Solr for all instances
196
195
  # of self.type (based on active_fedora_model_s as indexed
197
196
  # by Solr). If the query is any other string, this method simply does
@@ -203,6 +202,7 @@ module ActiveFedora
203
202
  # Args is an options hash, which is passed into the SolrService
204
203
  # connection instance.
205
204
  def find_by_solr(query, args={})
205
+ ActiveSupport::Deprecation.warn("find_by_fields_by_solr is deprecated and will be removed in 5.0. Use find_with_conditions instead.")
206
206
  if query == :all
207
207
  escaped_class_name = self.name.gsub(/(:)/, '\\:')
208
208
  SolrService.query("#{ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol)}:#{escaped_class_name}", args)
@@ -229,7 +229,7 @@ module ActiveFedora
229
229
  # :field_list => array, defaults to ["*", "score"]
230
230
  #
231
231
  def find_by_fields_by_solr(query_fields,opts={})
232
- ActiveSupport::Deprecation.warn("find_by_fields_by_solr is deprecated and will be removed in the next release")
232
+ ActiveSupport::Deprecation.warn("find_by_fields_by_solr is deprecated and will be removed in 5.0")
233
233
  #create solr_args from fields passed in, needs to be comma separated list of form field1=value1,field2=value2,...
234
234
  escaped_class_name = self.name.gsub(/(:)/, '\\:')
235
235
  query = "#{ActiveFedora::SolrService.solr_name(:active_fedora_model, :symbol)}:#{escaped_class_name}"
@@ -300,25 +300,46 @@ module ActiveFedora
300
300
  end
301
301
 
302
302
  # Returns a solr result matching the supplied conditions
303
- # @param[Hash] conditions solr conditions to match
303
+ # @param[Hash,String] conditions can either be specified as a string, or
304
+ # hash representing the query part of an solr statement. If a hash is
305
+ # provided, this method will generate conditions based simple equality
306
+ # combined using the boolean AND operator.
304
307
  # @param[Hash] options
305
308
  # @option opts [Array] :sort a list of fields to sort by
306
309
  # @option opts [Array] :rows number of rows to return
307
310
  def find_with_conditions(conditions, opts={})
308
- query = create_query(conditions)
309
311
  #set default sort to created date ascending
310
312
  unless opts.include?(:sort)
311
313
  opts[:sort]=[ActiveFedora::SolrService.solr_name(:system_create,:date)+' asc']
312
314
  end
313
- SolrService.query(query, opts)
315
+ SolrService.query(create_query(conditions), opts)
314
316
  end
315
317
 
316
-
318
+ def quote_for_solr(value)
319
+ '"' + value.gsub(/(:)/, '\\:').gsub(/"/, '\\"') + '"'
320
+ end
321
+
322
+ # @deprecated
323
+ def class_fields
324
+ #create dummy object that is empty by passing in fake pid
325
+ object = self.new()#{:pid=>'FAKE'})
326
+ fields = object.fields
327
+ #reset id to nothing
328
+ fields[:id][:values] = []
329
+ return fields
330
+ end
331
+
332
+ private
333
+
317
334
  # Returns a solr query for the supplied conditions
318
335
  # @param[Hash] conditions solr conditions to match
319
336
  def create_query(conditions)
320
- escaped_class_uri = SolrService.escape_uri_for_query(self.to_class_uri)
321
- clauses = ["#{ActiveFedora::SolrService.solr_name(:has_model, :symbol)}:#{escaped_class_uri}"]
337
+ return '' unless conditions
338
+ conditions.kind_of?(Hash) ? create_query_from_hash(conditions) : create_query_from_string(conditions)
339
+ end
340
+
341
+ def create_query_from_hash(conditions)
342
+ clauses = [search_model_clause]
322
343
  conditions.each_pair do |key,value|
323
344
  unless value.nil?
324
345
  if value.is_a? Array
@@ -333,24 +354,22 @@ module ActiveFedora
333
354
  end
334
355
  end
335
356
 
336
- clauses.join(" AND ")
357
+ clauses.compact.join(" AND ")
337
358
  end
338
359
 
339
- def quote_for_solr(value)
340
- '"' + value.gsub(/(:)/, '\\:').gsub(/"/, '\\"') + '"'
360
+ def create_query_from_string(conditions)
361
+ model_clause = search_model_clause
362
+ model_clause ? "#{model_clause} AND (#{conditions})" : conditions
341
363
  end
342
364
 
343
-
344
- def class_fields
345
- #create dummy object that is empty by passing in fake pid
346
- object = self.new()#{:pid=>'FAKE'})
347
- fields = object.fields
348
- #reset id to nothing
349
- fields[:id][:values] = []
350
- return fields
365
+ # Return the solr clause that queries for this type of class
366
+ def search_model_clause
367
+ unless self == ActiveFedora::Base
368
+ escaped_class_uri = SolrService.escape_uri_for_query(self.to_class_uri)
369
+ return "#{ActiveFedora::SolrService.solr_name(:has_model, :symbol)}:#{escaped_class_uri}"
370
+ end
351
371
  end
352
372
 
353
- private
354
373
  # Retrieve the Fedora object with the given pid, explore the returned object, determine its model
355
374
  # using #{ActiveFedora::ContentModel.known_models_for} and cast to that class.
356
375
  # Raises a ObjectNotFoundError if the object is not found.
@@ -41,7 +41,6 @@ module ActiveFedora
41
41
 
42
42
  def ng_xml
43
43
  @ng_xml ||= begin
44
- self.dirty = false
45
44
  self.xml_loaded = true
46
45
 
47
46
  if new?
@@ -54,8 +53,8 @@ module ActiveFedora
54
53
  end
55
54
 
56
55
  def ng_xml=(new_xml)
56
+ ng_xml_will_change!
57
57
  self.xml_loaded=true
58
- self.dirty = true
59
58
  case new_xml
60
59
  when Nokogiri::XML::Document
61
60
  @ng_xml = new_xml
@@ -68,6 +67,16 @@ module ActiveFedora
68
67
  end
69
68
  end
70
69
 
70
+ # don't want content eagerly loaded by proxy, so implementing methods that would be implemented by define_attribute_methods
71
+ def ng_xml_will_change!
72
+ changed_attributes['ng_xml'] = nil
73
+ end
74
+
75
+ # don't want content eagerly loaded by proxy, so implementing methods that would be implemented by define_attribute_methods
76
+ def ng_xml_changed?
77
+ changed_attributes.has_key? 'ng_xml'
78
+ end
79
+
71
80
  def content=(content)
72
81
  super
73
82
  self.xml_loaded=true
@@ -343,8 +352,8 @@ module ActiveFedora
343
352
  if @internal_solr_doc
344
353
  raise "No update performed, this object was initialized via Solr instead of Fedora and is therefore read-only. Please utilize ActiveFedora::Base.find to first load object via Fedora instead."
345
354
  else
355
+ ng_xml_will_change!
346
356
  result = om_update_values(params)
347
- self.dirty= true
348
357
  return result
349
358
  end
350
359
  end
@@ -13,6 +13,10 @@ module ActiveFedora
13
13
  def add_mime_type
14
14
  self.mimeType= 'application/rdf+xml'
15
15
  end
16
+
17
+ def changed?
18
+ model.relationships_are_dirty or super
19
+ end
16
20
 
17
21
  def serialize!
18
22
  self.content = to_rels_ext() if model.relationships_are_dirty
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "4.3.0"
2
+ VERSION = "4.4.0"
3
3
  end
@@ -420,10 +420,10 @@ describe ActiveFedora::Base do
420
420
 
421
421
  it "should delete the object from Fedora and Solr" do
422
422
  @test_object.save
423
- ActiveFedora::Base.find_by_solr(@test_object.pid).first["id"].should == @test_object.pid
423
+ ActiveFedora::Base.find_with_conditions(:id=>@test_object.pid).first["id"].should == @test_object.pid
424
424
  pid = @test_object.pid # store so we can access it after deletion
425
425
  @test_object.delete
426
- ActiveFedora::Base.find_by_solr(pid).should be_empty
426
+ ActiveFedora::Base.find_with_conditions(:id=>pid).should be_empty
427
427
  end
428
428
 
429
429
  describe '#delete' do
@@ -148,7 +148,7 @@ describe ActiveFedora::Base do
148
148
 
149
149
  @test_history.save
150
150
 
151
- @solr_result = OralHistory.find_by_solr(@test_history.pid)[0]
151
+ @solr_result = OralHistory.find_with_conditions(:id=>@test_history.pid)[0]
152
152
  @properties_sample_values.each_pair do |field, value|
153
153
  next if field == :hard_copy_availability #FIXME HYDRA-824
154
154
  next if field == :location #FIXME HYDRA-825
@@ -172,8 +172,8 @@ describe ActiveFedora::Base do
172
172
 
173
173
  end
174
174
 
175
- it "should support #find_by_solr" do
176
- solr_result = OralHistory.find(:all)
175
+ it "should support #find_with_conditions" do
176
+ solr_result = OralHistory.find_with_conditions({})
177
177
  solr_result.should_not be_nil
178
178
  end
179
179
 
@@ -19,7 +19,7 @@ describe ActiveFedora::NokogiriDatastream do
19
19
  describe '.term_values' do
20
20
  before do
21
21
  @pid = "hydrangea:fixture_mods_article1"
22
- @test_solr_object = HydrangeaArticle2.load_instance_from_solr(@pid)
22
+ @test_solr_object = ActiveFedora::Base.load_instance_from_solr(@pid)
23
23
  @test_object = HydrangeaArticle2.find(@pid)
24
24
  end
25
25
 
@@ -52,4 +52,18 @@ describe ActiveFedora::NokogiriDatastream do
52
52
  end
53
53
  end
54
54
 
55
+ describe '.update_values' do
56
+ before do
57
+ @pid = "hydrangea:fixture_mods_article1"
58
+ @test_object = HydrangeaArticle2.find(@pid)
59
+ end
60
+
61
+ it "should not be dirty after .update_values is saved" do
62
+ @test_object.datastreams["descMetadata"].update_values([{:name=>0},{:role=>0},:text] =>"Funder")
63
+ @test_object.datastreams["descMetadata"].dirty?.should be_true
64
+ @test_object.save
65
+ @test_object.datastreams["descMetadata"].dirty?.should be_false
66
+ @test_object.datastreams["descMetadata"].term_values({:name=>0},{:role=>0},:text).should == ["Funder"]
67
+ end
68
+ end
55
69
  end
@@ -114,16 +114,16 @@ describe ActiveFedora::RelsExtDatastream do
114
114
  model_rel = MockAFRelsSolr.to_class_uri
115
115
  #check inbound correct, testing goes to :has_part and testing2 goes to :has_member
116
116
  #get solr doc for @test_object2
117
- solr_doc = MockAFRelsSolr.find_by_solr(@test_object2.pid).first
117
+ solr_doc = MockAFRelsSolr.find_with_conditions(:id=>@test_object2.pid).first
118
118
  test_from_solr_object2 = MockAFRelsSolr.new
119
119
  test_from_solr_object2.rels_ext.from_solr(solr_doc)
120
- solr_doc = MockAFRelsSolr.find_by_solr(@test_object3.pid).first
120
+ solr_doc = MockAFRelsSolr.find_with_conditions(:id=>@test_object3.pid).first
121
121
  test_from_solr_object3 = MockAFRelsSolr.new
122
122
  test_from_solr_object3.rels_ext.from_solr(solr_doc)
123
- solr_doc = MockAFRelsSolr.find_by_solr(@test_object4.pid).first
123
+ solr_doc = MockAFRelsSolr.find_with_conditions(:id=>@test_object4.pid).first
124
124
  test_from_solr_object4 = MockAFRelsSolr.new
125
125
  test_from_solr_object4.rels_ext.from_solr(solr_doc)
126
- solr_doc = MockAFRelsSolr.find_by_solr(@test_object5.pid).first
126
+ solr_doc = MockAFRelsSolr.find_with_conditions(:id=>@test_object5.pid).first
127
127
  test_from_solr_object5 = MockAFRelsSolr.new
128
128
  test_from_solr_object5.rels_ext.from_solr(solr_doc)
129
129
 
@@ -18,7 +18,7 @@ describe ActiveFedora::Datastream do
18
18
  end
19
19
 
20
20
  it "should be inspectable" do
21
- @test_datastream.inspect.should match /#<ActiveFedora::Datastream:-?\d+ @pid=\"__DO_NOT_USE__\" @dsid=\"abcd\" @controlGroup=\"M\" @dirty=\"false\" @mimeType=\"\" >/
21
+ @test_datastream.inspect.should match /#<ActiveFedora::Datastream:-?\d+ @pid=\"__DO_NOT_USE__\" @dsid=\"abcd\" @controlGroup=\"M\" @dirty=\"true\" @mimeType=\"\" >/
22
22
  end
23
23
 
24
24
  describe '#validate_content_present' do
@@ -86,7 +86,7 @@ describe ActiveFedora::Datastream do
86
86
 
87
87
  describe ".dirty?" do
88
88
  it "should return the value of the @dirty attribute or changed?" do
89
- @test_datastream.expects(:changed?).returns(false)
89
+ @test_datastream.instance_variable_get(:@changed_attributes).clear
90
90
  @test_datastream.dirty?.should be_false
91
91
  @test_datastream.dirty = "boo"
92
92
  @test_datastream.dirty?.should be_true
@@ -177,8 +177,8 @@ describe ActiveFedora::Model do
177
177
  q.split(" AND ").include?("baz:\"quack\"")
178
178
  }.returns(mock_result)
179
179
  SpecModel::Basic.find_with_conditions(:foo=>'bar', :baz=>['quix','quack']).should == mock_result
180
-
181
180
  end
181
+
182
182
  it "should escape quotes" do
183
183
  mock_result = stub('Result')
184
184
  ActiveFedora::SolrService.expects(:query).with() { |args|
@@ -191,7 +191,17 @@ describe ActiveFedora::Model do
191
191
  q.split(" AND ").include?('baz:"quack"')
192
192
  }.returns(mock_result)
193
193
  SpecModel::Basic.find_with_conditions(:foo=>'9" Nails', :baz=>['7" version','quack']).should == mock_result
194
-
194
+ end
195
+
196
+ it "shouldn't use the class if it's called on AF:Base " do
197
+ mock_result = stub('Result')
198
+ ActiveFedora::SolrService.expects(:query).with('baz:"quack"', {:sort => ['system_create_dt asc']}).returns(mock_result)
199
+ ActiveFedora::Base.find_with_conditions(:baz=>'quack').should == mock_result
200
+ end
201
+ it "should use the query string if it's provided" do
202
+ mock_result = stub('Result')
203
+ ActiveFedora::SolrService.expects(:query).with('chunky:monkey', {:sort => ['system_create_dt asc']}).returns(mock_result)
204
+ ActiveFedora::Base.find_with_conditions('chunky:monkey').should == mock_result
195
205
  end
196
206
  end
197
207
 
@@ -215,8 +215,9 @@ describe ActiveFedora::NokogiriDatastream do
215
215
  it "should mark the datastream as dirty" do
216
216
  @test_ds2.dirty.should be_false
217
217
  @test_ds2.ng_xml = @sample_raw_xml
218
- @test_ds2.dirty.should be_true #not the same as be_dirty
218
+ @test_ds2.ng_xml_changed?.should be_true
219
219
  @test_ds2.should be_dirty
220
+ @test_ds2.instance_variable_get(:@content).should be_nil
220
221
  end
221
222
  end
222
223
 
@@ -19,12 +19,12 @@ describe ActiveFedora do
19
19
  @test_object = ActiveFedora::Base.new
20
20
  end
21
21
 
22
- after(:all) do
23
- # Revert to default mappings after running tests
24
- ActiveFedora::SolrService.load_mappings
25
- end
26
22
 
27
23
  describe "field name mappings" do
24
+ after(:all) do
25
+ # Revert to default mappings after running tests
26
+ ActiveFedora::SolrService.load_mappings
27
+ end
28
28
  it "should default to using the mappings for the current schema" do
29
29
  from_default_yml = YAML::load(File.open(File.join(File.dirname(__FILE__), "..", "..", "config", "solr_mappings.yml")))
30
30
  ActiveFedora::SolrService.mappings[:searchable].data_types[:date].opts[:suffix].should == from_default_yml["searchable"]["date"]
@@ -49,11 +49,11 @@ describe ActiveFedora do
49
49
  @test_object.to_solr[:id].should be_nil
50
50
  end
51
51
 
52
- it "should be used by ActiveFedora::Base#find_by_solr" do
52
+ it "should be used by ActiveFedora::Base#find_with_conditions" do
53
53
  mock_response = mock("SolrResponse")
54
- ActiveFedora::SolrService.expects(:query).with(SOLR_DOCUMENT_ID + ':changeme\:30', {}).returns(mock_response)
54
+ ActiveFedora::SolrService.expects(:query).with("has_model_s:info\\:fedora/afmodel\\:SolrSpecModel_Basic AND " + SOLR_DOCUMENT_ID + ':"changeme\\:30"', {:sort => ['system_create_dt asc']}).returns(mock_response)
55
55
 
56
- SolrSpecModel::Basic.find_by_solr("changeme:30").should equal(mock_response)
56
+ SolrSpecModel::Basic.find_with_conditions(:id=>"changeme:30").should equal(mock_response)
57
57
  end
58
58
  end
59
59
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-06-21 00:00:00.000000000 Z
14
+ date: 2012-06-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rsolr
@@ -29,70 +29,6 @@ dependencies:
29
29
  - - ! '>='
30
30
  - !ruby/object:Gem::Version
31
31
  version: '0'
32
- - !ruby/object:Gem::Dependency
33
- name: xml-simple
34
- requirement: !ruby/object:Gem::Requirement
35
- none: false
36
- requirements:
37
- - - ! '>='
38
- - !ruby/object:Gem::Version
39
- version: 1.0.12
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: 1.0.12
48
- - !ruby/object:Gem::Dependency
49
- name: mime-types
50
- requirement: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ! '>='
54
- - !ruby/object:Gem::Version
55
- version: '1.16'
56
- type: :runtime
57
- prerelease: false
58
- version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
63
- version: '1.16'
64
- - !ruby/object:Gem::Dependency
65
- name: multipart-post
66
- requirement: !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - ! '>='
70
- - !ruby/object:Gem::Version
71
- version: '0'
72
- type: :runtime
73
- prerelease: false
74
- version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- - !ruby/object:Gem::Dependency
81
- name: nokogiri
82
- requirement: !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :runtime
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
- requirements:
93
- - - ! '>='
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
32
  - !ruby/object:Gem::Dependency
97
33
  name: om
98
34
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +132,7 @@ dependencies:
196
132
  requirements:
197
133
  - - ~>
198
134
  - !ruby/object:Gem::Version
199
- version: 0.5.9
135
+ version: 0.5.10
200
136
  type: :runtime
201
137
  prerelease: false
202
138
  version_requirements: !ruby/object:Gem::Requirement
@@ -204,7 +140,7 @@ dependencies:
204
140
  requirements:
205
141
  - - ~>
206
142
  - !ruby/object:Gem::Version
207
- version: 0.5.9
143
+ version: 0.5.10
208
144
  - !ruby/object:Gem::Dependency
209
145
  name: rdf
210
146
  requirement: !ruby/object:Gem::Requirement
@@ -571,7 +507,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
571
507
  version: '0'
572
508
  segments:
573
509
  - 0
574
- hash: 801135923
510
+ hash: -160565939
575
511
  required_rubygems_version: !ruby/object:Gem::Requirement
576
512
  none: false
577
513
  requirements:
@@ -580,7 +516,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
580
516
  version: '0'
581
517
  segments:
582
518
  - 0
583
- hash: 801135923
519
+ hash: -160565939
584
520
  requirements: []
585
521
  rubyforge_project: rubyfedora
586
522
  rubygems_version: 1.8.24