aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorTomas D'Stefano <tomasdestefi@gmail.com>2011-05-31 11:43:19 -0300
committerJon Leighton <j@jonathanleighton.com>2011-07-08 22:26:54 +0100
commitea4b94a7bf707d27af44701fa44ef5f916b84e01 (patch)
treeae5ef07b2cccc9f5dc0d8a1c0f453fe4123dd9ff /activerecord/test/cases
parentdfec3737b05d22e6f298bcae0a8948a4b8803ebd (diff)
downloadrails-ea4b94a7bf707d27af44701fa44ef5f916b84e01.tar.gz
rails-ea4b94a7bf707d27af44701fa44ef5f916b84e01.tar.bz2
rails-ea4b94a7bf707d27af44701fa44ef5f916b84e01.zip
Destroy association habtm record before destroying the record itself. Fixes issue #402.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/habtm_destroy_order_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/habtm_destroy_order_test.rb b/activerecord/test/cases/habtm_destroy_order_test.rb
index f2b91d977e..2ce0de360e 100644
--- a/activerecord/test/cases/habtm_destroy_order_test.rb
+++ b/activerecord/test/cases/habtm_destroy_order_test.rb
@@ -16,6 +16,16 @@ class HabtmDestroyOrderTest < ActiveRecord::TestCase
assert !sicp.destroyed?
end
+ test 'should not raise error if have foreign key in the join table' do
+ student = Student.new(:name => "Ben Bitdiddle")
+ lesson = Lesson.new(:name => "SICP")
+ lesson.students << student
+ lesson.save!
+ assert_nothing_raised do
+ student.destroy
+ end
+ end
+
test "not destroying a student with lessons leaves student<=>lesson association intact" do
# test a normal before_destroy doesn't destroy the habtm joins
begin