aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/validations_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-15 12:29:08 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-15 12:29:08 +0000
commit846a1236bc3f02cc01515f7aa6ee986344ae53c8 (patch)
tree2c5986dc0e296924fff1fbc7c9a5e554e5073082 /activerecord/test/validations_test.rb
parent83c668f32ebd1508ab2c3182f8d3bece15dc711a (diff)
downloadrails-846a1236bc3f02cc01515f7aa6ee986344ae53c8.tar.gz
rails-846a1236bc3f02cc01515f7aa6ee986344ae53c8.tar.bz2
rails-846a1236bc3f02cc01515f7aa6ee986344ae53c8.zip
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
Diffstat (limited to 'activerecord/test/validations_test.rb')
-rwxr-xr-xactiverecord/test/validations_test.rb14
1 files changed, 14 insertions, 0 deletions
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