aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-11-01 19:04:30 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-11-01 19:04:30 -0200
commit1918b12c0429caec2a6134ac5e5b42ade103fe90 (patch)
tree7e9a61f8f5460d27231c295f843854a44961d2d9 /activerecord/test/cases/associations/has_many_associations_test.rb
parentd9e70501a41d6a2e8dd4f0c4f7da78aaab6d2202 (diff)
downloadrails-1918b12c0429caec2a6134ac5e5b42ade103fe90.tar.gz
rails-1918b12c0429caec2a6134ac5e5b42ade103fe90.tar.bz2
rails-1918b12c0429caec2a6134ac5e5b42ade103fe90.zip
Fix wrong behavior where associations with dependent: :destroy options
was using nullify strategy This caused a regression in applications trying to upgrade. Also if the user set the dependent option as destroy he expects to get the records removed from the database.
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index b824a0ee7c..dfc8a68e8c 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -101,11 +101,10 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
end
def test_do_not_call_callbacks_for_delete_all
- bulb_count = Bulb.count
car = Car.create(:name => 'honda')
car.funky_bulbs.create!
assert_nothing_raised { car.reload.funky_bulbs.delete_all }
- assert_equal bulb_count + 1, Bulb.count, "bulbs should have been deleted using :nullify strategey"
+ assert_equal 0, Bulb.count, "bulbs should have been deleted using :delete_all strategey"
end
def test_building_the_associated_object_with_implicit_sti_base_class
@@ -864,7 +863,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal 1, firm.dependent_clients_of_firm.size
assert_equal 1, Client.find_by_id(client_id).client_of
- # :nullify is called on each client
+ # :delete_all is called on each client since the dependent options is :destroy
firm.dependent_clients_of_firm.clear
assert_equal 0, firm.dependent_clients_of_firm.size
@@ -872,7 +871,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [], Client.destroyed_client_ids[firm.id]
# Should be destroyed since the association is dependent.
- assert_nil Client.find_by_id(client_id).client_of
+ assert_nil Client.find_by_id(client_id)
end
def test_delete_all_with_option_delete_all