diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-06 10:17:32 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-06 10:17:32 -0800 |
commit | 393f797be868c46e9a25c6f07760e4cd69d150ea (patch) | |
tree | 174660eec87d7619bc968658bd345d1c88d11361 /activemodel/test | |
parent | 6342cdd6ac7ea07edc3a905cd8ce700f3144c63d (diff) | |
parent | 60dad828aefa41703c0eee3863a7141c56caa7da (diff) | |
download | rails-393f797be868c46e9a25c6f07760e4cd69d150ea.tar.gz rails-393f797be868c46e9a25c6f07760e4cd69d150ea.tar.bz2 rails-393f797be868c46e9a25c6f07760e4cd69d150ea.zip |
Merge pull request #4905 from herimedia/to-infinity-and-beyond
Infinity should be a valid validates_length_of maximum
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/validations/length_validation_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/length_validation_test.rb b/activemodel/test/cases/validations/length_validation_test.rb index aa86d9d959..113bfd6337 100644 --- a/activemodel/test/cases/validations/length_validation_test.rb +++ b/activemodel/test/cases/validations/length_validation_test.rb @@ -357,4 +357,22 @@ class LengthValidationTest < ActiveModel::TestCase ensure Person.reset_callbacks(:validate) end + + def test_validates_length_of_for_infinite_maxima + Topic.validates_length_of(:title, :within => 5..Float::INFINITY) + + t = Topic.new("title" => "1234") + assert t.invalid? + assert t.errors[:title].any? + + t.title = "12345" + assert t.valid? + + Topic.validates_length_of(:author_name, :maximum => Float::INFINITY) + + assert t.valid? + + t.author_name = "A very long author name that should still be valid." * 100 + assert t.valid? + end end |