Merge pull request #37518 from shioyama/test_clear_changes_information_directly

Test clear_changes_information rather than reload
This commit is contained in:
Kasper Timm Hansen 2019-11-17 22:05:17 +01:00 committed by GitHub
commit a67a2f63e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 12 deletions

View File

@ -14,10 +14,6 @@ class AttributesDirtyTest < ActiveModel::TestCase
def save
changes_applied
end
def reload
clear_changes_information
end
end
setup do
@ -146,7 +142,7 @@ class AttributesDirtyTest < ActiveModel::TestCase
assert_predicate @model, :size_changed?
end
test "reload should reset all changes" do
test "clear_changes_information should reset all changes" do
@model.name = "Dmitry"
@model.name_changed?
@model.save
@ -155,7 +151,7 @@ class AttributesDirtyTest < ActiveModel::TestCase
assert_equal [nil, "Dmitry"], @model.previous_changes["name"]
assert_equal "Dmitry", @model.changed_attributes["name"]
@model.reload
@model.clear_changes_information
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.previous_changes
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes

View File

@ -39,10 +39,6 @@ class DirtyTest < ActiveModel::TestCase
def save
changes_applied
end
def reload
clear_changes_information
end
end
setup do
@ -184,7 +180,7 @@ class DirtyTest < ActiveModel::TestCase
assert_predicate @model, :size_changed?
end
test "reload should reset all changes" do
test "clear_changes_information should reset all changes" do
@model.name = "Dmitry"
@model.name_changed?
@model.save
@ -193,7 +189,7 @@ class DirtyTest < ActiveModel::TestCase
assert_equal [nil, "Dmitry"], @model.previous_changes["name"]
assert_equal "Dmitry", @model.changed_attributes["name"]
@model.reload
@model.clear_changes_information
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.previous_changes
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes