Skip to content

Commit

Permalink
Failing test for validates_length_of, when both too_short and too_lon…
Browse files Browse the repository at this point in the history
…g messages are set [#5283 state:open]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
rohitarondekar authored and josevalim committed Aug 3, 2010
1 parent f01184a commit 621246f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions activemodel/test/cases/validations/length_validation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 621246f

Please sign in to comment.