aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-08 10:19:09 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-08 10:19:09 +0000
commit35b4bdcff0e697765b562a74bd881e78de97f4d1 (patch)
tree15d1e68d1fd4fa2f4a4b40e133716b0cada078cf /activerecord/test/associations_test.rb
parentc54b51fa7e6fd51f89cd74c9b2b2f144f2229ee9 (diff)
downloadrails-35b4bdcff0e697765b562a74bd881e78de97f4d1.tar.gz
rails-35b4bdcff0e697765b562a74bd881e78de97f4d1.tar.bz2
rails-35b4bdcff0e697765b562a74bd881e78de97f4d1.zip
Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. Closes #2065.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2940 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-xactiverecord/test/associations_test.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index fc2afb721f..4ad40f338c 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -1246,10 +1246,13 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
end
def test_removing_associations_on_destroy
- Developer.find(1).destroy
- assert Developer.connection.select_all("SELECT * FROM developers_projects WHERE developer_id = 1").empty?
+ david = DeveloperWithBeforeDestroyRaise.find(1)
+ assert !david.projects.empty?
+ assert_nothing_raised { david.destroy }
+ assert david.projects.empty?
+ assert DeveloperWithBeforeDestroyRaise.connection.select_all("SELECT * FROM developers_projects WHERE developer_id = 1").empty?
end
-
+
def test_additional_columns_from_join_table
# SQL Server doesn't have a separate column type just for dates,
# so the time is in the string and incorrectly formatted