Skip to content
Browse files

add test coverage for activemodel Dirty#reset_changes

  • Loading branch information...
1 parent 5af7cab commit 8acd58f23cac478c2f5f8a51a9b591a98773baec @dmitry dmitry committed Feb 9, 2014
Showing with 19 additions and 0 deletions.
  1. +19 −0 activemodel/test/cases/dirty_test.rb
View
19 activemodel/test/cases/dirty_test.rb
@@ -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

0 comments on commit 8acd58f

Please sign in to comment.
Something went wrong with that request. Please try again.