From 2e4f7986b8ec90d7b41c385388be21b8cee79b9c Mon Sep 17 00:00:00 2001 From: Bogdan Gusiev Date: Mon, 6 Aug 2012 13:45:27 +0300 Subject: AM::Validation#validates: ability to pass custom exception to `:strict` option --- activemodel/test/cases/validations_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'activemodel/test/cases') diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index 8ea9745fbf..a9d32808da 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -11,6 +11,8 @@ require 'active_support/xml_mini' class ValidationsTest < ActiveModel::TestCase + class CustomStrictValidationException < StandardError; end + def setup Topic._validators.clear end @@ -323,6 +325,13 @@ class ValidationsTest < ActiveModel::TestCase end end + def test_strict_validation_custom_exception + Topic.validates_presence_of :title, :strict => CustomStrictValidationException + assert_raises CustomStrictValidationException do + Topic.new.valid? + end + end + def test_validates_with_bang Topic.validates! :title, :presence => true assert_raises ActiveModel::StrictValidationFailed do -- cgit v1.2.3