diff options
author | rohit <rohit.arondekar@gmail.com> | 2010-08-03 16:28:55 +0530 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-03 15:11:51 +0200 |
commit | 621246f997887eccf61c1737c76b1eefc9217263 (patch) | |
tree | a849634dd5639b1e2af99049cdb5da06ea832ce4 /activemodel/test/cases | |
parent | f01184ad9e7efbbcdb8581c93b92e16c61c7a6bd (diff) | |
download | rails-621246f997887eccf61c1737c76b1eefc9217263.tar.gz rails-621246f997887eccf61c1737c76b1eefc9217263.tar.bz2 rails-621246f997887eccf61c1737c76b1eefc9217263.zip |
Failing test for validates_length_of, when both too_short and too_long messages are set [#5283 state:open]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/validations/length_validation_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/length_validation_test.rb b/activemodel/test/cases/validations/length_validation_test.rb index 012c5a2f37..1e6180a938 100644 --- a/activemodel/test/cases/validations/length_validation_test.rb +++ b/activemodel/test/cases/validations/length_validation_test.rb @@ -229,6 +229,20 @@ class LengthValidationTest < ActiveModel::TestCase 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") |