1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix typo by renaming :genre to :gender.

This commit is contained in:
José Valim 2010-01-09 00:17:16 +01:00
parent 93898b389b
commit 017f5d5308
3 changed files with 8 additions and 8 deletions

View file

@ -54,7 +54,7 @@ module ActiveModel
# The validators hash can also handle regular expressions, ranges and arrays:
#
# validates :email, :format => /@/
# validates :genre, :inclusion => %w(mail female)
# validates :gender, :inclusion => %w(mail female)
# validates :password, :length => 6..20
#
# Finally, the options :if, :unless, :on, :allow_blank and :allow_nil can be given

View file

@ -70,20 +70,20 @@ class ValidatesTest < ActiveModel::TestCase
end
def test_validates_with_array
Person.validates :genre, :inclusion => %w(m f)
Person.validates :gender, :inclusion => %w(m f)
person = Person.new
assert person.invalid?
assert_equal ['is not included in the list'], person.errors[:genre]
person.genre = "m"
assert_equal ['is not included in the list'], person.errors[:gender]
person.gender = "m"
assert person.valid?
end
def test_validates_with_range
Person.validates :password, :length => 6..20
Person.validates :karma, :length => 6..20
person = Person.new
assert person.invalid?
assert_equal ['is too short (minimum is 6 characters)'], person.errors[:password]
person.password = '123456'
assert_equal ['is too short (minimum is 6 characters)'], person.errors[:karma]
person.karma = 'something'
assert person.valid?
end

View file

@ -2,7 +2,7 @@ class Person
include ActiveModel::Validations
extend ActiveModel::Translation
attr_accessor :title, :karma, :salary, :genre, :password
attr_accessor :title, :karma, :salary, :gender
def condition_is_true
true