File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ def attribute_will_change!(attr)
156
156
rescue TypeError , NoMethodError
157
157
end
158
158
159
- changed_attributes [ attr ] = value
159
+ changed_attributes [ attr ] = value unless changed_attributes . include? ( attr )
160
160
end
161
161
162
162
# Handle <tt>reset_*!</tt> for +method_missing+.
Original file line number Diff line number Diff line change @@ -106,4 +106,13 @@ def save
106
106
assert_equal [ nil , "Jericho Cane" ] , @model . previous_changes [ 'name' ]
107
107
end
108
108
109
+ test "changing the same attribute multiple times retains the correct original value" do
110
+ @model . name = "Otto"
111
+ @model . save
112
+ @model . name = "DudeFella ManGuy"
113
+ @model . name = "Mr. Manfredgensonton"
114
+ assert_equal [ "Otto" , "Mr. Manfredgensonton" ] , @model . name_change
115
+ assert_equal @model . name_was , "Otto"
116
+ end
117
+
109
118
end
You can’t perform that action at this time.
0 commit comments