diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-16 16:59:04 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-16 16:59:04 -0300 |
commit | cfd7f4e9a09df137f1e78ae7194e969e4bacfd87 (patch) | |
tree | 633ea06abec347363d73548163f9fe8f83531a2f /activemodel/test | |
parent | 2a42b12d3b2ccfbdd14893cbc73f78ab229a34c2 (diff) | |
parent | 2e4f7986b8ec90d7b41c385388be21b8cee79b9c (diff) | |
download | rails-cfd7f4e9a09df137f1e78ae7194e969e4bacfd87.tar.gz rails-cfd7f4e9a09df137f1e78ae7194e969e4bacfd87.tar.bz2 rails-cfd7f4e9a09df137f1e78ae7194e969e4bacfd87.zip |
Merge pull request #7024 from bogdan/strict_validation_custom_exception
AM::Validation#validates: custom exception for :strict option
Conflicts:
activemodel/CHANGELOG.md
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/validations_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
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 |