diff options
author | Alisdair McDiarmid <alisdair@mcdiarmid.org> | 2012-11-25 10:13:39 +0000 |
---|---|---|
committer | Alisdair McDiarmid <alisdair@mcdiarmid.org> | 2012-11-25 11:24:27 +0000 |
commit | fc4e387d7a478f75cdd4375b6c62e918b4b132b0 (patch) | |
tree | e993fe9626595504f388f4f3d8dd48c17a7faf94 /activerecord/test | |
parent | e95b9d6c68b1e0bba3840d18fc0aa94ccf88776d (diff) | |
download | rails-fc4e387d7a478f75cdd4375b6c62e918b4b132b0.tar.gz rails-fc4e387d7a478f75cdd4375b6c62e918b4b132b0.tar.bz2 rails-fc4e387d7a478f75cdd4375b6c62e918b4b132b0.zip |
Don't call will_change! for datetime nil->"".
Setting a nil datetime attribute to a blank string should not cause the
attribute to be dirty.
Fix #8310
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/dirty_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb index d4fc5f204b..6fd9a9d11d 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -203,6 +203,20 @@ class DirtyTest < ActiveRecord::TestCase end end + def test_nullable_datetime_not_marked_as_changed_if_new_value_is_blank + in_time_zone 'Edinburgh' do + target = Class.new(ActiveRecord::Base) + target.table_name = 'topics' + + topic = target.create + assert_equal nil, topic.written_on + + topic.written_on = "" + assert_equal nil, topic.written_on + assert !topic.written_on_changed? + end + end + def test_integer_zero_to_string_zero_not_marked_as_changed pirate = Pirate.new pirate.parrot_id = 0 |