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:
parent
5af7cab02d
commit
8acd58f23c
1 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue