diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-03-30 06:08:05 -0700 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-03-30 06:08:05 -0700 |
commit | 2eb111815d5f7a86a7dbd317075e396c94ab2c3d (patch) | |
tree | e6a5ced27b7fd486252b44b6d4f5dff304fcf58c /activerecord/test/cases/locking_test.rb | |
parent | 34320cd6ba3423be7e0828c1486601aca53abc82 (diff) | |
parent | 2931f413a51f75e7365ac7dfe2e0bc2a27224c94 (diff) | |
download | rails-2eb111815d5f7a86a7dbd317075e396c94ab2c3d.tar.gz rails-2eb111815d5f7a86a7dbd317075e396c94ab2c3d.tar.bz2 rails-2eb111815d5f7a86a7dbd317075e396c94ab2c3d.zip |
Merge pull request #5334 from courtland/master
Fix deleting from a HABTM join table upon destroying an object of a model with optimistic locking enabled.
Diffstat (limited to 'activerecord/test/cases/locking_test.rb')
-rw-r--r-- | activerecord/test/cases/locking_test.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb index 807274ca67..a8fb3548f6 100644 --- a/activerecord/test/cases/locking_test.rb +++ b/activerecord/test/cases/locking_test.rb @@ -22,7 +22,7 @@ class ReadonlyFirstNamePerson < Person end class OptimisticLockingTest < ActiveRecord::TestCase - fixtures :people, :legacy_things, :references, :string_key_objects + fixtures :people, :legacy_things, :references, :string_key_objects, :peoples_treasures def test_non_integer_lock_existing s1 = StringKeyObject.find("record1") @@ -239,6 +239,16 @@ class OptimisticLockingTest < ActiveRecord::TestCase end assert car.destroyed? end + + def test_removing_has_and_belongs_to_many_associations_upon_destroy + p = RichPerson.create! + p.treasures.create! + assert !p.treasures.empty? + p.destroy + assert p.treasures.empty? + assert RichPerson.connection.select_all("SELECT * FROM peoples_treasures WHERE rich_person_id = 1").empty? + end + end class OptimisticLockingWithSchemaChangeTest < ActiveRecord::TestCase |