diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index f2b377a20b6829b33661f24d82a37f965bb8c2c1..75cc342f9002489d12bc5beee8d554f7e96dcc44 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 43552e092cc50701db6bb2abcff244d3bfa8991b..6fc90aa29114e70a606952ec7fcfbb7b9ce1d757 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -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) diff --git a/activerecord/test/fixtures/company_in_module.rb b/activerecord/test/fixtures/company_in_module.rb index 1eb2b2bd93afee9d6735cd8136b6d3de7d0d5fef..feb3210c022471fb94653a2895eb96756ebc0bb9 100644 --- a/activerecord/test/fixtures/company_in_module.rb +++ b/activerecord/test/fixtures/company_in_module.rb @@ -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 diff --git a/activerecord/test/validations_test.rb b/activerecord/test/validations_test.rb index d0d644a567cfc72ff22311323377d440d9f73fe1..0d47eb15f953b52c5ea1902f3548567f80eded34 100755 --- a/activerecord/test/validations_test.rb +++ b/activerecord/test/validations_test.rb @@ -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 }