Skip to content

Commit d81291f

Browse files
authored
Merge pull request rails#55386 from fatkodima/followup-51455
Add missing tests for `update_column`/`update_columns` `:touch` with specific time
2 parents a8ad282 + d5bab28 commit d81291f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

activerecord/test/cases/persistence_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,15 @@ def test_update_column_touch_option
11491149
end
11501150
end
11511151

1152+
def test_update_column_touch_option_with_specific_time
1153+
topic = Topic.find(1)
1154+
new_updated_at = Date.parse("2024-03-31 12:00:00")
1155+
1156+
assert_changes -> { topic.updated_at }, to: new_updated_at do
1157+
topic.update_column(:title, "super_title", touch: { time: new_updated_at })
1158+
end
1159+
end
1160+
11521161
def test_update_column_should_not_use_setter_method
11531162
dev = Developer.find(1)
11541163
dev.instance_eval { def salary=(value); write_attribute(:salary, value * 2); end }
@@ -1278,6 +1287,15 @@ def test_update_columns_touch_option_not_overwrite_explicit_attribute_with_strin
12781287
end
12791288
end
12801289

1290+
def test_update_columns_touch_option_with_specific_time
1291+
topic = Topic.find(1)
1292+
new_updated_at = Date.parse("2024-03-31 12:00:00")
1293+
1294+
assert_changes -> { topic.updated_at }, to: new_updated_at do
1295+
topic.update_columns(title: "super_title", touch: { time: new_updated_at })
1296+
end
1297+
end
1298+
12811299
def test_update_columns_should_not_use_setter_method
12821300
dev = Developer.find(1)
12831301
dev.instance_eval { def salary=(value); write_attribute(:salary, value * 2); end }

0 commit comments

Comments
 (0)