Merge pull request #1897 from istewart/active_model_dirty_patch
ActiveModel::Dirty patch for multiple assignments to the same attribute
This commit is contained in:
commit
4106245530
@ -156,7 +156,7 @@ def attribute_will_change!(attr)
|
||||
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 @@ def save
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user