mirror of
https://github.com/github/rails.git
synced 2026-01-09 14:48:01 -05:00
changing an attribute multiple times retains the correct original value
This commit is contained in:
@@ -156,7 +156,7 @@ module ActiveModel
|
||||
rescue TypeError, NoMethodError
|
||||
end
|
||||
|
||||
changed_attributes[attr] = value
|
||||
changed_attributes[attr] = value unless changed_attributes.include?(attr)
|
||||
end
|
||||
|
||||
# Handle <tt>reset_*!</tt> for +method_missing+.
|
||||
|
||||
@@ -106,4 +106,13 @@ class DirtyTest < ActiveModel::TestCase
|
||||
assert_equal [nil, "Jericho Cane"], @model.previous_changes['name']
|
||||
end
|
||||
|
||||
test "changing the same attribute multiple times retains the correct original value" do
|
||||
@model.name = "Otto"
|
||||
@model.save
|
||||
@model.name = "DudeFella ManGuy"
|
||||
@model.name = "Mr. Manfredgensonton"
|
||||
assert_equal ["Otto", "Mr. Manfredgensonton"], @model.name_change
|
||||
assert_equal @model.name_was, "Otto"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user