aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-10-09 01:42:09 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-10-09 01:42:09 +0000
commit9fd88d793998ea3a15a916ce7175f1bb2cd264fe (patch)
tree5e783a553d9a62fd49d35533f4bdb6c142b64461 /activerecord
parentcb0837a2b7e7d5ba46494acaecc0f5798964ecf7 (diff)
downloadrails-9fd88d793998ea3a15a916ce7175f1bb2cd264fe.tar.gz
rails-9fd88d793998ea3a15a916ce7175f1bb2cd264fe.tar.bz2
rails-9fd88d793998ea3a15a916ce7175f1bb2cd264fe.zip
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
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/validations.rb1
-rw-r--r--activerecord/test/fixtures/company_in_module.rb6
-rwxr-xr-xactiverecord/test/validations_test.rb25
4 files changed, 16 insertions, 18 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index f2b377a20b..75cc342f90 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -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]
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index 43552e092c..6fc90aa291 100755
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -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)
diff --git a/activerecord/test/fixtures/company_in_module.rb b/activerecord/test/fixtures/company_in_module.rb
index 1eb2b2bd93..feb3210c02 100644
--- a/activerecord/test/fixtures/company_in_module.rb
+++ b/activerecord/test/fixtures/company_in_module.rb
@@ -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
diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb
index d0d644a567..0d47eb15f9 100755
--- a/activerecord/test/validations_test.rb
+++ b/activerecord/test/validations_test.rb
@@ -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)
@@ -626,6 +613,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 }