mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
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]
This commit is contained in:
committed by
Michael Koziarski
parent
80747e9db1
commit
2b8be761e4
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user