Add counter cache test for class_name

Backport test from #14410
上级 34e54fa0
......@@ -824,6 +824,17 @@ def test_self_referential_belongs_to_with_counter_cache_assigning_nil
assert_equal 0, comments(:greetings).reload.children_count
end
def test_belongs_to_with_id_assigning
post = posts(:welcome)
comment = Comment.create! body: "foo", post: post
parent = comments(:greetings)
assert_equal 0, parent.reload.children_count
comment.parent_id = parent.id
comment.save!
assert_equal 1, parent.reload.children_count
end
def test_polymorphic_with_custom_primary_key
toy = Toy.create!
sponsor = Sponsor.create!(:sponsorable => toy)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册