aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/validations_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-03-31 01:49:31 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-03-31 01:49:31 +0000
commit3aaf60def848785a9c9c05c426359fa69888ef13 (patch)
tree9e800bd8f557daf8872a7440d68e17b9569328c7 /activerecord/test/cases/validations_test.rb
parent6b9448cdd227ef3adbe2f31ecaf64bc7ef062103 (diff)
downloadrails-3aaf60def848785a9c9c05c426359fa69888ef13.tar.gz
rails-3aaf60def848785a9c9c05c426359fa69888ef13.tar.bz2
rails-3aaf60def848785a9c9c05c426359fa69888ef13.zip
Add :message option to validates_numericality_of. Closes #11456 [miloops, mdempfle]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9158 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/cases/validations_test.rb')
-rwxr-xr-xactiverecord/test/cases/validations_test.rb14
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|