diff options
author | Frederick Cheung <frederick.cheung@gmail.com> | 2011-02-18 17:55:29 +0000 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-02-18 21:32:28 +0100 |
commit | fbfa30a1eeaaab22ac8f43a4137ec8282920fe15 (patch) | |
tree | 5c62421750867a456c0af4e0f4402b0c5568ade1 /activemodel/test | |
parent | 00418ac96bf5a25d3a7cf760499ec19ad3700007 (diff) | |
download | rails-fbfa30a1eeaaab22ac8f43a4137ec8282920fe15.tar.gz rails-fbfa30a1eeaaab22ac8f43a4137ec8282920fe15.tar.bz2 rails-fbfa30a1eeaaab22ac8f43a4137ec8282920fe15.zip |
Change validates inclusion to use cover? for Ranges in ruby 1.9 [#6453 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/validations/inclusion_validation_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/inclusion_validation_test.rb b/activemodel/test/cases/validations/inclusion_validation_test.rb index 0716b4f087..62f2ec785d 100644 --- a/activemodel/test/cases/validations/inclusion_validation_test.rb +++ b/activemodel/test/cases/validations/inclusion_validation_test.rb @@ -10,6 +10,15 @@ class InclusionValidationTest < ActiveModel::TestCase Topic.reset_callbacks(:validate) end + def test_validates_inclusion_of_range + Topic.validates_inclusion_of( :title, :in => 'aaa'..'bbb' ) + assert Topic.new("title" => "bbc", "content" => "abc").invalid? + assert Topic.new("title" => "aa", "content" => "abc").invalid? + assert Topic.new("title" => "aaa", "content" => "abc").valid? + assert Topic.new("title" => "abc", "content" => "abc").valid? + assert Topic.new("title" => "bbb", "content" => "abc").valid? + end + def test_validates_inclusion_of Topic.validates_inclusion_of( :title, :in => %w( a b c d e f g ) ) |