Permalink
Browse files

validates method should not change options argument

  • Loading branch information...
1 parent 5f8274e commit e84998cc212c6c96c279ebd41619f51054f5642f @dreamfall dreamfall committed Jan 17, 2012
@@ -80,7 +80,7 @@ module ClassMethods
# validates :password, :presence => true, :confirmation => true, :if => :password_required?
#
def validates(*attributes)
- defaults = attributes.extract_options!
+ defaults = attributes.extract_options!.dup
validations = defaults.slice!(*_validates_default_keys)
raise ArgumentError, "You need to supply at least one attribute" if attributes.empty?
@@ -330,4 +330,10 @@ def test_validates_with_bang
Topic.new.valid?
end
end
+
+ def test_does_not_modify_options_argument
+ options = {:presence => true}
+ Topic.validates :title, options
+ assert_equal({:presence => true}, options)
+ end
end

0 comments on commit e84998c

Please sign in to comment.