aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-06-04 11:45:53 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-06-04 11:45:53 -0700
commit1ce0cc0d38c9f5058cb484612fab625db823c4e4 (patch)
tree7c856d0c2f6534c349ff2e81a01046acaa868c31 /actionpack
parent3f7e482aed8f67137c6c8382f6c558d7e856b341 (diff)
parentb8f586a094c104006d29a87fee0d8b48d0af2d14 (diff)
downloadrails-1ce0cc0d38c9f5058cb484612fab625db823c4e4.tar.gz
rails-1ce0cc0d38c9f5058cb484612fab625db823c4e4.tar.bz2
rails-1ce0cc0d38c9f5058cb484612fab625db823c4e4.zip
Merge branch 'master' of github.com:rails/rails
* 'master' of github.com:rails/rails: For our build, stick with mail 2.5.x for now Correct result, previously showing wrong result Collapse PG default extractoin of most types to single regex Change wording of explanation about precision & scale of decimal numbers [ci skip] Cleaned up duplicated CHANGELOG entry [ci skip] reuse available belongs_to? method Convert StrongParameters cache to a hash. This fixes an unbounded memory leak demonstrated on @tenderlove's latest blog post: Partially revert deprecation of *_filter Pluralize params Add default_i18n_subject to the guides Fix regression on eager loading association based on SQL query rather than existing column. Relax mail gem constraint from ~> 2.5.4 to ~> 2.5, >= 2.5.4 Keep column defaults in type cast form Return a null column when no column exists for an attribute Refactor XML serializer to not depend on `serialized_attributes` Test the serialized types of virtual columns in XML implement ActiveRecord::Base#pretty_print + changelog Remove duplicated HashWithIndifferentAccess#with_indifferent_access.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md4
-rw-r--r--actionpack/lib/abstract_controller/callbacks.rb33
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb12
-rw-r--r--actionpack/lib/action_dispatch/http/parameters.rb1
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb4
-rw-r--r--actionpack/test/abstract/callbacks_test.rb8
-rw-r--r--actionpack/test/controller/parameters/parameters_permit_test.rb2
-rw-r--r--actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb5
8 files changed, 19 insertions, 50 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index fb633f11d5..3b20aec20d 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -2,10 +2,6 @@
application. Use of a symbol should be replaced with `action: symbol`.
Use of a string without a "#" should be replaced with `controller: string`.
-* Deprecate all *_filter callbacks in favor of *_action callbacks.
-
- *Rafael Mendonça França*
-
* Fix URL generation with `:trailing_slash` such that it does not add
a trailing slash after `.:format`
diff --git a/actionpack/lib/abstract_controller/callbacks.rb b/actionpack/lib/abstract_controller/callbacks.rb
index 252e297c69..ca5c80cd71 100644
--- a/actionpack/lib/abstract_controller/callbacks.rb
+++ b/actionpack/lib/abstract_controller/callbacks.rb
@@ -1,5 +1,3 @@
-require 'active_support/deprecation'
-
module AbstractController
module Callbacks
extend ActiveSupport::Concern
@@ -56,11 +54,7 @@ module AbstractController
skip_after_action(*names)
skip_around_action(*names)
end
-
- def skip_filter(*names)
- ActiveSupport::Deprecation.warn("#{callback}_filter is deprecated and will removed in Rails 5. Use #{callback}_action instead.")
- skip_action_callback(*names)
- end
+ alias_method :skip_filter, :skip_action_callback
# Take callback names and an optional callback proc, normalize them,
# then call the block with each callback. This allows us to abstract
@@ -175,22 +169,14 @@ module AbstractController
set_callback(:process_action, callback, name, options)
end
end
-
- define_method "#{callback}_filter" do |*names, &blk|
- ActiveSupport::Deprecation.warn("#{callback}_filter is deprecated and will removed in Rails 5. Use #{callback}_action instead.")
- send("#{callback}_action", *names, &blk)
- end
+ alias_method :"#{callback}_filter", :"#{callback}_action"
define_method "prepend_#{callback}_action" do |*names, &blk|
_insert_callbacks(names, blk) do |name, options|
set_callback(:process_action, callback, name, options.merge(:prepend => true))
end
end
-
- define_method "prepend_#{callback}_filter" do |*names, &blk|
- ActiveSupport::Deprecation.warn("prepend_#{callback}_filter is deprecated and will removed in Rails 5. Use prepend_#{callback}_action instead.")
- send("prepend_#{callback}_action", *names, &blk)
- end
+ alias_method :"prepend_#{callback}_filter", :"prepend_#{callback}_action"
# Skip a before, after or around callback. See _insert_callbacks
# for details on the allowed parameters.
@@ -199,18 +185,11 @@ module AbstractController
skip_callback(:process_action, callback, name, options)
end
end
-
- define_method "skip_#{callback}_filter" do |*names, &blk|
- ActiveSupport::Deprecation.warn("skip_#{callback}_filter is deprecated and will removed in Rails 5. Use skip_#{callback}_action instead.")
- send("skip_#{callback}_action", *names, &blk)
- end
+ alias_method :"skip_#{callback}_filter", :"skip_#{callback}_action"
# *_action is the same as append_*_action
- alias_method :"append_#{callback}_action", :"#{callback}_action" # alias_method :append_before_action, :before_action
- define_method "append_#{callback}_filter" do |*names, &blk|
- ActiveSupport::Deprecation.warn("append_#{callback}_filter is deprecated and will removed in Rails 5. Use append_#{callback}_action instead.")
- send("append_#{callback}_action", *names, &blk)
- end
+ alias_method :"append_#{callback}_action", :"#{callback}_action"
+ alias_method :"append_#{callback}_filter", :"#{callback}_action"
end
end
end
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index d86d49c9dc..265048a308 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -130,7 +130,7 @@ module ActionController
# looping in the common use case permit + mass-assignment. Defined in a
# method to instantiate it only if needed.
def converted_arrays
- @converted_arrays ||= Set.new
+ @converted_arrays ||= {}
end
# Returns +true+ if the parameter is permitted, +false+ otherwise.
@@ -333,15 +333,15 @@ module ActionController
private
def convert_hashes_to_parameters(key, value, assign_if_converted=true)
- converted = convert_value_to_parameters(value)
+ converted = convert_value_to_parameters(key, value)
self[key] = converted if assign_if_converted && !converted.equal?(value)
converted
end
- def convert_value_to_parameters(value)
- if value.is_a?(Array) && !converted_arrays.member?(value)
- converted = value.map { |_| convert_value_to_parameters(_) }
- converted_arrays << converted
+ def convert_value_to_parameters(key, value)
+ if value.is_a?(Array) && !converted_arrays.member?(key)
+ converted = value.map { |v| convert_value_to_parameters(nil, v) }
+ converted_arrays[key] = converted if key
converted
elsif value.is_a?(Parameters) || !value.is_a?(Hash)
value
diff --git a/actionpack/lib/action_dispatch/http/parameters.rb b/actionpack/lib/action_dispatch/http/parameters.rb
index 1ab11392ce..5f7627cf96 100644
--- a/actionpack/lib/action_dispatch/http/parameters.rb
+++ b/actionpack/lib/action_dispatch/http/parameters.rb
@@ -15,7 +15,6 @@ module ActionDispatch
query_parameters.dup
end
params.merge!(path_parameters)
- params.with_indifferent_access
end
end
alias :params :parameters
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index dfe258e463..4d4b443fb4 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -291,7 +291,7 @@ module ActionDispatch
# Override Rack's GET method to support indifferent access
def GET
- @env["action_dispatch.request.query_parameters"] ||= Utils.deep_munge((normalize_encode_params(super) || {}))
+ @env["action_dispatch.request.query_parameters"] ||= Utils.deep_munge(normalize_encode_params(super || {}))
rescue TypeError => e
raise ActionController::BadRequest.new(:query, e)
end
@@ -299,7 +299,7 @@ module ActionDispatch
# Override Rack's POST method to support indifferent access
def POST
- @env["action_dispatch.request.request_parameters"] ||= Utils.deep_munge((normalize_encode_params(super) || {}))
+ @env["action_dispatch.request.request_parameters"] ||= Utils.deep_munge(normalize_encode_params(super || {}))
rescue TypeError => e
raise ActionController::BadRequest.new(:request, e)
end
diff --git a/actionpack/test/abstract/callbacks_test.rb b/actionpack/test/abstract/callbacks_test.rb
index 07571602e4..8cba049485 100644
--- a/actionpack/test/abstract/callbacks_test.rb
+++ b/actionpack/test/abstract/callbacks_test.rb
@@ -267,11 +267,9 @@ module AbstractController
end
class AliasedCallbacks < ControllerWithCallbacks
- ActiveSupport::Deprecation.silence do
- before_filter :first
- after_filter :second
- around_filter :aroundz
- end
+ before_filter :first
+ after_filter :second
+ around_filter :aroundz
def first
@text = "Hello world"
diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb
index 33a91d72d9..1856ecd42b 100644
--- a/actionpack/test/controller/parameters/parameters_permit_test.rb
+++ b/actionpack/test/controller/parameters/parameters_permit_test.rb
@@ -169,7 +169,7 @@ class ParametersPermitTest < ActiveSupport::TestCase
test 'arrays are converted at most once' do
params = ActionController::Parameters.new(foo: [{}])
- assert params[:foo].equal?(params[:foo])
+ assert_same params[:foo], params[:foo]
end
test "fetch doesnt raise ParameterMissing exception if there is a default" do
diff --git a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
index 9a77454f30..1de05cbf09 100644
--- a/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
+++ b/actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
@@ -130,10 +130,7 @@ class UrlEncodedParamsParsingTest < ActionDispatch::IntegrationTest
end
test "ambiguous params returns a bad request" do
- with_routing do |set|
- set.draw do
- post ':action', to: ::UrlEncodedParamsParsingTest::TestController
- end
+ with_test_routing do
post "/parse", "foo[]=bar&foo[4]=bar"
assert_response :bad_request
end