aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations
diff options
context:
space:
mode:
authorAndriy Tyurnikov <Andriy.Tyurnikov@gmail.com>2011-03-10 19:50:55 +0200
committerSantiago Pastorino <santiago@wyeworks.com>2011-03-12 21:12:44 -0200
commitf48d3d4df6c8ff6ab544f5fe384af2a0552984d7 (patch)
tree148b5ef71ed3d8fbb02ad77b66f90a15848e4f38 /activemodel/test/cases/validations
parent015192560b7e81639430d7e46c410bf6a3cd9223 (diff)
downloadrails-f48d3d4df6c8ff6ab544f5fe384af2a0552984d7.tar.gz
rails-f48d3d4df6c8ff6ab544f5fe384af2a0552984d7.tar.bz2
rails-f48d3d4df6c8ff6ab544f5fe384af2a0552984d7.zip
length validation for fixnums
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activemodel/test/cases/validations')
-rw-r--r--activemodel/test/cases/validations/length_validation_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/length_validation_test.rb b/activemodel/test/cases/validations/length_validation_test.rb
index 1e6180a938..5e4f4f5cae 100644
--- a/activemodel/test/cases/validations/length_validation_test.rb
+++ b/activemodel/test/cases/validations/length_validation_test.rb
@@ -341,6 +341,17 @@ class LengthValidationTest < ActiveModel::TestCase
assert t.errors[:content].any?
assert_equal ["Your essay must be at least 5 words."], t.errors[:content]
end
+
+ def test_validates_length_of_for_fixnum
+ Topic.validates_length_of(:approved, :is => 4)
+
+ t = Topic.new("title" => "uhohuhoh", "content" => "whatever", :approved => 1)
+ assert t.invalid?
+ assert t.errors[:approved].any?
+
+ t = Topic.new("title" => "uhohuhoh", "content" => "whatever", :approved => 1234)
+ assert t.valid?
+ end
def test_validates_length_of_for_ruby_class
Person.validates_length_of :karma, :minimum => 5