diff options
author | Xavier Noria <fxn@hashref.com> | 2008-08-21 15:45:06 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-08-21 15:48:04 +0100 |
commit | a970f916fb1e05376733e2d42d9bcc2b873af355 (patch) | |
tree | 32341e068add430be9687f38dc08722820d45845 /activerecord/test/cases/associations | |
parent | ea40f71431a821b2ddb37be6ea3ee7d8dac63b85 (diff) | |
download | rails-a970f916fb1e05376733e2d42d9bcc2b873af355.tar.gz rails-a970f916fb1e05376733e2d42d9bcc2b873af355.tar.bz2 rails-a970f916fb1e05376733e2d42d9bcc2b873af355.zip |
Fix has_many#count_records. [#865 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index b806e885e1..da3c8fb28e 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -395,6 +395,18 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 3, company.clients_of_firm.size end + def test_collection_size_twice_for_regressions + post = posts(:thinking) + assert_equal 0, post.readers.size + # This test needs a post that has no readers, we assert it to ensure it holds, + # but need to reload the post because the very call to #size hides the bug. + post.reload + post.readers.build + size1 = post.readers.size + size2 = post.readers.size + assert_equal size1, size2 + end + def test_build_many company = companies(:first_firm) new_clients = assert_no_queries { company.clients_of_firm.build([{"name" => "Another Client"}, {"name" => "Another Client II"}]) } |