File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,10 @@ def initialize_dup(other) # :nodoc:
54
54
55
55
module ClassMethods # :nodoc:
56
56
def touch_attributes_with_time ( *names , time : nil )
57
+ names = names . map ( &:to_s )
58
+ names = names . map { |name | attribute_aliases [ name ] || name }
57
59
attribute_names = timestamp_attributes_for_update_in_model
58
- attribute_names |= names . map ( & :to_s )
60
+ attribute_names |= names
59
61
attribute_names . index_with ( time || current_time_from_proper_timezone )
60
62
end
61
63
Original file line number Diff line number Diff line change @@ -135,6 +135,19 @@ def test_touch_all_with_custom_timestamp
135
135
assert_not_equal previously_updated_at , developer . updated_at
136
136
end
137
137
138
+ def test_touch_all_with_aliased_for_update_timestamp
139
+ assert Developer . attribute_aliases . key? ( "updated_at" )
140
+
141
+ developer = developers ( :david )
142
+ previously_created_at = developer . created_at
143
+ previously_updated_at = developer . updated_at
144
+ Developer . where ( name : "David" ) . touch_all ( :updated_at )
145
+ developer . reload
146
+
147
+ assert_equal previously_created_at , developer . created_at
148
+ assert_not_equal previously_updated_at , developer . updated_at
149
+ end
150
+
138
151
def test_touch_all_with_given_time
139
152
developer = developers ( :david )
140
153
previously_created_at = developer . created_at
You can’t perform that action at this time.
0 commit comments