Test for has_many bug on unsaved records

See issue #7950.
This commit is contained in:
George Brocklehurst 2012-10-25 23:48:22 +02:00 committed by Carlos Antonio da Silva
parent 1e9522cb25
commit 3e64859938
1 changed files with 7 additions and 0 deletions

View File

@ -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