diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-07-20 14:12:01 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-07-20 14:19:26 -0300 |
commit | 089371ac23f35550676e6c5ac99e789a97101475 (patch) | |
tree | db23dfe0a0799edb35ee459d629f7bc673ecd338 /activemodel/test/cases/validations/inclusion_validation_test.rb | |
parent | a79bfa92e7bdc31b346d13ee5447d3fdac382bfb (diff) | |
download | rails-089371ac23f35550676e6c5ac99e789a97101475.tar.gz rails-089371ac23f35550676e6c5ac99e789a97101475.tar.bz2 rails-089371ac23f35550676e6c5ac99e789a97101475.zip |
`validates_inclusion_of` and `validates_exclusion_of` now accept
`:within` option as alias of `:in` as documented.
Fix #7118
Diffstat (limited to 'activemodel/test/cases/validations/inclusion_validation_test.rb')
-rw-r--r-- | activemodel/test/cases/validations/inclusion_validation_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/inclusion_validation_test.rb b/activemodel/test/cases/validations/inclusion_validation_test.rb index 851d345eab..c57fa75faf 100644 --- a/activemodel/test/cases/validations/inclusion_validation_test.rb +++ b/activemodel/test/cases/validations/inclusion_validation_test.rb @@ -60,6 +60,16 @@ class InclusionValidationTest < ActiveModel::TestCase assert_equal ["option uhoh is not in the list"], t.errors[:title] end + def test_validates_inclusion_of_with_within_option + Topic.validates_inclusion_of( :title, :within => %w( a b c d e f g ) ) + + assert Topic.new("title" => "a", "content" => "abc").valid? + + t = Topic.new("title" => "uhoh", "content" => "abc") + assert t.invalid? + assert t.errors[:title].any? + end + def test_validates_inclusion_of_for_ruby_class Person.validates_inclusion_of :karma, :in => %w( abe monkey ) |