Skip to content
Browse files

Failing test for validates_length_of, when both too_short and too_lon…

…g messages are set [#5283 state:open]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent a44779e commit 257e9c4ec46c5045785081e3989bed9bc8d9b37a @rohit rohit committed with josevalim
Showing with 14 additions and 0 deletions.
  1. +14 −0 activemodel/test/cases/validations/length_validation_test.rb
View
14 activemodel/test/cases/validations/length_validation_test.rb
@@ -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")

0 comments on commit 257e9c4

Please sign in to comment.
Something went wrong with that request. Please try again.