diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-10-29 08:42:16 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-10-29 08:42:16 -0700 |
commit | d1c95d912ec39e7e374aee605a1d6fb11f8521d7 (patch) | |
tree | 9ec15855e1cab91c346d5a09e6adb593c7585608 /actionpack | |
parent | 72e6fb005fbdd211883282fc761d3ded23ef7fbb (diff) | |
parent | 0b7067d8497c4d832b32233888ce973ab4357e5d (diff) | |
download | rails-d1c95d912ec39e7e374aee605a1d6fb11f8521d7.tar.gz rails-d1c95d912ec39e7e374aee605a1d6fb11f8521d7.tar.bz2 rails-d1c95d912ec39e7e374aee605a1d6fb11f8521d7.zip |
Merge pull request #8063 from nikitug/deprecation_caller_context
Provide a call stack for deprecation warnings where needed.
Diffstat (limited to 'actionpack')
11 files changed, 45 insertions, 22 deletions
diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index bffd2a02d0..90b69879e5 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -8,12 +8,12 @@ module ActionController 'ActionView::RecodIdentifier module.' def dom_id(record, prefix = nil) - ActiveSupport::Deprecation.warn 'dom_id ' + MESSAGE + ActiveSupport::Deprecation.warn('dom_id ' + MESSAGE, caller) ActionView::RecordIdentifier.dom_id(record, prefix) end def dom_class(record, prefix = nil) - ActiveSupport::Deprecation.warn 'dom_class ' + MESSAGE + ActiveSupport::Deprecation.warn('dom_class ' + MESSAGE, caller) ActionView::RecordIdentifier.dom_class(record, prefix) end end diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index d911d47a1d..7529993a0e 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -476,7 +476,7 @@ module ActionController def process(action, http_method = 'GET', *args) check_required_ivars - http_method, args = handle_old_process_api(http_method, args) + http_method, args = handle_old_process_api(http_method, args, caller) if args.first.is_a?(String) && http_method != 'HEAD' @request.env['RAW_POST_DATA'] = args.shift @@ -579,10 +579,10 @@ module ActionController end end - def handle_old_process_api(http_method, args) + def handle_old_process_api(http_method, args, callstack) # 4.0: Remove this method. if http_method.is_a?(Hash) - ActiveSupport::Deprecation.warn("TestCase#process now expects the HTTP method as second argument: process(action, http_method, params, session, flash)") + ActiveSupport::Deprecation.warn("TestCase#process now expects the HTTP method as second argument: process(action, http_method, params, session, flash)", callstack) args.unshift(http_method) http_method = args.last.is_a?(String) ? args.last : "GET" end diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 3d560518e1..f29730270c 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -275,12 +275,12 @@ module Mime # Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See # ActionController::RequestForgeryProtection. def verify_request? - ActiveSupport::Deprecation.warn "Mime::Type#verify_request? is deprecated and will be removed in Rails 4.1" + ActiveSupport::Deprecation.warn("Mime::Type#verify_request? is deprecated and will be removed in Rails 4.1", caller) @@browser_generated_types.include?(to_sym) end def self.browser_generated_types - ActiveSupport::Deprecation.warn "Mime::Type.browser_generated_types is deprecated and will be removed in Rails 4.1" + ActiveSupport::Deprecation.warn("Mime::Type.browser_generated_types is deprecated and will be removed in Rails 4.1", caller) @@browser_generated_types end diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 4eac6514df..9a2b5ae16a 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -125,7 +125,7 @@ module ActionView "the :type option key. This behavior is deprecated and will be remove in Rails 4.1. You should pass " + ":type option explicitly if you want to use other types, for example: " + "auto_discovery_link_tag(:xml, '/feed.xml', :type => 'application/xml')" - ActiveSupport::Deprecation.warn message + ActiveSupport::Deprecation.warn(message, caller) end tag( diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index b87c2e936f..1a0ce29756 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -1181,8 +1181,8 @@ module ActionView def initialize(object_name, object, template, options, block=nil) if block - ActiveSupport::Deprecation.warn( - "Giving a block to FormBuilder is deprecated and has no effect anymore.") + message = "Giving a block to FormBuilder is deprecated and has no effect anymore." + ActiveSupport::Deprecation.warn(message, caller) end @nested_child_index = {} diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 2bb526a539..6b3d80cbf0 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -519,7 +519,9 @@ module ActionView else prompt = options options = {} - ActiveSupport::Deprecation.warn "Passing the prompt to grouped_options_for_select as an argument is deprecated. Please use an options hash like `{ prompt: #{prompt.inspect} }`." + message = "Passing the prompt to grouped_options_for_select as an argument is deprecated. " / + "Please use an options hash like `{ prompt: #{prompt.inspect} }`." + ActiveSupport::Deprecation.warn(message, caller) end body = "".html_safe diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index f16e33d08d..c92b38e2b9 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -425,13 +425,17 @@ module ActionView options = options.stringify_keys if disable_with = options.delete("disable_with") - ActiveSupport::Deprecation.warn ":disable_with option is deprecated and will be removed from Rails 4.1. Use ':data => { :disable_with => \'Text\' }' instead" + message = ":disable_with option is deprecated and will be removed from Rails 4.1. " / + "Use ':data => { :disable_with => \'Text\' }' instead." + ActiveSupport::Deprecation.warn(message, caller) options["data-disable-with"] = disable_with end if confirm = options.delete("confirm") - ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead'" + message = ":confirm option is deprecated and will be removed from Rails 4.1. " / + "Use ':data => { :confirm => \'Text\' }' instead'." + ActiveSupport::Deprecation.warn(message, caller) options["data-confirm"] = confirm end @@ -483,13 +487,17 @@ module ActionView options = options.stringify_keys if disable_with = options.delete("disable_with") - ActiveSupport::Deprecation.warn ":disable_with option is deprecated and will be removed from Rails 4.1. Use ':data => { :disable_with => \'Text\' }' instead" + message = ":disable_with option is deprecated and will be removed from Rails 4.1. " / + "Use ':data => { :disable_with => \'Text\' }' instead." + ActiveSupport::Deprecation.warn(message, caller) options["data-disable-with"] = disable_with end if confirm = options.delete("confirm") - ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead'" + message = ":confirm option is deprecated and will be removed from Rails 4.1. " / + "Use ':data => { :confirm => \'Text\' }' instead'." + ActiveSupport::Deprecation.warn(message, caller) options["data-confirm"] = confirm end @@ -533,7 +541,9 @@ module ActionView options = options.stringify_keys if confirm = options.delete("confirm") - ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead'" + message = ":confirm option is deprecated and will be removed from Rails 4.1. " / + "Use ':data => { :confirm => \'Text\' }' instead'." + ActiveSupport::Deprecation.warn(message, caller) options["data-confirm"] = confirm end diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 7bf659d5f2..6be35168dd 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -80,7 +80,7 @@ module ActionView def button_to_function(name, function=nil, html_options={}) message = "button_to_function is deprecated and will be removed from Rails 4.1. We recomend to use Unobtrusive JavaScript instead. " + "See http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript" - ActiveSupport::Deprecation.warn message + ActiveSupport::Deprecation.warn(message, caller) onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function};" @@ -102,7 +102,7 @@ module ActionView def link_to_function(name, function, html_options={}) message = "link_to_function is deprecated and will be removed from Rails 4.1. We recomend to use Unobtrusive JavaScript instead. " + "See http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript" - ActiveSupport::Deprecation.warn message + ActiveSupport::Deprecation.warn(message, caller) onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;" href = html_options[:href] || '#' diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 5105d0e585..4d6367e66a 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -577,7 +577,9 @@ module ActionView method = html_options.delete('method') if confirm - ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead" + message = ":confirm option is deprecated and will be removed from Rails 4.1. " / + "Use ':data => { :confirm => \'Text\' }' instead." + ActiveSupport::Deprecation.warn(message, caller) html_options["data-confirm"] = confirm end @@ -585,7 +587,9 @@ module ActionView add_method_to_attributes!(html_options, method) if method if disable_with - ActiveSupport::Deprecation.warn ":disable_with option is deprecated and will be removed from Rails 4.1. Use ':data => { :disable_with => \'Text\' }' instead" + message = ":disable_with option is deprecated and will be removed from Rails 4.1. " / + "Use ':data => { :disable_with => \'Text\' }' instead." + ActiveSupport::Deprecation.warn(message, caller) html_options["data-disable-with"] = disable_with end diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 379cdc8a25..01a6bb42c8 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -149,7 +149,8 @@ module ActionView end def mime_type - ActiveSupport::Deprecation.warn 'Template#mime_type is deprecated and will be removed in Rails 4.1. Please use type method instead.' + message = 'Template#mime_type is deprecated and will be removed in Rails 4.1. Please use type method instead.' + ActiveSupport::Deprecation.warn(message, caller) @mime_type ||= Mime::Type.lookup_by_extension(@formats.first.to_s) if @formats.first end diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index 25c6fd4aa8..32a9152707 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -232,8 +232,14 @@ module ActionView def extract_handler_and_format(path, default_formats) pieces = File.basename(path).split(".") pieces.shift + extension = pieces.pop - ActiveSupport::Deprecation.warn "The file #{path} did not specify a template handler. The default is currently ERB, but will change to RAW in the future." unless extension + unless extension + message = "The file #{path} did not specify a template handler. The default is currently ERB, " / + "but will change to RAW in the future." + ActiveSupport::Deprecation.warn(message, caller) + end + handler = Template.handler_for_extension(extension) format = pieces.last && Template::Types[pieces.last] [handler, format] |