diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-11-25 14:29:34 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-11-25 22:55:20 -0200 |
commit | 6fe1a4a2da5440aee91c4de387ffdf71b0b83a0e (patch) | |
tree | 7c648455a52abc85382753b8de456660993076c9 /activerecord/test/cases | |
parent | 83e71051258b98bd5c4df80b321c7b690ddcab35 (diff) | |
download | rails-6fe1a4a2da5440aee91c4de387ffdf71b0b83a0e.tar.gz rails-6fe1a4a2da5440aee91c4de387ffdf71b0b83a0e.tar.bz2 rails-6fe1a4a2da5440aee91c4de387ffdf71b0b83a0e.zip |
Merge pull request #8311 from alisdair/dirty-nullable-datetime
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.
Conflicts:
activerecord/CHANGELOG.md
activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
Diffstat (limited to 'activerecord/test/cases')
-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 4fc7e77786..86a28d95ad 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -201,6 +201,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 |