aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2009-09-01 12:19:09 -0700
committerCarl Lerche <carllerche@mac.com>2009-09-01 12:19:09 -0700
commit016b1d3596ce12367edac8bb442f5c630a453ecf (patch)
tree49435918ebb372f617c3cc95bc495f6dd5c12d24 /activemodel/test
parent22d5e3d89d619acb9179dfcdd33f1afaee9567ca (diff)
parentda636809daca9c338200811d3590e446f57c8e81 (diff)
downloadrails-016b1d3596ce12367edac8bb442f5c630a453ecf.tar.gz
rails-016b1d3596ce12367edac8bb442f5c630a453ecf.tar.bz2
rails-016b1d3596ce12367edac8bb442f5c630a453ecf.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/validations/numericality_validation_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/numericality_validation_test.rb b/activemodel/test/cases/validations/numericality_validation_test.rb
index 0af6eb69ce..d3201966dc 100644
--- a/activemodel/test/cases/validations/numericality_validation_test.rb
+++ b/activemodel/test/cases/validations/numericality_validation_test.rb
@@ -106,6 +106,24 @@ class NumericalityValidationTest < ActiveModel::TestCase
valid!([2])
end
+ def test_validates_numericality_with_proc
+ Topic.send(:define_method, :min_approved, lambda { 5 })
+ Topic.validates_numericality_of :approved, :greater_than_or_equal_to => Proc.new {|topic| topic.min_approved }
+
+ invalid!([3, 4])
+ valid!([5, 6])
+ Topic.send(:remove_method, :min_approved)
+ end
+
+ def test_validates_numericality_with_symbol
+ Topic.send(:define_method, :max_approved, lambda { 5 })
+ Topic.validates_numericality_of :approved, :less_than_or_equal_to => :max_approved
+
+ invalid!([6])
+ valid!([4, 5])
+ Topic.send(:remove_method, :max_approved)
+ end
+
def test_validates_numericality_with_numeric_message
Topic.validates_numericality_of :approved, :less_than => 4, :message => "smaller than {{count}}"
topic = Topic.new("title" => "numeric test", "approved" => 10)