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
This commit is contained in:
parent
cb0837a2b7
commit
9fd88d7939
|
@ -1,5 +1,7 @@
|
|||
*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 @@ module ActiveRecord
|
|||
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 @@ module MyApplication
|
|||
|
||||
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 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
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)
|
||||
|
||||
|
@ -627,6 +614,18 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
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 }
|
||||
t = Topic.new('title' => 'noreplies', 'content' => 'whatever')
|
||||
|
|
Loading…
Reference in New Issue