Rank validations
authorNguyễn Thái Ngọc Duy <[email protected]>
Sun, 20 Aug 2006 01:29:47 +0000 (20 08:29 +0700)
committerNguyễn Thái Ngọc Duy <[email protected]>
Sun, 20 Aug 2006 01:29:47 +0000 (20 08:29 +0700)
app/models/rank.rb
test/unit/rank_test.rb

index f80a59a..2fb9e52 100644 (file)
@@ -1,2 +1,3 @@
 class Rank < ActiveRecord::Base
+  validates_length_of :rank, :within => 1..50
 end
index cf0f1a0..91758c0 100644 (file)
@@ -3,8 +3,15 @@ require File.dirname(__FILE__) + '/../test_helper'
 class RankTest < Test::Unit::TestCase
   fixtures :ranks
 
-  # Replace this with your real tests.
   def test_truth
-    assert true
+    r = Rank.new
+    r.rank = 'a'
+    assert r.save == true
+    r.rank = 'a'*50
+    assert r.save == true
+    r.rank = ''
+    assert r.save == false
+    r.rank = 'a'*51
+    assert r.save == false
   end
 end