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

Fix typos and add tests to ensure they will be caught the next time.

This commit is contained in:
José Valim 2010-01-11 23:37:48 +01:00
parent cccb998800
commit b078f7fd39
3 changed files with 11 additions and 3 deletions

View file

@ -10,8 +10,8 @@ module ActiveModel
end
def check_validity!
keys = CHECKS.keys - [:odd, :event]
options.slice(*keys) do |option, value|
keys = CHECKS.keys - [:odd, :even]
options.slice(*keys).each do |option, value|
next if value.is_a?(Numeric) || value.is_a?(Proc) || value.is_a?(Symbol)
raise ArgumentError, ":#{option} must be a number, a symbol or a proc"
end

View file

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

View file

@ -154,6 +154,14 @@ class NumericalityValidationTest < ActiveModel::TestCase
Person.reset_callbacks(:validate)
end
def test_validates_numericality_with_invalid_args
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :greater_than_or_equal_to => "foo" }
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :less_than_or_equal_to => "foo" }
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :greater_than => "foo" }
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :less_than => "foo" }
assert_raise(ArgumentError){ Topic.validates_numericality_of :approved, :equal_to => "foo" }
end
private
def invalid!(values, error = nil)