diff options
author | Jon Leighton <j@jonathanleighton.com> | 2013-01-18 02:08:13 -0800 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2013-01-18 02:08:13 -0800 |
commit | e8d80f73996bc19b2fab46c7519c384ce96f1928 (patch) | |
tree | c7ef359809a33d8612761d05f0eca46c9387f489 /activerecord/test | |
parent | 9da9763e0a848906725f8805f44d2ce0c0b9ab9e (diff) | |
parent | ec07735641e4df13b644a85f1f300cf20134995a (diff) | |
download | rails-e8d80f73996bc19b2fab46c7519c384ce96f1928.tar.gz rails-e8d80f73996bc19b2fab46c7519c384ce96f1928.tar.bz2 rails-e8d80f73996bc19b2fab46c7519c384ce96f1928.zip |
Merge pull request #8912 from senny/8879_association_empty_method
`CollectionAssociation#empty?` respects newly builded records
Diffstat (limited to 'activerecord/test')
-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 7e6c7d5862..28400970fb 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -625,6 +625,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 3, company.clients_of_firm.size end + def test_collection_not_empty_after_building + company = companies(:first_firm) + assert_predicate company.contracts, :empty? + company.contracts.build + assert_not_predicate company.contracts, :empty? + end + def test_collection_size_twice_for_regressions post = posts(:thinking) assert_equal 0, post.readers.size |