Commit 7eaff42 rbr
committed
1 parent b5b3823 commit 7eaff42 Copy full SHA for 7eaff42
File tree 2 files changed +13
-3
lines changed
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,6 @@ def restore!(opts = {})
110
110
if ( noop_if_frozen && !@attributes . frozen? ) || !noop_if_frozen
111
111
write_attribute paranoia_column , paranoia_sentinel_value
112
112
update_columns ( paranoia_restore_attributes )
113
- touch
114
113
end
115
114
restore_associated_records if opts [ :recursive ]
116
115
end
@@ -154,13 +153,17 @@ def really_destroy!
154
153
def paranoia_restore_attributes
155
154
{
156
155
paranoia_column => paranoia_sentinel_value
157
- }
156
+ } . merge ( timestamp_attributes_with_current_time )
158
157
end
159
158
160
159
def paranoia_destroy_attributes
161
160
{
162
161
paranoia_column => current_time_from_proper_timezone
163
- }
162
+ } . merge ( timestamp_attributes_with_current_time )
163
+ end
164
+
165
+ def timestamp_attributes_with_current_time
166
+ timestamp_attributes_for_update_in_model . each_with_object ( { } ) { |attr , hash | hash [ attr ] = current_time_from_proper_timezone }
164
167
end
165
168
166
169
# restore associated records that have been soft deleted when
Original file line number Diff line number Diff line change @@ -774,6 +774,13 @@ def test_validates_uniqueness_still_works_on_non_deleted_records
774
774
refute b . valid?
775
775
end
776
776
777
+ def test_updated_at_modification_on_destroy
778
+ paranoid_model = ParanoidModelWithTimestamp . create ( :parent_model => ParentModel . create , :updated_at => 1 . day . ago )
779
+ assert paranoid_model . updated_at < 10 . minutes . ago
780
+ paranoid_model . destroy
781
+ assert paranoid_model . updated_at > 10 . minutes . ago
782
+ end
783
+
777
784
def test_updated_at_modification_on_restore
778
785
parent1 = ParentModel . create
779
786
pt1 = ParanoidModelWithTimestamp . create ( :parent_model => parent1 )
You can’t perform that action at this time.
0 commit comments