aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-03-18 01:27:54 -0700
committerGodfrey Chan <godfreykfc@gmail.com>2014-03-18 01:27:54 -0700
commit4279a75a144515d1a35f8617f0ef61ddec33e7fd (patch)
tree282d0aea6bdcd599ef460c009ef718b9e66b55c5 /activerecord
parent34e54fa0542ebb3403932ab785239119e449dc3c (diff)
parente64875ffde5787eee24a96070f3cf51727347304 (diff)
downloadrails-4279a75a144515d1a35f8617f0ef61ddec33e7fd.tar.gz
rails-4279a75a144515d1a35f8617f0ef61ddec33e7fd.tar.bz2
rails-4279a75a144515d1a35f8617f0ef61ddec33e7fd.zip
Merge pull request #14413 from arthurnn/port_test_cc
Add counter cache test for class_name
Diffstat (limited to 'activerecord')
-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)