aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authormiloops <miloops@gmail.com>2008-09-16 11:14:23 -0300
committerMichael Koziarski <michael@koziarski.com>2009-02-01 14:58:17 +1300
commit2b8be761e476c103e94f8567c3880ea7363dfec0 (patch)
tree8409ff74cf5cf14581b8204f756aaddd6da25f3c /activerecord/test/cases
parent80747e9db16ec60eb0d95b510baf051612ec0768 (diff)
downloadrails-2b8be761e476c103e94f8567c3880ea7363dfec0.tar.gz
rails-2b8be761e476c103e94f8567c3880ea7363dfec0.tar.bz2
rails-2b8be761e476c103e94f8567c3880ea7363dfec0.zip
validate_length_of should use custom message if given when using in or within.
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1057 state:committed]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/validations_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb
index 380d8ac260..cbb184131f 100644
--- a/activerecord/test/cases/validations_test.rb
+++ b/activerecord/test/cases/validations_test.rb
@@ -958,6 +958,19 @@ class ValidationsTest < ActiveRecord::TestCase
assert_equal "boo 5", t.errors["title"]
end
+ def test_validates_length_of_custom_errors_for_in
+ Topic.validates_length_of(:title, :in => 10..20, :message => "hoo {{count}}")
+ t = Topic.create("title" => "uhohuhoh", "content" => "whatever")
+ assert !t.valid?
+ assert t.errors.on(:title)
+ assert_equal "hoo 10", t.errors["title"]
+
+ t = Topic.create("title" => "uhohuhohuhohuhohuhohuhohuhohuhoh", "content" => "whatever")
+ assert !t.valid?
+ assert t.errors.on(:title)
+ assert_equal "hoo 20", t.errors["title"]
+ end
+
def test_validates_length_of_custom_errors_for_maximum_with_too_long
Topic.validates_length_of( :title, :maximum=>5, :too_long=>"hoo {{count}}" )
t = Topic.create("title" => "uhohuhoh", "content" => "whatever")