mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user