aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/abstract_controller/base.rb10
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb2
-rw-r--r--actionpack/lib/action_controller/metal/exceptions.rb9
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb2
-rw-r--r--actionpack/lib/action_controller/record_identifier.rb4
-rw-r--r--actionpack/lib/action_controller/test_case.rb6
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb16
-rw-r--r--actionpack/lib/action_dispatch/middleware/best_standards_support.rb8
-rw-r--r--actionpack/lib/action_dispatch/middleware/remote_ip.rb10
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb2
-rw-r--r--actionpack/lib/action_dispatch/testing/integration.rb4
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb3
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb20
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb6
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb8
-rw-r--r--actionpack/lib/action_view/renderer/template_renderer.rb7
-rw-r--r--actionpack/lib/action_view/template.rb3
-rw-r--r--actionpack/lib/action_view/template/resolver.rb8
20 files changed, 90 insertions, 44 deletions
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb
index 388e043f0b..56dc9ab7a1 100644
--- a/actionpack/lib/abstract_controller/base.rb
+++ b/actionpack/lib/abstract_controller/base.rb
@@ -34,6 +34,15 @@ module AbstractController
@abstract = true
end
+ def inherited(klass) # :nodoc:
+ # define the abstract ivar on subclasses so that we don't get
+ # uninitialized ivar warnings
+ unless klass.instance_variable_defined?(:@abstract)
+ klass.instance_variable_set(:@abstract, false)
+ end
+ super
+ end
+
# A list of all internal methods for a controller. This finds the first
# abstract superclass of a controller, and gets a list of all public
# instance methods on that abstract class. Public instance methods of
@@ -42,6 +51,7 @@ module AbstractController
# (ActionController::Metal and ActionController::Base are defined as abstract)
def internal_methods
controller = self
+
controller = controller.superclass until controller.abstract?
controller.public_instance_methods(true)
end
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index 3da2834af0..4b984d0558 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -51,7 +51,7 @@ module AbstractController
@view_context_class ||= begin
routes = respond_to?(:_routes) && _routes
helpers = respond_to?(:_helpers) && _helpers
-
+
Class.new(ActionView::Base) do
if routes
include routes.url_helpers
diff --git a/actionpack/lib/action_controller/metal/exceptions.rb b/actionpack/lib/action_controller/metal/exceptions.rb
index 3c9d0c86a7..3844dbf2a6 100644
--- a/actionpack/lib/action_controller/metal/exceptions.rb
+++ b/actionpack/lib/action_controller/metal/exceptions.rb
@@ -3,6 +3,15 @@ module ActionController
end
class BadRequest < ActionControllerError #:nodoc:
+ attr_reader :original_exception
+
+ def initialize(type = nil, e = nil)
+ return super() unless type && e
+
+ super("Invalid #{type} parameters: #{e.message}")
+ @original_exception = e
+ set_backtrace e.backtrace
+ end
end
class RenderError < ActionControllerError #:nodoc:
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 73f2e94cd1..04dc1d37f7 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -196,7 +196,7 @@ module ActionController
def permit(*filters)
params = self.class.new
- filters.each do |filter|
+ filters.flatten.each do |filter|
case filter
when Symbol, String then
if has_key?(filter)
diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb
index bffd2a02d0..b49128c184 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)
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)
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 d007133183..5aecb59df9 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/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index fc8825d6d9..3de927abc8 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -251,21 +251,17 @@ module ActionDispatch
# Override Rack's GET method to support indifferent access
def GET
- begin
- @env["action_dispatch.request.query_parameters"] ||= (normalize_parameters(super) || {})
- rescue TypeError => e
- raise ActionController::BadRequest, "Invalid query parameters: #{e.message}"
- end
+ @env["action_dispatch.request.query_parameters"] ||= (normalize_parameters(super) || {})
+ rescue TypeError => e
+ raise ActionController::BadRequest.new(:query, e)
end
alias :query_parameters :GET
# Override Rack's POST method to support indifferent access
def POST
- begin
- @env["action_dispatch.request.request_parameters"] ||= (normalize_parameters(super) || {})
- rescue TypeError => e
- raise ActionController::BadRequest, "Invalid request parameters: #{e.message}"
- end
+ @env["action_dispatch.request.request_parameters"] ||= (normalize_parameters(super) || {})
+ rescue TypeError => e
+ raise ActionController::BadRequest.new(:request, e)
end
alias :request_parameters :POST
diff --git a/actionpack/lib/action_dispatch/middleware/best_standards_support.rb b/actionpack/lib/action_dispatch/middleware/best_standards_support.rb
index 69adcc419f..d338996240 100644
--- a/actionpack/lib/action_dispatch/middleware/best_standards_support.rb
+++ b/actionpack/lib/action_dispatch/middleware/best_standards_support.rb
@@ -15,7 +15,13 @@ module ActionDispatch
def call(env)
status, headers, body = @app.call(env)
- headers["X-UA-Compatible"] = @header
+
+ if headers["X-UA-Compatible"] && @header
+ headers["X-UA-Compatible"] << "," << @header.to_s
+ else
+ headers["X-UA-Compatible"] = @header
+ end
+
[status, headers, body]
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/remote_ip.rb b/actionpack/lib/action_dispatch/middleware/remote_ip.rb
index ec15a2a715..5abf8f2802 100644
--- a/actionpack/lib/action_dispatch/middleware/remote_ip.rb
+++ b/actionpack/lib/action_dispatch/middleware/remote_ip.rb
@@ -63,9 +63,9 @@ module ActionDispatch
}x
def initialize(env, middleware)
- @env = env
- @middleware = middleware
- @calculated_ip = false
+ @env = env
+ @middleware = middleware
+ @ip = nil
end
# Determines originating IP address. REMOTE_ADDR is the standard
@@ -100,9 +100,7 @@ module ActionDispatch
end
def to_s
- return @ip if @calculated_ip
- @calculated_ip = true
- @ip = calculate_ip
+ @ip ||= calculate_ip
end
private
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index e337e30766..045299281c 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -182,7 +182,7 @@ module ActionDispatch
controller ||= default_controller
action ||= default_action
- unless controller.is_a?(Regexp)
+ unless controller.is_a?(Regexp) || to_shorthand
controller = [@scope[:module], controller].compact.join("/").presence
end
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb
index 2928263163..95cd89a166 100644
--- a/actionpack/lib/action_dispatch/testing/integration.rb
+++ b/actionpack/lib/action_dispatch/testing/integration.rb
@@ -3,6 +3,7 @@ require 'uri'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/object/try'
require 'rack/test'
+require 'minitest/unit'
module ActionDispatch
module Integration #:nodoc:
@@ -497,8 +498,7 @@ module ActionDispatch
def self.app
if !@@app && !ActionDispatch.test_app
- ActiveSupport::Deprecation.warn "Rails application fallback is deprecated " \
- "and no longer works, please set ActionDispatch.test_app", caller
+ ActiveSupport::Deprecation.warn "Rails application fallback is deprecated and no longer works, please set ActionDispatch.test_app"
end
@@app || ActionDispatch.test_app
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 77d8794b7d..459f95bb73 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -69,7 +69,7 @@ module ActionView
options = include_seconds_or_options
else
ActiveSupport::Deprecation.warn "distance_of_time_in_words and time_ago_in_words now accept :include_seconds " +
- "as a part of options hash, not a boolean argument", caller
+ "as a part of options hash, not a boolean argument"
options[:include_seconds] ||= !!include_seconds_or_options
end
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index b87c2e936f..6abf1e1751 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -1181,8 +1181,7 @@ 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.")
+ ActiveSupport::Deprecation.warn "Giving a block to FormBuilder is deprecated and has no effect anymore."
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 a33b233ed5..b7b3db959e 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
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 0257a13bc4..7f42d6e9c3 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
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
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
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
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
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 a30326349a..1a99fc7091 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -78,7 +78,8 @@ module ActionView
# # => <input class="ok" onclick="alert('Hello world!');" type="button" value="Greeting" />
#
def button_to_function(name, function=nil, html_options={})
- message = "button_to_function is deprecated and will be removed from Rails 4.1. Use Unobtrusive JavaScript instead."
+ 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
onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function};"
@@ -99,7 +100,8 @@ module ActionView
# # => <a class="nav_link" href="#" onclick="alert('Hello world!'); return false;">Greeting</a>
#
def link_to_function(name, function, html_options={})
- message = "link_to_function is deprecated and will be removed from Rails 4.1. Use Unobtrusive JavaScript instead."
+ 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
onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;"
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 9bfda0ee9c..fd671c9c07 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
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
html_options["data-disable-with"] = disable_with
end
diff --git a/actionpack/lib/action_view/renderer/template_renderer.rb b/actionpack/lib/action_view/renderer/template_renderer.rb
index 156ad4e547..2a5ea5a711 100644
--- a/actionpack/lib/action_view/renderer/template_renderer.rb
+++ b/actionpack/lib/action_view/renderer/template_renderer.rb
@@ -29,8 +29,11 @@ module ActionView
handler = Template.handler_for_extension(options[:type] || "erb")
Template.new(options[:inline], "inline template", handler, :locals => keys)
elsif options.key?(:template)
- options[:template].respond_to?(:render) ?
- options[:template] : find_template(options[:template], options[:prefixes], false, keys, @details)
+ if options[:template].respond_to?(:render)
+ options[:template]
+ else
+ find_template(options[:template], options[:prefixes], false, keys, @details)
+ end
else
raise ArgumentError, "You invoked render but did not give any of :partial, :template, :inline, :file or :text option."
end
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 379cdc8a25..aefc42be48 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
@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..fc77c1485d 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
+ end
+
handler = Template.handler_for_extension(extension)
format = pieces.last && Template::Types[pieces.last]
[handler, format]