add test coverage for activemodel Dirty#reset_changes
This commit is contained in:
parent
5af7cab02d
commit
8acd58f23c
@ -41,6 +41,10 @@ def size=(val)
|
||||
def save
|
||||
changes_applied
|
||||
end
|
||||
|
||||
def reload
|
||||
reset_changes
|
||||
end
|
||||
end
|
||||
|
||||
setup do
|
||||
@ -157,4 +161,19 @@ def save
|
||||
@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 New Issue
Block a user