active-fedora 3.0.3 → 3.0.4

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.
@@ -1,3 +1,7 @@
1
+ 3.0.4
2
+
3
+ HYDRA-663 -- Passing an empty string to a id setter should clear the belongs to association
4
+
1
5
  3.0.3
2
6
 
3
7
  Added HasAndBelongsToManyAssociation
@@ -175,7 +175,8 @@ module ActiveFedora
175
175
  end
176
176
 
177
177
  redefine_method("#{reflection.name}_id=") do |new_value|
178
- send("#{reflection.name}=", reflection.klass.find(new_value))
178
+ obj = new_value.empty? ? nil : reflection.klass.find(new_value)
179
+ send("#{reflection.name}=", obj)
179
180
  end
180
181
  redefine_method("#{reflection.name}_id") do
181
182
  obj = send("#{reflection.name}")
@@ -1,3 +1,4 @@
1
+ #attribute_methods/write.rb
1
2
  module ActiveFedora
2
3
  module AttributeMethods
3
4
  extend ActiveSupport::Concern
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "3.0.3"
2
+ VERSION = "3.0.4"
3
3
  end
@@ -15,7 +15,7 @@ end
15
15
 
16
16
  describe ActiveFedora::Base do
17
17
  describe "an unsaved instance" do
18
- describe "of belongs_to" do
18
+ describe "of has_many" do
19
19
  before do
20
20
  @library = Library.new()
21
21
  @book = Book.new
@@ -56,11 +56,32 @@ describe ActiveFedora::Base do
56
56
  end
57
57
 
58
58
 
59
+
59
60
  after do
60
61
  @book.delete
61
62
  @book2.delete
62
63
  end
63
64
  end
65
+
66
+ describe "of belongs to" do
67
+ before do
68
+ @library = Library.new()
69
+ @library.save
70
+ @book = Book.new
71
+ @book.save
72
+ end
73
+ it "should be settable from the book side" do
74
+ @book.library_id = @library.pid
75
+ @book.library.pid.should == @library.pid
76
+ @book.attributes= {:library_id => ""}
77
+ @book.library_id.should be_nil
78
+ end
79
+ after do
80
+ @library.delete
81
+ @book.delete
82
+ end
83
+ end
84
+
64
85
  describe "of has_many_and_belongs_to" do
65
86
  before do
66
87
  @topic1 = Topic.new
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 3
10
- version: 3.0.3
9
+ - 4
10
+ version: 3.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-09-08 00:00:00 -05:00
19
+ date: 2011-09-16 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency