diff options
Diffstat (limited to 'activerecord/test/cases')
-rwxr-xr-x | activerecord/test/cases/validations_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index 3d83b8d4d1..d5b8b4d88b 100755 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -1405,6 +1405,20 @@ class ValidatesNumericalityTest < ActiveRecord::TestCase valid!([2]) end + def test_validates_numericality_with_numeric_message + Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than %d" + topic = Topic.new("title" => "numeric test", "approved" => 10) + + assert !topic.valid? + assert_equal "smaller than 4", topic.errors.on(:approved) + + Topic.validates_numericality_of :approved, :greater_than => 4, :message => "greater than %d" + topic = Topic.new("title" => "numeric test", "approved" => 1) + + assert !topic.valid? + assert_equal "greater than 4", topic.errors.on(:approved) + end + private def invalid!(values, error=nil) with_each_topic_approved_value(values) do |topic, value| |