diff options
author | Dmitry Polushkin <dmitry.polushkin@gmail.com> | 2014-02-09 01:34:14 +0000 |
---|---|---|
committer | Dmitry Polushkin <dmitry.polushkin@gmail.com> | 2014-02-09 18:44:24 +0000 |
commit | 8acd58f23cac478c2f5f8a51a9b591a98773baec (patch) | |
tree | e79bfb0516a753193a912125454da79b24552712 /activemodel/test/cases | |
parent | 5af7cab02ddd95e6813738e9de69b64fe560dbcd (diff) | |
download | rails-8acd58f23cac478c2f5f8a51a9b591a98773baec.tar.gz rails-8acd58f23cac478c2f5f8a51a9b591a98773baec.tar.bz2 rails-8acd58f23cac478c2f5f8a51a9b591a98773baec.zip |
add test coverage for activemodel Dirty#reset_changes
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/dirty_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activemodel/test/cases/dirty_test.rb b/activemodel/test/cases/dirty_test.rb index 8b55901a65..2853476c91 100644 --- a/activemodel/test/cases/dirty_test.rb +++ b/activemodel/test/cases/dirty_test.rb @@ -41,6 +41,10 @@ class DirtyTest < ActiveModel::TestCase def save changes_applied end + + def reload + reset_changes + end end setup do @@ -157,4 +161,19 @@ class DirtyTest < ActiveModel::TestCase @model.size = 1 assert @model.size_changed? end + + test "reload should reset all changes" do + @model.name = 'Dmitry' + @model.name_changed? + @model.save + @model.name = 'Bob' + + assert_equal [nil, 'Dmitry'], @model.previous_changes['name'] + assert_equal 'Dmitry', @model.changed_attributes['name'] + + @model.reload + + assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.previous_changes + assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes + end end |