From edd2f21e8095fe4a38e812025b4d9fd0e0cc28f1 Mon Sep 17 00:00:00 2001 From: Dmitry Polushkin Date: Fri, 9 Sep 2011 08:31:54 +0100 Subject: Test polymorphic record with optimistic locking and counter cache should be destoyed without catching the ActiveRecord::StaleObjectError. --- activerecord/test/cases/locking_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 61baa55027..a809cd0aa7 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -6,6 +6,9 @@ require 'models/reader' require 'models/legacy_thing' require 'models/reference' require 'models/string_key_object' +require 'models/car' +require 'models/engine' +require 'models/wheel' class LockWithoutDefault < ActiveRecord::Base; end @@ -207,6 +210,15 @@ class OptimisticLockingTest < ActiveRecord::TestCase assert_equal lock_version, p1.lock_version end end + + def test_polymorphic_destroy_with_dependencies_and_lock_version + car = Car.create! + car.wheels << Wheel.create! + assert_equal 1, car.wheels.count + assert car.destroy + assert_equal 0, car.wheels.count + assert car.destroyed? + end end class OptimisticLockingWithSchemaChangeTest < ActiveRecord::TestCase -- cgit v1.2.3