File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change
1
+ * Make possible to change ` record_timestamps ` inside Callbacks.
2
+
3
+ * Tieg Zaharia*
4
+
1
5
* Fixed error where .persisted? throws SystemStackError for an unsaved model with a
2
6
custom primary key that didn't save due to validation error.
3
7
Original file line number Diff line number Diff line change @@ -310,8 +310,8 @@ class Base
310
310
include Locking ::Optimistic
311
311
include Locking ::Pessimistic
312
312
include AttributeMethods
313
- include Callbacks
314
313
include Timestamp
314
+ include Callbacks
315
315
include Associations
316
316
include ActiveModel ::SecurePassword
317
317
include AutosaveAssociation
Original file line number Diff line number Diff line change @@ -71,6 +71,24 @@ def test_saving_when_instance_record_timestamps_is_false_doesnt_update_its_times
71
71
assert_equal @previously_updated_at , @developer . updated_at
72
72
end
73
73
74
+ def test_saving_when_callback_sets_record_timestamps_to_false_doesnt_update_its_timestamp
75
+ klass = Class . new ( Developer ) do
76
+ before_update :cancel_record_timestamps
77
+ def cancel_record_timestamps
78
+ self . record_timestamps = false
79
+ return true
80
+ end
81
+ end
82
+
83
+ developer = klass . first
84
+ previously_updated_at = developer . updated_at
85
+
86
+ developer . name = "New Name"
87
+ developer . save!
88
+
89
+ assert_equal previously_updated_at , developer . updated_at
90
+ end
91
+
74
92
def test_touching_an_attribute_updates_timestamp
75
93
previously_created_at = @developer . created_at
76
94
@developer . touch ( :created_at )
You can’t perform that action at this time.
0 commit comments