From 9b610049bb4f73dbcdc670879683ec2a1a2ab780 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 5 Sep 2010 21:20:54 -0300 Subject: Cleanup deprecation warnings in active record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activerecord/test/cases/callbacks_test.rb | 17 ++++++------ activerecord/test/cases/named_scope_test.rb | 4 --- activerecord/test/cases/validations_test.rb | 43 ----------------------------- 3 files changed, 8 insertions(+), 56 deletions(-) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb index 8a84f19836..7f4d25790b 100644 --- a/activerecord/test/cases/callbacks_test.rb +++ b/activerecord/test/cases/callbacks_test.rb @@ -16,6 +16,7 @@ class CallbackDeveloper < ActiveRecord::Base define_method(callback_method) do self.history << [callback_method, :method] end + send(callback_method, :"#{callback_method}") end def callback_object(callback_method) @@ -27,15 +28,13 @@ class CallbackDeveloper < ActiveRecord::Base end end - ActiveSupport::Deprecation.silence do - ActiveRecord::Callbacks::CALLBACKS.each do |callback_method| - next if callback_method.to_s =~ /^around_/ - define_callback_method(callback_method) - send(callback_method, callback_string(callback_method)) - send(callback_method, callback_proc(callback_method)) - send(callback_method, callback_object(callback_method)) - send(callback_method) { |model| model.history << [callback_method, :block] } - end + ActiveRecord::Callbacks::CALLBACKS.each do |callback_method| + next if callback_method.to_s =~ /^around_/ + define_callback_method(callback_method) + send(callback_method, callback_string(callback_method)) + send(callback_method, callback_proc(callback_method)) + send(callback_method, callback_object(callback_method)) + send(callback_method) { |model| model.history << [callback_method, :block] } end def history diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index 3d6975d0b5..cc4438395e 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -394,10 +394,6 @@ class NamedScopeTest < ActiveRecord::TestCase end end - def test_deprecated_named_scope_method - assert_deprecated('named_scope has been deprecated') { Topic.named_scope :deprecated_named_scope } - end - def test_named_scopes_on_relations # Topic.replied approved_topics = Topic.scoped.approved.order('id DESC') diff --git a/activerecord/test/cases/validations_test.rb b/activerecord/test/cases/validations_test.rb index fd771ef4be..c3e494866b 100644 --- a/activerecord/test/cases/validations_test.rb +++ b/activerecord/test/cases/validations_test.rb @@ -13,24 +13,6 @@ class ProtectedPerson < ActiveRecord::Base attr_protected :first_name end -class DeprecatedPerson < ActiveRecord::Base - set_table_name 'people' - - private - - def validate - errors[:name] << "always invalid" - end - - def validate_on_create - errors[:name] << "invalid on create" - end - - def validate_on_update - errors[:name] << "invalid on update" - end -end - class ValidationsTest < ActiveRecord::TestCase fixtures :topics, :developers @@ -141,14 +123,6 @@ class ValidationsTest < ActiveRecord::TestCase assert reply.save(:validate => false) end - def test_deprecated_create_without_validation - reply = WrongReply.new - assert !reply.save - assert_deprecated do - assert reply.save(false) - end - end - def test_validates_acceptance_of_with_non_existant_table Object.const_set :IncorporealModel, Class.new(ActiveRecord::Base) @@ -170,23 +144,6 @@ class ValidationsTest < ActiveRecord::TestCase assert topic["approved"] end - def test_validate_is_deprecated_on_create - p = DeprecatedPerson.new - assert_deprecated do - assert !p.valid? - end - assert_equal ["always invalid", "invalid on create"], p.errors[:name] - end - - def test_validate_is_deprecated_on_update - p = DeprecatedPerson.new(:first_name => "David") - assert p.save(:validate => false) - assert_deprecated do - assert !p.valid? - end - assert_equal ["always invalid", "invalid on update"], p.errors[:name] - end - def test_validators assert_equal 1, Parrot.validators.size assert_equal 1, Company.validators.size -- cgit v1.2.3