diff options
-rwxr-xr-x | activerecord/test/associations_test.rb | 8 | ||||
-rwxr-xr-x | activerecord/test/fixtures/reply.rb | 4 | ||||
-rwxr-xr-x | activerecord/test/fixtures/topic.rb | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index cc4c2374d1..5313485ec4 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -296,6 +296,14 @@ class HasManyAssociationsTest < Test::Unit::TestCase assert_equal 0, Client.find_all.length end + def test_three_levels_of_dependence + topic = Topic.create "title" => "neat and simple" + reply = topic.replies.create "title" => "neat and simple", "content" => "still digging it" + silly_reply = reply.silly_replies.create "title" => "neat and simple", "content" => "ain't complaining" + + assert_nothing_raised { topic.destroy } + end + def test_dependence_with_transaction_support_on_failure assert_equal 2, Client.find_all.length firm = Firm.find_first diff --git a/activerecord/test/fixtures/reply.rb b/activerecord/test/fixtures/reply.rb index 127f2052f3..d0ec895127 100755 --- a/activerecord/test/fixtures/reply.rb +++ b/activerecord/test/fixtures/reply.rb @@ -1,5 +1,6 @@ class Reply < Topic belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true + has_many :silly_replies, :dependent => true, :foreign_key => "parent_id" validate :errors_on_empty_content validate_on_create :title_is_wrong_create @@ -27,4 +28,7 @@ class Reply < Topic def validate_on_update errors.add("title", "is Wrong Update") if attribute_present?("title") && title == "Wrong Update" end +end + +class SillyReply < Reply end
\ No newline at end of file diff --git a/activerecord/test/fixtures/topic.rb b/activerecord/test/fixtures/topic.rb index 55c94e9e88..60022aa46b 100755 --- a/activerecord/test/fixtures/topic.rb +++ b/activerecord/test/fixtures/topic.rb @@ -1,5 +1,5 @@ class Topic < ActiveRecord::Base - has_many :replies, :foreign_key => "parent_id" + has_many :replies, :dependent => true, :foreign_key => "parent_id" serialize :content before_create :default_written_on |