mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
validates method should not change options argument
This commit is contained in:
parent
5f8274efe1
commit
e84998cc21
2 changed files with 7 additions and 1 deletions
|
@ -80,7 +80,7 @@ module ActiveModel
|
|||
# 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 @@ class ValidationsTest < ActiveModel::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue