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:
parent
93898b389b
commit
017f5d5308
3 changed files with 8 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue