diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-01-26 05:08:20 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-01-26 05:08:20 +0000 |
commit | 176abc842c43fc803d41efa429456a2ea8e7296d (patch) | |
tree | 911be28379532178d54c0ece99830553a4dae83a /activerecord/test | |
parent | 8ef3dfff7a48bd0609ba4067c54910880fc6ef88 (diff) | |
download | rails-176abc842c43fc803d41efa429456a2ea8e7296d.tar.gz rails-176abc842c43fc803d41efa429456a2ea8e7296d.tar.bz2 rails-176abc842c43fc803d41efa429456a2ea8e7296d.zip |
Add tests and documentation for allow_blank. Closes #10651 [blj]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8733 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/cases/validations_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index 34caf0e67e..bf79521cca 100755 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -489,6 +489,14 @@ class ValidationsTest < ActiveRecord::TestCase assert_raise(ArgumentError) { Topic.validates_format_of(:title, :content) } end + def test_validate_format_with_allow_blank + Topic.validates_format_of(:title, :with => /^Validation\smacros \w+!$/, :allow_blank=>true) + assert !Topic.create("title" => "Shouldn't be valid").valid? + assert Topic.create("title" => "").valid? + assert Topic.create("title" => nil).valid? + assert Topic.create("title" => "Validation macros rule!").valid? + end + # testing ticket #3142 def test_validate_format_numeric Topic.validates_format_of(:title, :content, :with => /^[1-9][0-9]*$/, :message => "is bad data") |