cerealize 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +5 -1
- data/README +1 -1
- data/README.rdoc +1 -1
- data/cerealize.gemspec +1 -1
- data/lib/cerealize/attr_hash.rb +5 -2
- data/lib/cerealize/version.rb +1 -1
- data/test/real.rb +1 -0
- data/test/test_attr_hash.rb +15 -0
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
= cerealize changes history
|
2
2
|
|
3
|
+
== cerealize 0.8.6 -- 2010-09-29
|
4
|
+
|
5
|
+
* Make sure attr_hash didn't get saved setting the same value.
|
6
|
+
|
3
7
|
== cerealize 0.8.5 -- 2010-09-29
|
4
8
|
|
5
|
-
*
|
9
|
+
* Fixed a bug that nil can't be set in cerealized column.
|
6
10
|
This shows the bug:
|
7
11
|
|
8
12
|
apple = Apple.find(Apple.create(:data => [5]).id)
|
data/README
CHANGED
data/README.rdoc
CHANGED
data/cerealize.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cerealize}
|
5
|
-
s.version = "0.8.
|
5
|
+
s.version = "0.8.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Cardinal Blue", "Lin Jen-Shin (aka godfat 真常)", "Jaime Cham"]
|
data/lib/cerealize/attr_hash.rb
CHANGED
@@ -13,13 +13,16 @@ module Cerealize
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def #{attr}= value
|
16
|
+
self.#{property} ||= {}
|
17
|
+
|
16
18
|
# this line fixes the quirks in ActiveRecord 2.3.9 at
|
17
19
|
# activerecord-2.3.9/lib/active_record/associations/association_collection.rb:L352-L363
|
18
20
|
# when we're using associations and STI, thanks Jaime
|
19
21
|
# TODO: test for this?
|
20
|
-
#{property}_will_change! if
|
22
|
+
#{property}_will_change! if
|
23
|
+
respond_to?(:#{property}_will_change!) &&
|
24
|
+
#{property}[:#{attr}] != value
|
21
25
|
|
22
|
-
self.#{property} ||= {}
|
23
26
|
#{property}[:#{attr}] = value
|
24
27
|
end
|
25
28
|
RUBY
|
data/lib/cerealize/version.rb
CHANGED
data/test/real.rb
CHANGED
data/test/test_attr_hash.rb
CHANGED
@@ -25,6 +25,21 @@ class AttrHashTest < Test::Unit::TestCase
|
|
25
25
|
assert_nil Apple.new.data
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_dont_save_twice
|
29
|
+
apple = Apple.create(:name => 'banana')
|
30
|
+
assert apple.updated_at
|
31
|
+
|
32
|
+
Apple.record_timestamps = false
|
33
|
+
apple.update_attributes(:updated_at => nil)
|
34
|
+
Apple.record_timestamps = true
|
35
|
+
apple2 = Apple.find(apple.id)
|
36
|
+
assert_equal nil, apple2.updated_at
|
37
|
+
apple2.update_attributes :name => 'banana'
|
38
|
+
assert_equal nil, apple2.updated_at
|
39
|
+
apple2.update_attributes :name => 'pineapple'
|
40
|
+
assert apple2.updated_at
|
41
|
+
end
|
42
|
+
|
28
43
|
def simple_case hh, ah
|
29
44
|
assert_equal hh[:name], ah.name
|
30
45
|
assert_equal hh[:size], ah.size
|