提交 afa2da64 编写于 作者: E Eugene Kenny

Add test for update_counters with empty touch

This is a regression test for a fix included in
https://github.com/rails/rails/commit/bad9bfbea6d6af9dc28583e08a49492668087393.

Without that change, this test would fail with:

    ActiveRecord::StatementInvalid: SQLite3::SQLException: near "WHERE": syntax error: UPDATE "topics" SET "replies_count" = COALESCE("replies_count", 0) - 1,  WHERE "topics"."id" = ?
上级 aaece61a
......@@ -221,6 +221,15 @@ class ::SpecialReply < ::Reply
assert_equal previously_updated_at, @topic.updated_at
end
test "update counters doesn't touch timestamps with touch: []" do
@topic.update_column :updated_at, 5.minutes.ago
previously_updated_at = @topic.updated_at
Topic.update_counters(@topic.id, replies_count: -1, touch: [])
assert_equal previously_updated_at, @topic.updated_at
end
test "update counters with touch: true" do
assert_touching @topic, :updated_at do
Topic.update_counters(@topic.id, replies_count: -1, touch: true)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册