Added Base.validates_boundries_of that delegates to add_on_boundary_breaking #312 [Tobias Luetke]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@166 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2004-12-15 12:29:08 +00:00
parent 83c668f32e
commit 846a1236bc
3 changed files with 64 additions and 32 deletions

View File

@@ -189,4 +189,18 @@ class ValidationsTest < Test::Unit::TestCase
t2.title = "Now Im really also unique"
assert t2.save, "Should now save t2 as unique"
end
def test_validate_boundaries
Topic.validates_boundries_of(:title, :content, :within => 3..5)
t = Topic.create("title" => "a!", "content" => "I'm ooooooooh so very long")
assert !t.save
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)
t.title = "abe"
t.content = "mad"
assert t.save
end
end