diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-01-10 12:14:44 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-01-10 12:14:44 -0800 |
commit | 223a1d9451c88800e9fcc93a726fdebec99e2650 (patch) | |
tree | 207b0b671778ac7a0e00829f6f642256b261cb28 /activerecord/test/cases/associations/has_many_associations_test.rb | |
parent | 13c6c3cfc59ff0b400b294dce15f32752b0fb5f5 (diff) | |
parent | 9fe69b225cfbf12c02ee1433adf3a5aa17bcdf59 (diff) | |
download | rails-223a1d9451c88800e9fcc93a726fdebec99e2650.tar.gz rails-223a1d9451c88800e9fcc93a726fdebec99e2650.tar.bz2 rails-223a1d9451c88800e9fcc93a726fdebec99e2650.zip |
Merge branch 'master' into savepoints
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 19 |
1 files changed, 19 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 816ceb6855..a5ae5cd8ec 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -665,6 +665,19 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 1, Client.find_all_by_client_of(firm.id).size end + def test_dependent_association_respects_optional_hash_conditions_on_delete + firm = companies(:odegy) + Client.create(:client_of => firm.id, :name => "BigShot Inc.") + Client.create(:client_of => firm.id, :name => "SmallTime Inc.") + # only one of two clients is included in the association due to the :conditions key + assert_equal 2, Client.find_all_by_client_of(firm.id).size + assert_equal 1, firm.dependent_sanitized_conditional_clients_of_firm.size + firm.destroy + # only the correctly associated client should have been deleted + assert_equal 1, Client.find_all_by_client_of(firm.id).size + end + + def test_creation_respects_hash_condition ms_client = companies(:first_firm).clients_like_ms_with_hash_conditions.build @@ -1102,5 +1115,11 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert !client_association.respond_to?(:private_method) assert client_association.respond_to?(:private_method, true) end + + def test_creating_using_primary_key + firm = Firm.find(:first) + client = firm.clients_using_primary_key.create!(:name => 'test') + assert_equal firm.name, client.firm_name + end end |