Permalink
Browse files

Merge pull request #6517 from purcell/validates-false-value

Don't enable validations when passing false hash values to ActiveModel.validates
  • Loading branch information...
2 parents 5acb10d + b3ccd7b commit f5e26bcb1a9a44b763d4d9ff117705312d1c650f @josevalim josevalim committed May 28, 2012
View
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Passing false hash values to `validates` will no longer enable the corresponding validators *Steve Purcell*
+
* `ConfirmationValidator` error messages will attach to `:#{attribute}_confirmation` instead of `attribute` *Brian Cardarella*
* Added ActiveModel::Model, a mixin to make Ruby objects work with AP out of box *Guillermo Iguaran*
@@ -88,6 +88,7 @@ def validates(*attributes)
defaults.merge!(:attributes => attributes)
validations.each do |key, options|
+ next unless options
key = "#{key.to_s.camelize}Validator"
begin
@@ -330,6 +330,11 @@ def test_validates_with_bang
end
end
+ def test_validates_with_false_hash_value
+ Topic.validates :title, :presence => false
+ assert Topic.new.valid?
+ end
+
def test_strict_validation_error_message
Topic.validates :title, :strict => true, :presence => true

0 comments on commit f5e26bc

Please sign in to comment.