diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-19 18:25:14 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-19 18:25:14 -0800 |
commit | 17064acb3e8a99b306924a5a01f64e1d734fe8ac (patch) | |
tree | b7d8ad621ad77742ac7bb35749f987b6c9efdff2 /activerecord | |
parent | be7d2248e9505983d1aacf0b33c657e6e3ddd9db (diff) | |
download | rails-17064acb3e8a99b306924a5a01f64e1d734fe8ac.tar.gz rails-17064acb3e8a99b306924a5a01f64e1d734fe8ac.tar.bz2 rails-17064acb3e8a99b306924a5a01f64e1d734fe8ac.zip |
adding tests for previous_changes hash
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index f5c139e85f..3ab6973549 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -187,6 +187,31 @@ class BasicsTest < ActiveRecord::TestCase end end + def test_previously_changed + topic = Topic.find :first + topic.title = '<3<3<3' + assert_equal({}, topic.previous_changes) + + topic.save! + expected = ["The First Topic", "<3<3<3"] + assert_equal(expected, topic.previous_changes['title']) + end + + def test_previously_changed_dup + topic = Topic.find :first + topic.title = '<3<3<3' + topic.save! + + t2 = topic.dup + + assert_equal(topic.previous_changes, t2.previous_changes) + + topic.title = "lolwut" + topic.save! + + assert_not_equal(topic.previous_changes, t2.previous_changes) + end + def test_preserving_time_objects assert_kind_of( Time, Topic.find(1).bonus_time, |