diff options
author | Paul Gillard <paulmgillard@gmail.com> | 2009-08-04 16:23:08 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-08-04 16:23:08 -0500 |
commit | bada18dc36e3875dea1814ffaab1e8d1ac24b521 (patch) | |
tree | 0dabb989bcdb1379b28f19851fcf0a3e144c12bb /activerecord/test | |
parent | c30a0ce3c8f88baebd369180a6e221706e2b5cbf (diff) | |
download | rails-bada18dc36e3875dea1814ffaab1e8d1ac24b521.tar.gz rails-bada18dc36e3875dea1814ffaab1e8d1ac24b521.tar.bz2 rails-bada18dc36e3875dea1814ffaab1e8d1ac24b521.zip |
Added reset_attribute! method to ActiveRecord::AttributeMethods::Dirty which will reset an attribute to its original value should it have changed.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/dirty_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb index ac95bac4ad..1441421a80 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -62,6 +62,16 @@ class DirtyTest < ActiveRecord::TestCase assert_equal parrot.name_change, parrot.title_change end + def test_reset_attribute! + pirate = Pirate.create!(:catchphrase => 'Yar!') + pirate.catchphrase = 'Ahoy!' + + pirate.reset_catchphrase! + assert_equal "Yar!", pirate.catchphrase + assert_equal Hash.new, pirate.changes + assert !pirate.catchphrase_changed? + end + def test_nullable_number_not_marked_as_changed_if_new_value_is_blank pirate = Pirate.new |