Permalink
Browse files

Attempted to capture #286 in a unit test, but couldnt get it to fail

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@132 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent e1ee022 commit 5c50df27cf1a81cd8ace5cad83bc7acee61311da @dhh dhh committed Dec 12, 2004
@@ -296,6 +296,14 @@ def test_dependence
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
@@ -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 @@ def title_is_wrong_create
def validate_on_update
errors.add("title", "is Wrong Update") if attribute_present?("title") && title == "Wrong Update"
end
+end
+
+class SillyReply < Reply
end
@@ -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

0 comments on commit 5c50df2

Please sign in to comment.