aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/dirty_test.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-05-20 20:50:46 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-05-20 20:53:47 +0100
commit281edce6db8accc7d4a0e9ab01892631d9d0ebc3 (patch)
tree6d56e7bae4636d1cab9da18c8880880206c2bfa1 /activerecord/test/cases/dirty_test.rb
parent73c59638549686fccc749ffd3ac53cb533c5fd61 (diff)
downloadrails-281edce6db8accc7d4a0e9ab01892631d9d0ebc3.tar.gz
rails-281edce6db8accc7d4a0e9ab01892631d9d0ebc3.tar.bz2
rails-281edce6db8accc7d4a0e9ab01892631d9d0ebc3.zip
Ensure nil to '' doesn't get recorded by dirty for nullable integer columns. [#150 state:resolved] [Jason Dew, Pratik]
Diffstat (limited to 'activerecord/test/cases/dirty_test.rb')
-rw-r--r--activerecord/test/cases/dirty_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index 1266eb5036..62178977f9 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -44,6 +44,16 @@ class DirtyTest < ActiveRecord::TestCase
assert_nil pirate.catchphrase_change
end
+ def test_nullable_integer_not_marked_as_changed_if_new_value_is_blank
+ pirate = Pirate.new
+
+ ["", nil].each do |value|
+ pirate.parrot_id = value
+ assert !pirate.parrot_id_changed?
+ assert_nil pirate.parrot_id_change
+ end
+ end
+
def test_object_should_be_changed_if_any_attribute_is_changed
pirate = Pirate.new
assert !pirate.changed?