cerealize 0.8.5 → 0.8.6

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.
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
- * Fix a bug that nil can't be set in cerealized column.
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
@@ -1,4 +1,4 @@
1
- = cerealize 0.8.3
1
+ = cerealize 0.8.6
2
2
  by Cardinal Blue ( http://cardinalblue.com )
3
3
 
4
4
  == LINKS:
@@ -1,4 +1,4 @@
1
- = cerealize 0.8.3
1
+ = cerealize 0.8.6
2
2
  by Cardinal Blue ( http://cardinalblue.com )
3
3
 
4
4
  == LINKS:
@@ -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"
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"]
@@ -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 respond_to? :#{property}_will_change!
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
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Cerealize
3
- VERSION = '0.8.5'
3
+ VERSION = '0.8.6'
4
4
  end
@@ -64,4 +64,5 @@ end
64
64
 
65
65
  ActiveRecord::Base.connection.create_table :apples, :force => true do |t|
66
66
  t.text :data
67
+ t.timestamps :updated_at
67
68
  end
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 5
9
- version: 0.8.5
8
+ - 6
9
+ version: 0.8.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Cardinal Blue