aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-02 19:14:52 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-02 19:14:52 -0700
commit4e9f53f9736544f070e75e516c71137b7eb49a7a (patch)
tree6036f60855b79451525e29f310ac5923d2e2b45c /activemodel/test
parent6b802cdb4f5b84e1bf49aaeb0e994b3be6028af9 (diff)
parent4f9b59dba0fe9d90f53417f0d4f1bc63679d556a (diff)
downloadrails-4e9f53f9736544f070e75e516c71137b7eb49a7a.tar.gz
rails-4e9f53f9736544f070e75e516c71137b7eb49a7a.tar.bz2
rails-4e9f53f9736544f070e75e516c71137b7eb49a7a.zip
Merge pull request #7826 from sikachu/master-validators-kind
Make `.validators_on` accept `:kind` option
Diffstat (limited to 'activemodel/test')
-rw-r--r--activemodel/test/cases/validations_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb
index a9d32808da..66d9e51854 100644
--- a/activemodel/test/cases/validations_test.rb
+++ b/activemodel/test/cases/validations_test.rb
@@ -287,6 +287,14 @@ class ValidationsTest < ActiveModel::TestCase
assert_equal [], Topic.validators_on(:author_name)
end
+ def test_list_of_validators_on_an_attribute_based_on_kind
+ Topic.validates_presence_of :title, :content
+ Topic.validates_length_of :title, :minimum => 2
+
+ assert_equal Topic.validators_on(:title).select { |v| v.kind == :presence },
+ Topic.validators_on(:title, kind: :presence)
+ end
+
def test_validations_on_the_instance_level
auto = Automobile.new