mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #37518 from shioyama/test_clear_changes_information_directly
Test clear_changes_information rather than reload
This commit is contained in:
commit
a67a2f63e7
2 changed files with 4 additions and 12 deletions
|
@ -14,10 +14,6 @@ class AttributesDirtyTest < ActiveModel::TestCase
|
||||||
def save
|
def save
|
||||||
changes_applied
|
changes_applied
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload
|
|
||||||
clear_changes_information
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
|
@ -146,7 +142,7 @@ class AttributesDirtyTest < ActiveModel::TestCase
|
||||||
assert_predicate @model, :size_changed?
|
assert_predicate @model, :size_changed?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "reload should reset all changes" do
|
test "clear_changes_information should reset all changes" do
|
||||||
@model.name = "Dmitry"
|
@model.name = "Dmitry"
|
||||||
@model.name_changed?
|
@model.name_changed?
|
||||||
@model.save
|
@model.save
|
||||||
|
@ -155,7 +151,7 @@ class AttributesDirtyTest < ActiveModel::TestCase
|
||||||
assert_equal [nil, "Dmitry"], @model.previous_changes["name"]
|
assert_equal [nil, "Dmitry"], @model.previous_changes["name"]
|
||||||
assert_equal "Dmitry", @model.changed_attributes["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.previous_changes
|
||||||
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes
|
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes
|
||||||
|
|
|
@ -39,10 +39,6 @@ class DirtyTest < ActiveModel::TestCase
|
||||||
def save
|
def save
|
||||||
changes_applied
|
changes_applied
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload
|
|
||||||
clear_changes_information
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
|
@ -184,7 +180,7 @@ class DirtyTest < ActiveModel::TestCase
|
||||||
assert_predicate @model, :size_changed?
|
assert_predicate @model, :size_changed?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "reload should reset all changes" do
|
test "clear_changes_information should reset all changes" do
|
||||||
@model.name = "Dmitry"
|
@model.name = "Dmitry"
|
||||||
@model.name_changed?
|
@model.name_changed?
|
||||||
@model.save
|
@model.save
|
||||||
|
@ -193,7 +189,7 @@ class DirtyTest < ActiveModel::TestCase
|
||||||
assert_equal [nil, "Dmitry"], @model.previous_changes["name"]
|
assert_equal [nil, "Dmitry"], @model.previous_changes["name"]
|
||||||
assert_equal "Dmitry", @model.changed_attributes["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.previous_changes
|
||||||
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes
|
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes
|
||||||
|
|
Loading…
Reference in a new issue