1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

r3603@asus: jeremy | 2005-09-26 19:10:00 -0700

Add unit tests for nil assigned to validates_size_of :attr, :within


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2354 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2005-09-26 22:40:51 +00:00
parent 1d738cab80
commit 54adccda08

View file

@ -396,15 +396,20 @@ class ValidationsTest < Test::Unit::TestCase
def test_validates_length_of_using_within def test_validates_length_of_using_within
Topic.validates_length_of(:title, :content, :within => 3..5) Topic.validates_length_of(:title, :content, :within => 3..5)
t = Topic.create("title" => "a!", "content" => "I'm ooooooooh so very long") t = Topic.new("title" => "a!", "content" => "I'm ooooooooh so very long")
assert !t.save assert !t.valid?
assert_equal "is too short (min is 3 characters)", t.errors.on(:title) assert_equal "is too short (min is 3 characters)", t.errors.on(:title)
assert_equal "is too long (max is 5 characters)", t.errors.on(:content) assert_equal "is too long (max is 5 characters)", t.errors.on(:content)
t.title = nil
t.content = nil
assert !t.valid?
assert_equal "is too short (min is 3 characters)", t.errors.on(:title)
assert_equal "is too short (min is 3 characters)", t.errors.on(:content)
t.title = "abe" t.title = "abe"
t.content = "mad" t.content = "mad"
assert t.save assert t.valid?
end end
def test_optionally_validates_length_of_using_within def test_optionally_validates_length_of_using_within