aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/belongs_to_associations_test.rb
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2014-03-17 21:23:54 -0400
committerArthur Neves <arthurnn@gmail.com>2014-03-17 21:23:54 -0400
commite64875ffde5787eee24a96070f3cf51727347304 (patch)
tree282d0aea6bdcd599ef460c009ef718b9e66b55c5 /activerecord/test/cases/associations/belongs_to_associations_test.rb
parent34e54fa0542ebb3403932ab785239119e449dc3c (diff)
downloadrails-e64875ffde5787eee24a96070f3cf51727347304.tar.gz
rails-e64875ffde5787eee24a96070f3cf51727347304.tar.bz2
rails-e64875ffde5787eee24a96070f3cf51727347304.zip
Add counter cache test for class_name
Backport test from #14410
Diffstat (limited to 'activerecord/test/cases/associations/belongs_to_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index 9340bc0a83..56ac284331 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -824,6 +824,17 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
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)