aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2010-09-05 21:20:54 -0300
committerJosé Valim <jose.valim@gmail.com>2010-09-06 13:39:55 +0200
commit9b610049bb4f73dbcdc670879683ec2a1a2ab780 (patch)
treef93f129985ed38eb8bd578ca52d16aae21192377 /activerecord
parenta18b73b43c07d031c9a660bc119835dcb6db85cf (diff)
downloadrails-9b610049bb4f73dbcdc670879683ec2a1a2ab780.tar.gz
rails-9b610049bb4f73dbcdc670879683ec2a1a2ab780.tar.bz2
rails-9b610049bb4f73dbcdc670879683ec2a1a2ab780.zip
Cleanup deprecation warnings in active record
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/base.rb24
-rw-r--r--activerecord/lib/active_record/callbacks.rb17
-rw-r--r--activerecord/lib/active_record/named_scope.rb5
-rw-r--r--activerecord/lib/active_record/validations.rb13
-rw-r--r--activerecord/test/cases/callbacks_test.rb17
-rw-r--r--activerecord/test/cases/named_scope_test.rb4
-rw-r--r--activerecord/test/cases/validations_test.rb43
7 files changed, 11 insertions, 112 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index c3a34ae104..47394de3c1 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -15,7 +15,6 @@ require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/string/behavior'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/module/delegation'
-require 'active_support/core_ext/module/deprecation'
require 'active_support/core_ext/module/introspection'
require 'active_support/core_ext/object/duplicable'
require 'active_support/core_ext/object/blank'
@@ -316,18 +315,6 @@ module ActiveRecord #:nodoc:
# a class and instance level by calling +logger+.
cattr_accessor :logger, :instance_writer => false
- class << self
- def reset_subclasses #:nodoc:
- ActiveSupport::Deprecation.warn 'ActiveRecord::Base.reset_subclasses no longer does anything in Rails 3. It will be removed in the final release; please update your apps and plugins.', caller
- end
-
- def subclasses
- descendants
- end
-
- deprecate :subclasses => :descendants
- end
-
##
# :singleton-method:
# Contains the database configuration - as is typically stored in config/database.yml -
@@ -429,13 +416,6 @@ module ActiveRecord #:nodoc:
self.default_scoping = []
class << self # Class methods
- def colorize_logging(*args)
- ActiveSupport::Deprecation.warn "ActiveRecord::Base.colorize_logging and " <<
- "config.active_record.colorize_logging are deprecated. Please use " <<
- "ActiveRecord::LogSubscriber.colorize_logging or config.colorize_logging instead", caller
- end
- alias :colorize_logging= :colorize_logging
-
delegate :find, :first, :last, :all, :destroy, :destroy_all, :exists?, :delete, :delete_all, :update, :update_all, :to => :scoped
delegate :find_each, :find_in_batches, :to => :scoped
delegate :select, :group, :order, :reorder, :limit, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :create_with, :to => :scoped
@@ -879,8 +859,8 @@ module ActiveRecord #:nodoc:
# It is recommended to use block form of unscoped because chaining unscoped with <tt>named_scope</tt>
# does not work. Assuming that <tt>published</tt> is a <tt>named_scope</tt> following two statements are same.
#
- # Post.unscoped.published
- # Post.published
+ # Post.unscoped.published
+ # Post.published
def unscoped #:nodoc:
block_given? ? relation.scoping { yield } : relation
end
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index fd71d7db4e..49671a1042 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -246,16 +246,6 @@ module ActiveRecord
define_model_callbacks :save, :create, :update, :destroy
end
- module ClassMethods
- def method_added(meth)
- super
- if CALLBACKS.include?(meth.to_sym)
- ActiveSupport::Deprecation.warn("Base##{meth} has been deprecated, please use Base.#{meth} :method instead", caller[0,1])
- send(meth.to_sym, meth.to_sym)
- end
- end
- end
-
def destroy #:nodoc:
_run_destroy_callbacks { super }
end
@@ -264,13 +254,6 @@ module ActiveRecord
_run_touch_callbacks { super }
end
- def deprecated_callback_method(symbol) #:nodoc:
- if respond_to?(symbol, true)
- ActiveSupport::Deprecation.warn("Overwriting #{symbol} in your models has been deprecated, please use Base##{symbol} :method_name instead")
- send(symbol)
- end
- end
-
private
def create_or_update #:nodoc:
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb
index 3de4c40977..6ab84df25b 100644
--- a/activerecord/lib/active_record/named_scope.rb
+++ b/activerecord/lib/active_record/named_scope.rb
@@ -120,11 +120,6 @@ module ActiveRecord
singleton_class.send(:redefine_method, name, &scopes[name])
end
- def named_scope(*args, &block)
- ActiveSupport::Deprecation.warn("Base.named_scope has been deprecated, please use Base.scope instead", caller)
- scope(*args, &block)
- end
-
protected
def valid_scope_name?(name)
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index b98fd353aa..e4c366ea63 100644
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -53,24 +53,13 @@ module ActiveRecord
def valid?(context = nil)
context ||= (new_record? ? :create : :update)
output = super(context)
-
- deprecated_callback_method(:validate)
- deprecated_callback_method(:"validate_on_#{context}")
-
errors.empty? && output
end
protected
def perform_validations(options={})
- perform_validation = case options
- when Hash
- options[:validate] != false
- else
- ActiveSupport::Deprecation.warn "save(#{options}) is deprecated, please give save(:validate => #{options}) instead", caller
- options
- end
-
+ perform_validation = options[:validate] != false
if perform_validation
valid?(options.is_a?(Hash) ? options[:context] : nil)
else
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