aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-15 18:45:15 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-15 18:45:15 -0300
commit93e09f52781993f9f6b36af5b93e7d8892252271 (patch)
tree141dc9de75148f2d3a358a87e2524785e7a3e357 /activerecord/test
parent2b2e04150680498f043720de34f82e6dc647c14a (diff)
parent41fb06fa47b0c11d6b943163ec1bc8ce9fd4d229 (diff)
downloadrails-93e09f52781993f9f6b36af5b93e7d8892252271.tar.gz
rails-93e09f52781993f9f6b36af5b93e7d8892252271.tar.bz2
rails-93e09f52781993f9f6b36af5b93e7d8892252271.zip
Merge pull request #16180 from rafaelfranca/rm-dirty
Improve Active Model Dirty API.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/dirty_test.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index ea73c561e9..69a7f25213 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -169,7 +169,19 @@ class DirtyTest < ActiveRecord::TestCase
pirate = Pirate.create!(:catchphrase => 'Yar!')
pirate.catchphrase = 'Ahoy!'
- pirate.reset_catchphrase!
+ assert_deprecated do
+ pirate.reset_catchphrase!
+ end
+ assert_equal "Yar!", pirate.catchphrase
+ assert_equal Hash.new, pirate.changes
+ assert !pirate.catchphrase_changed?
+ end
+
+ def test_restore_attribute!
+ pirate = Pirate.create!(:catchphrase => 'Yar!')
+ pirate.catchphrase = 'Ahoy!'
+
+ pirate.restore_catchphrase!
assert_equal "Yar!", pirate.catchphrase
assert_equal Hash.new, pirate.changes
assert !pirate.catchphrase_changed?
@@ -398,7 +410,7 @@ class DirtyTest < ActiveRecord::TestCase
def test_dup_objects_should_not_copy_dirty_flag_from_creator
pirate = Pirate.create!(:catchphrase => "shiver me timbers")
pirate_dup = pirate.dup
- pirate_dup.reset_catchphrase!
+ pirate_dup.restore_catchphrase!
pirate.catchphrase = "I love Rum"
assert pirate.catchphrase_changed?
assert !pirate_dup.catchphrase_changed?