From a5631a56742b8fabff2cdeb3b6f013e3f885aa89 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 16 Nov 2006 06:45:06 +0000 Subject: [PATCH] Merge [5535], [5536] from trunk. git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5537 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ .../lib/action_controller/components.rb | 2 ++ actionpack/test/controller/components_test.rb | 4 +++- .../lib/active_support/deprecation.rb | 20 ++++++++++++++++--- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 7702051cece94..3da9d0ad4c983 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Deprecate standalone components. [Jeremy Kemper] + * Always clear model associations from session. #4795 [sd@notso.net, andylien@gmail.com] * Update to Prototype 1.5.0_rc2. [Sam Stephenson] diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb index a7f5be2e6a0aa..e6b0194647f4c 100644 --- a/actionpack/lib/action_controller/components.rb +++ b/actionpack/lib/action_controller/components.rb @@ -80,6 +80,8 @@ def uses_component_template_root self.template_root = path_of_controller_root end + + deprecate :uses_component_template_root => 'Components are deprecated and will be removed in Rails 2.0.' end module InstanceMethods diff --git a/actionpack/test/controller/components_test.rb b/actionpack/test/controller/components_test.rb index 57e3b21acff5f..c71de444dc7e2 100644 --- a/actionpack/test/controller/components_test.rb +++ b/actionpack/test/controller/components_test.rb @@ -143,6 +143,8 @@ def self.caller class UsesComponentTemplateRootTest < Test::Unit::TestCase def test_uses_component_template_root - assert_equal './test/fixtures/', A::B::C::NestedController.uses_component_template_root + assert_deprecated 'uses_component_template_root' do + assert_equal './test/fixtures/', A::B::C::NestedController.uses_component_template_root + end end end diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 621cc14cea579..8960a03e6694e 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -51,13 +51,27 @@ def silence private def deprecation_message(callstack, message = nil) - file, line, method = extract_callstack(callstack) message ||= "You are using deprecated behavior which will be removed from Rails 2.0." - "DEPRECATION WARNING: #{message} See http://www.rubyonrails.org/deprecation for details. (called from #{method} at #{file}:#{line})" + "DEPRECATION WARNING: #{message} See http://www.rubyonrails.org/deprecation for details. #{deprecation_caller_message(callstack)}" + end + + def deprecation_caller_message(callstack) + file, line, method = extract_callstack(callstack) + if file + if line && method + "(called from #{method} at #{file}:#{line})" + else + "(called from #{file}:#{line})" + end + end end def extract_callstack(callstack) - callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/).captures + if md = callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/) + md.captures + else + callstack.first + end end end