aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-06-23 17:01:00 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-06-23 17:01:00 +0000
commit279113f9b31ba6f08ba2489f5f033d269b94f829 (patch)
tree5b71bafab7a6b244f3c0567b8d367094f1db852d /activerecord/test
parent62a9203a5ed43fb3aea742b887a3bc874352950a (diff)
downloadrails-279113f9b31ba6f08ba2489f5f033d269b94f829.tar.gz
rails-279113f9b31ba6f08ba2489f5f033d269b94f829.tar.bz2
rails-279113f9b31ba6f08ba2489f5f033d269b94f829.zip
Fixed validates_associated should not stop on the first error (closes #4276) [mrj/manfred/josh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7094 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/validations_test.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb
index 81c53cef8b..105b8edd40 100755
--- a/activerecord/test/validations_test.rb
+++ b/activerecord/test/validations_test.rb
@@ -864,19 +864,21 @@ class ValidationsTest < Test::Unit::TestCase
def test_validates_associated_many
Topic.validates_associated( :replies )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
- t.replies << [r = Reply.create("title" => "A reply"), r2 = Reply.create("title" => "Another reply")]
+ t.replies << [r = Reply.new("title" => "A reply"), r2 = Reply.new("title" => "Another reply", "content" => "non-empty"), r3 = Reply.new("title" => "Yet another reply"), r4 = Reply.new("title" => "The last reply", "content" => "non-empty")]
assert !t.valid?
assert t.errors.on(:replies)
assert_equal 1, r.errors.count # make sure all associated objects have been validated
- assert_equal 1, r2.errors.count
- r.content = r2.content = "non-empty"
+ assert_equal 0, r2.errors.count
+ assert_equal 1, r3.errors.count
+ assert_equal 0, r4.errors.count
+ r.content = r3.content = "non-empty"
assert t.valid?
end
def test_validates_associated_one
Reply.validates_associated( :topic )
Topic.validates_presence_of( :content )
- r = Reply.create("title" => "A reply", "content" => "with content!")
+ r = Reply.new("title" => "A reply", "content" => "with content!")
r.topic = Topic.create("title" => "uhohuhoh")
assert !r.valid?
assert r.errors.on(:topic)