Permalink
Browse files

Merge pull request #14413 from arthurnn/port_test_cc

Add counter cache test for class_name
  • Loading branch information...
2 parents 34e54fa + e64875f commit 4279a75a144515d1a35f8617f0ef61ddec33e7fd @chancancode chancancode committed Mar 18, 2014
Showing with 11 additions and 0 deletions.
  1. +11 −0 activerecord/test/cases/associations/belongs_to_associations_test.rb
View
11 activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -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)

0 comments on commit 4279a75

Please sign in to comment.