提交 621246f9 编写于 作者: R rohit 提交者: José Valim

Failing test for validates_length_of, when both too_short and too_long...

Failing test for validates_length_of, when both too_short and too_long messages are set [#5283 state:open]
Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 f01184ad
......@@ -229,6 +229,20 @@ def test_validates_length_of_custom_errors_for_maximum_with_too_long
assert_equal ["hoo 5"], t.errors["title"]
end
def test_validates_length_of_custom_errors_for_both_too_short_and_too_long
Topic.validates_length_of :title, :minimum => 3, :maximum => 5, :too_short => 'too short', :too_long => 'too long'
t = Topic.new(:title => 'a')
assert t.invalid?
assert t.errors[:title].any?
assert_equal ['too short'], t.errors['title']
t = Topic.new(:title => 'aaaaaa')
assert t.invalid?
assert t.errors[:title].any?
assert_equal ['too long'], t.errors['title']
end
def test_validates_length_of_custom_errors_for_is_with_message
Topic.validates_length_of( :title, :is=>5, :message=>"boo %{count}" )
t = Topic.new("title" => "uhohuhoh", "content" => "whatever")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册