提交 9fd88d79 编写于 作者: D David Heinemeier Hansson

Deprecated add_on_boundary_breaking (use validates_length_of instead) (closes #6292) [BobSilva]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5255 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 cb0837a2
*SVN*
* Deprecated add_on_boundary_breaking (use validates_length_of instead) #6292 [BobSilva]
* The has_many create method works with polymorphic associations. #6361 [Dan Peterson]
* MySQL: introduce Mysql::Result#all_hashes to support further optimization. #5581 [Stefan Kaes]
......
......@@ -87,6 +87,7 @@ def add_on_boundary_breaking(attributes, range, too_long_msg = @@default_error_m
end
alias :add_on_boundry_breaking :add_on_boundary_breaking
deprecate :add_on_boundary_breaking, :add_on_boundry_breaking
# Returns true if the specified +attribute+ has errors associated with it.
def invalid?(attribute)
......
......@@ -21,11 +21,7 @@ class Client < Company
class Developer < ActiveRecord::Base
has_and_belongs_to_many :projects
protected
def validate
errors.add_on_boundary_breaking("name", 3..20)
end
validates_length_of :name, :within => (3..20)
end
class Project < ActiveRecord::Base
......
......@@ -165,19 +165,6 @@ def test_validates_each
perform = false
end
def test_errors_on_boundary_breaking
developer = Developer.new("name" => "xs")
assert !developer.save
assert_equal "is too short (minimum is 3 characters)", developer.errors.on("name")
developer.name = "All too very long for this boundary, it really is"
assert !developer.save
assert_equal "is too long (maximum is 20 characters)", developer.errors.on("name")
developer.name = "Just right"
assert developer.save
end
def test_no_title_confirmation
Topic.validates_confirmation_of(:title)
......@@ -626,6 +613,18 @@ def test_validates_length_with_globaly_modified_error_message
assert_equal 'tu est trops petit hombre 10', t.errors['title']
end
def test_add_on_boundary_breaking_is_deprecated
t = Topic.new('title' => 'noreplies', 'content' => 'whatever')
class << t
def validate
errors.add_on_boundary_breaking('title', 1..6)
end
end
assert_deprecated 'add_on_boundary_breaking' do
assert !t.valid?
end
end
def test_validates_size_of_association
assert_nothing_raised { Topic.validates_size_of :replies, :minimum => 1 }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册