diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2008-12-21 15:38:40 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-12-21 15:57:48 +0000 |
commit | b17b9371c6a26484eb1984d45acffcdcd91b1ae1 (patch) | |
tree | f81c502a724e8383faf90d6b28250fd54860e9e5 /activerecord/test/cases/associations | |
parent | 6f4b2469fb19bb01fa0f53192eb49f8f2d95db1b (diff) | |
download | rails-b17b9371c6a26484eb1984d45acffcdcd91b1ae1.tar.gz rails-b17b9371c6a26484eb1984d45acffcdcd91b1ae1.tar.bz2 rails-b17b9371c6a26484eb1984d45acffcdcd91b1ae1.zip |
Fix configure_dependency_for_has_many not quoting conditions properly [#1461 state:resolved]
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 13 |
1 files changed, 13 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..20b9acda44 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 |