aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorGeorge Brocklehurst <george.brocklehurst@gmail.com>2012-10-25 23:48:22 +0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-16 21:34:31 -0200
commit3e648599385887d0bd80225bd45db4799902ec02 (patch)
treee7515d8f71212636618d8d8bfd9218c289f11c86 /activerecord
parent1e9522cb257fedcf66c7b280db71b681a17fd13f (diff)
downloadrails-3e648599385887d0bd80225bd45db4799902ec02.tar.gz
rails-3e648599385887d0bd80225bd45db4799902ec02.tar.bz2
rails-3e648599385887d0bd80225bd45db4799902ec02.zip
Test for has_many bug on unsaved records
See issue #7950.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb7
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 b1066fb24c..01afa087be 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1150,6 +1150,13 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert companies(:first_firm).clients.include?(Client.find(2))
end
+ def test_included_in_collection_for_new_records
+ client = Client.create(:name => 'Persisted')
+ assert_nil client.client_of
+ assert !Firm.new.clients_of_firm.include?(client),
+ 'includes a client that does not belong to any firm'
+ end
+
def test_adding_array_and_collection
assert_nothing_raised { Firm.first.clients + Firm.all.last.clients }
end