Skip to content

Commit

Permalink
Merge pull request #37518 from shioyama/test_clear_changes_informatio…
Browse files Browse the repository at this point in the history
…n_directly

Test clear_changes_information rather than reload
  • Loading branch information
kaspth committed Nov 17, 2019
2 parents fe094cb + 8937c72 commit a67a2f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions activemodel/test/cases/attributes_dirty_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ class DirtyModel
def save
changes_applied
end

def reload
clear_changes_information
end
end

setup do
Expand Down Expand Up @@ -146,7 +142,7 @@ def reload
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
Expand All @@ -155,7 +151,7 @@ def reload
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
Expand Down
8 changes: 2 additions & 6 deletions activemodel/test/cases/dirty_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def status=(val)
def save
changes_applied
end

def reload
clear_changes_information
end
end

setup do
Expand Down Expand Up @@ -184,7 +180,7 @@ def reload
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
Expand All @@ -193,7 +189,7 @@ def reload
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
Expand Down

0 comments on commit a67a2f6

Please sign in to comment.