1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

add test coverage for activemodel Dirty#reset_changes

This commit is contained in:
Dmitry Polushkin 2014-02-09 01:34:14 +00:00
parent 5af7cab02d
commit 8acd58f23c

View file

@ -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