diff options
author | Adam Keys <adam@therealadam.com> | 2009-08-08 16:35:03 -0500 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-08-08 23:42:18 +0100 |
commit | 5632b36701ad9514d596c558877cd74c14c1d54b (patch) | |
tree | 5f8bd9d896c63cde9e73cb65b1f33a71b08f3c1d /activemodel/test | |
parent | bee3e099bd3f4038f8a4122ad48446a232cbf21a (diff) | |
download | rails-5632b36701ad9514d596c558877cd74c14c1d54b.tar.gz rails-5632b36701ad9514d596c558877cd74c14c1d54b.tar.bz2 rails-5632b36701ad9514d596c558877cd74c14c1d54b.zip |
Fix exclusive range patch to use begin/end instead of min/max. [#2981 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activemodel/test')
-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 499f6a5e31..2c97b762f1 100644 --- a/activemodel/test/cases/validations/length_validation_test.rb +++ b/activemodel/test/cases/validations/length_validation_test.rb @@ -112,6 +112,20 @@ class LengthValidationTest < ActiveModel::TestCase assert t.valid? end + def test_validates_length_of_using_within_with_exclusive_range + Topic.validates_length_of(:title, :within => 4...10) + + t = Topic.new("title" => "9 chars!!") + assert t.valid? + + t.title = "Now I'm 10" + assert !t.valid? + assert_equal ["is too long (maximum is 9 characters)"], t.errors[:title] + + t.title = "Four" + assert t.valid? + end + def test_optionally_validates_length_of_using_within Topic.validates_length_of :title, :content, :within => 3..5, :allow_nil => true |