From 846a1236bc3f02cc01515f7aa6ee986344ae53c8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 15 Dec 2004 12:29:08 +0000 Subject: 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 --- activerecord/test/validations_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb index 06b4740012..af7c975de1 100755 --- a/activerecord/test/validations_test.rb +++ b/activerecord/test/validations_test.rb @@ -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 \ No newline at end of file -- cgit v1.2.3