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:
|
# The validators hash can also handle regular expressions, ranges and arrays:
|
||||||
#
|
#
|
||||||
# validates :email, :format => /@/
|
# validates :email, :format => /@/
|
||||||
# validates :genre, :inclusion => %w(mail female)
|
# validates :gender, :inclusion => %w(mail female)
|
||||||
# validates :password, :length => 6..20
|
# validates :password, :length => 6..20
|
||||||
#
|
#
|
||||||
# Finally, the options :if, :unless, :on, :allow_blank and :allow_nil can be given
|
# Finally, the options :if, :unless, :on, :allow_blank and :allow_nil can be given
|
||||||
|
|
|
@ -70,20 +70,20 @@ class ValidatesTest < ActiveModel::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validates_with_array
|
def test_validates_with_array
|
||||||
Person.validates :genre, :inclusion => %w(m f)
|
Person.validates :gender, :inclusion => %w(m f)
|
||||||
person = Person.new
|
person = Person.new
|
||||||
assert person.invalid?
|
assert person.invalid?
|
||||||
assert_equal ['is not included in the list'], person.errors[:genre]
|
assert_equal ['is not included in the list'], person.errors[:gender]
|
||||||
person.genre = "m"
|
person.gender = "m"
|
||||||
assert person.valid?
|
assert person.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validates_with_range
|
def test_validates_with_range
|
||||||
Person.validates :password, :length => 6..20
|
Person.validates :karma, :length => 6..20
|
||||||
person = Person.new
|
person = Person.new
|
||||||
assert person.invalid?
|
assert person.invalid?
|
||||||
assert_equal ['is too short (minimum is 6 characters)'], person.errors[:password]
|
assert_equal ['is too short (minimum is 6 characters)'], person.errors[:karma]
|
||||||
person.password = '123456'
|
person.karma = 'something'
|
||||||
assert person.valid?
|
assert person.valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Person
|
||||||
include ActiveModel::Validations
|
include ActiveModel::Validations
|
||||||
extend ActiveModel::Translation
|
extend ActiveModel::Translation
|
||||||
|
|
||||||
attr_accessor :title, :karma, :salary, :genre, :password
|
attr_accessor :title, :karma, :salary, :gender
|
||||||
|
|
||||||
def condition_is_true
|
def condition_is_true
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in a new issue