active-fedora 4.5.2 → 4.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,8 @@ module ActiveFedora
5
5
 
6
6
  module DatastreamBootstrap
7
7
  def datastream_object_for dsid, ds_spec=nil
8
- ds_spec ||= original_class.ds_specs[dsid] || {}
8
+ # ds_spec is nil when called from Rubydora for existing datastreams, so it should not be autocreated
9
+ ds_spec ||= (original_class.ds_specs[dsid] || {}).merge(:autocreate=>false)
9
10
  ds = ds_spec.fetch(:type, ActiveFedora::Datastream).new(self, dsid)
10
11
  attributes = {}
11
12
  attributes[:asOfDateTime] ||= asOfDateTime if self.respond_to? :asOfDateTime
@@ -20,7 +21,10 @@ module ActiveFedora
20
21
  attributes[:dsLocation]= ds_spec[:url]
21
22
  end
22
23
  ds.default_attributes = attributes
23
- ds.datastream_will_change! if ds_spec[:autocreate]
24
+ # would rather not load profile here in the call to .new?, so trusting :autocreate attribute
25
+ if ds_spec[:autocreate] # and ds.new?
26
+ ds.datastream_will_change!
27
+ end
24
28
  ds
25
29
  end
26
30
  end
@@ -46,6 +46,7 @@ module ActiveFedora
46
46
  end
47
47
  end
48
48
  tmpl.model.relationships_are_dirty = false
49
+ tmpl.changed_attributes.clear
49
50
  tmpl
50
51
  end
51
52
  end
@@ -30,7 +30,7 @@ module ActiveFedora
30
30
  # @param object Either a string URI or an object that is a kind of ActiveFedora::Base
31
31
  def add_relationship(predicate, target, literal=false)
32
32
  object_relations.add(predicate, target, literal)
33
- rels_ext.dirty = true
33
+ rels_ext.dirty = true if object_relations.dirty
34
34
  end
35
35
 
36
36
  # Clears all relationships with the specified predicate
@@ -39,7 +39,7 @@ module ActiveFedora
39
39
  relationships(predicate).each do |target|
40
40
  object_relations.delete(predicate, target)
41
41
  end
42
- rels_ext.dirty = true
42
+ rels_ext.dirty = true if object_relations.dirty
43
43
  end
44
44
 
45
45
  # Checks that this object is matches the model class passed in.
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "4.5.2"
2
+ VERSION = "4.5.3"
3
3
  end
@@ -52,6 +52,7 @@ describe ActiveFedora::Datastreams do
52
52
  before :all do
53
53
  class HasFile < ActiveFedora::Base
54
54
  has_file_datastream :name => "file_ds", :versionable => false
55
+ has_file_datastream :name => "file_ds2", :versionable => false, :autocreate => false
55
56
  end
56
57
  end
57
58
  after :all do
@@ -77,13 +78,23 @@ describe ActiveFedora::Datastreams do
77
78
  it "should create datastreams from the spec on new objects" do
78
79
  @has_file.file_ds.versionable.should be_false
79
80
  @has_file.file_ds.content = "blah blah blah"
81
+ @has_file.file_ds.changed?.should be_true
82
+ @has_file.file_ds2.changed?.should be_false # no autocreate
83
+ @has_file.file_ds2.new?.should be_true
80
84
  @has_file.save
81
85
  @has_file.file_ds.versionable.should be_false
82
- HasFile.find(@has_file.pid).file_ds.versionable.should be_false
86
+ test_obj = HasFile.find(@has_file.pid)
87
+ test_obj.file_ds.versionable.should be_false
88
+ test_obj.dc.changed?.should be_false
89
+ test_obj.rels_ext.changed?.should be_false
90
+ test_obj.file_ds.changed?.should be_false
91
+ test_obj.file_ds2.changed?.should be_false
92
+ test_obj.file_ds2.new?.should be_true
83
93
  end
84
94
 
85
95
  it "should use ds_specs on migrated objects" do
86
96
  test_obj = HasFile.find(@base.pid)
97
+ test_obj.dc.changed?.should be_false
87
98
  test_obj.file_ds.versionable.should be_false
88
99
  test_obj.file_ds.new?.should be_true
89
100
  test_obj.file_ds.content = "blah blah blah"
@@ -27,6 +27,9 @@ def restore_spec_configuration
27
27
  end
28
28
  restore_spec_configuration
29
29
 
30
+ # Shut those Rails deprecation warnings up
31
+ ActiveSupport::Deprecation.behavior= Proc.new { |message, callstack| }
32
+
30
33
  RSpec.configure do |config|
31
34
  config.mock_with :mocha
32
35
  config.color_enabled = true
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.5.2
4
+ version: 4.5.3
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-08-30 00:00:00.000000000 Z
14
+ date: 2012-10-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rsolr
@@ -520,21 +520,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
520
520
  - - ! '>='
521
521
  - !ruby/object:Gem::Version
522
522
  version: '0'
523
- segments:
524
- - 0
525
- hash: -146245566086376860
526
523
  required_rubygems_version: !ruby/object:Gem::Requirement
527
524
  none: false
528
525
  requirements:
529
526
  - - ! '>='
530
527
  - !ruby/object:Gem::Version
531
528
  version: '0'
532
- segments:
533
- - 0
534
- hash: -146245566086376860
535
529
  requirements: []
536
530
  rubyforge_project: rubyfedora
537
- rubygems_version: 1.8.23
531
+ rubygems_version: 1.8.24
538
532
  signing_key:
539
533
  specification_version: 3
540
534
  summary: A convenience libary for manipulating documents in the Fedora Repository.