diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-29 17:53:44 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-29 17:53:44 +0000 |
commit | f34d57e2d2fcc3357e7b4076d23bed3bfbd35ce3 (patch) | |
tree | 122316b519a5612362cabe6c0399604d2eab1f48 /activerecord/test | |
parent | 3748d7a0f2a2826cfb9aa8fdde5789fa62b0de34 (diff) | |
download | rails-f34d57e2d2fcc3357e7b4076d23bed3bfbd35ce3.tar.gz rails-f34d57e2d2fcc3357e7b4076d23bed3bfbd35ce3.tar.bz2 rails-f34d57e2d2fcc3357e7b4076d23bed3bfbd35ce3.zip |
Fixed that validates_size_of :within works in associations (closes #11295, #10019) [cavalle]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9129 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/cases/validations_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index 34d55dbcf6..3d83b8d4d1 100755 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -806,6 +806,20 @@ class ValidationsTest < ActiveRecord::TestCase reply = t.replies.build('title' => 'areply', 'content' => 'whateveragain') assert t.valid? end + + def test_validates_size_of_association_using_within + assert_nothing_raised { Topic.validates_size_of :replies, :within => 1..2 } + t = Topic.new('title' => 'noreplies', 'content' => 'whatever') + assert !t.save + assert t.errors.on(:replies) + + reply = t.replies.build('title' => 'areply', 'content' => 'whateveragain') + assert t.valid? + + 2.times { t.replies.build('title' => 'areply', 'content' => 'whateveragain') } + assert !t.save + assert t.errors.on(:replies) + end def test_validates_length_of_nasty_params assert_raise(ArgumentError) { Topic.validates_length_of(:title, :minimum=>6, :maximum=>9) } |