diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-07-02 03:17:33 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-07-02 03:17:33 +0100 |
commit | 474d42538269a141687c7c66bef6575b4682b15d (patch) | |
tree | 42aebc676eeb1f6e0035aa1595fb1bed0dea01ca /activerecord/test/cases | |
parent | 7378e237342443addb1691795ac9457250b6db1e (diff) | |
download | rails-474d42538269a141687c7c66bef6575b4682b15d.tar.gz rails-474d42538269a141687c7c66bef6575b4682b15d.tar.bz2 rails-474d42538269a141687c7c66bef6575b4682b15d.zip |
Ensure AssociationCollection#size considers all unsaved record. [#305 state:resolved] [sds]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 7 |
1 files changed, 7 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 1e21614f45..247726bc61 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -384,6 +384,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 2, company.clients_of_firm(true).size end + def test_collection_size_after_building + company = companies(:first_firm) # company already has one client + company.clients_of_firm.build("name" => "Another Client") + company.clients_of_firm.build("name" => "Yet Another Client") + assert_equal 3, company.clients_of_firm.size + 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"}]) } |