aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/validations
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2011-02-05 16:33:00 -0800
committerCarl Lerche <me@carllerche.com>2011-02-05 16:33:00 -0800
commite9e9ed6b60a42a7c3afe3c4a9f8cf6d1e5422e59 (patch)
treee9d45b2dd7c00979fcc5bd36ce430ac5406c3bb0 /activemodel/test/cases/validations
parented7614aa7de2eaeba16c9af11cf09b4fd7ed6819 (diff)
downloadrails-e9e9ed6b60a42a7c3afe3c4a9f8cf6d1e5422e59.tar.gz
rails-e9e9ed6b60a42a7c3afe3c4a9f8cf6d1e5422e59.tar.bz2
rails-e9e9ed6b60a42a7c3afe3c4a9f8cf6d1e5422e59.zip
Be able to pass a validator method to #validates
Diffstat (limited to 'activemodel/test/cases/validations')
-rw-r--r--activemodel/test/cases/validations/with_validation_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations/with_validation_test.rb b/activemodel/test/cases/validations/with_validation_test.rb
index 6d825cd316..33efedcd7c 100644
--- a/activemodel/test/cases/validations/with_validation_test.rb
+++ b/activemodel/test/cases/validations/with_validation_test.rb
@@ -171,4 +171,16 @@ class ValidatesWithTest < ActiveModel::TestCase
assert topic.errors[:title].empty?
assert topic.errors[:content].empty?
end
+
+ test "validates_with can validate with an instance method" do
+ Topic.validates :title, :with => :my_validation
+
+ topic = Topic.new :title => "foo"
+ assert topic.valid?
+ assert topic.errors[:title].empty?
+
+ topic = Topic.new
+ assert !topic.valid?
+ assert_equal ['is missing'], topic.errors[:title]
+ end
end