diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-09-05 05:37:52 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-09-05 05:37:52 +0000 |
commit | aa32f66ebba1172ea006ee815df396152cacdffe (patch) | |
tree | 1828fca0b12ee291b1c2a5a091781107cecd4d2a /activerecord/test | |
parent | 51977bc261f83091a31c7f3d6f8dbd59cec1d2a3 (diff) | |
download | rails-aa32f66ebba1172ea006ee815df396152cacdffe.tar.gz rails-aa32f66ebba1172ea006ee815df396152cacdffe.tar.bz2 rails-aa32f66ebba1172ea006ee815df396152cacdffe.zip |
Add :allow_blank to validations. Like allow_nil, but for values which are +blank?+. [jnoon] Closes #7383
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7407 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/validations_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb index cd4b27a7dd..8c7ef759e6 100755 --- a/activerecord/test/validations_test.rb +++ b/activerecord/test/validations_test.rb @@ -457,6 +457,24 @@ class ValidationsTest < Test::Unit::TestCase assert developer.valid? end + def test_validates_length_of_with_allow_nil + Topic.validates_length_of( :title, :is => 5, :allow_nil=>true ) + + assert !Topic.create("title" => "ab").valid? + assert !Topic.create("title" => "").valid? + assert Topic.create("title" => nil).valid? + assert Topic.create("title" => "abcde").valid? + end + + def test_validates_length_of_with_allow_blank + Topic.validates_length_of( :title, :is => 5, :allow_blank=>true ) + + assert !Topic.create("title" => "ab").valid? + assert Topic.create("title" => "").valid? + assert Topic.create("title" => nil).valid? + assert Topic.create("title" => "abcde").valid? + end + def test_numericality_with_allow_nil_and_getter_method Developer.validates_numericality_of( :salary, :allow_nil => true) developer = Developer.new("name" => "michael", "salary" => nil) |