diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-06-03 21:16:50 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-06-03 21:16:50 +0000 |
commit | 16716090632d499eb6bfc8afdea2784eb6f5963d (patch) | |
tree | f179381121e6acc84892191d5c006f809cf31585 /activerecord/test | |
parent | 01a52dd1ad51034b10a8386db7b1aae83f32a59d (diff) | |
download | rails-16716090632d499eb6bfc8afdea2784eb6f5963d.tar.gz rails-16716090632d499eb6bfc8afdea2784eb6f5963d.tar.bz2 rails-16716090632d499eb6bfc8afdea2784eb6f5963d.zip |
Fixed that has_many.create ended up with duplicate objects (closes #5250) [daniel@nouvelles-solutions.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4416 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/associations_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 4c8d169566..4d8817568f 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -460,6 +460,14 @@ class HasManyAssociationsTest < Test::Unit::TestCase assert_equal 2, companies(:first_firm).clients_of_firm(true).size # checking using the db assert_equal natural, companies(:first_firm).clients_of_firm.last end + + def test_adding_using_create + first_firm = companies(:first_firm) + assert_equal 2, first_firm.plain_clients.size + natural = first_firm.plain_clients.create(:name => "Natural Company") + assert_equal 3, first_firm.plain_clients.length + assert_equal 3, first_firm.plain_clients.size + end def test_adding_a_mismatch_class assert_raises(ActiveRecord::AssociationTypeMismatch) { companies(:first_firm).clients_of_firm << nil } |