aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/actionpack.gemspec4
-rw-r--r--actionpack/lib/action_controller/metal/params_wrapper.rb34
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb6
-rw-r--r--actionpack/test/controller/log_subscriber_test.rb6
-rw-r--r--actionpack/test/controller/params_wrapper_test.rb12
-rw-r--r--actionpack/test/dispatch/cookies_test.rb12
6 files changed, 39 insertions, 35 deletions
diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec
index 0b4e7027ed..45958ec75a 100644
--- a/actionpack/actionpack.gemspec
+++ b/actionpack/actionpack.gemspec
@@ -22,10 +22,10 @@ Gem::Specification.new do |s|
s.add_dependency('rack-cache', '~> 1.0.1')
s.add_dependency('builder', '~> 3.0.0')
s.add_dependency('i18n', '~> 0.6.0beta1')
- s.add_dependency('rack', '~> 1.3.0.beta')
+ s.add_dependency('rack', '~> 1.3.0.beta2')
s.add_dependency('rack-test', '~> 0.6.0')
s.add_dependency('rack-mount', '~> 0.8.1')
- s.add_dependency('sprockets', '~> 2.0.0.beta.3')
+ s.add_dependency('sprockets', '~> 2.0.0.beta.5')
s.add_dependency('tzinfo', '~> 0.3.27')
s.add_dependency('erubis', '~> 2.7.0')
end
diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb
index 93241fc056..5500f88930 100644
--- a/actionpack/lib/action_controller/metal/params_wrapper.rb
+++ b/actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -37,11 +37,11 @@ module ActionController
# {"name" => "Konata", "user" => {"name" => "Konata"}}
#
# You can also specify the key in which the parameters should be wrapped to,
- # and also the list of attributes it should wrap by using either +:only+ or
- # +:except+ options like this:
+ # and also the list of attributes it should wrap by using either +:include+ or
+ # +:exclude+ options like this:
#
# class UsersController < ApplicationController
- # wrap_parameters :person, :only => [:username, :password]
+ # wrap_parameters :person, :include => [:username, :password]
# end
#
# If you're going to pass the parameters to an +ActiveModel+ object (such as
@@ -53,7 +53,7 @@ module ActionController
# wrap_parameters Person
# end
#
- # You still could pass +:only+ and +:except+ to set the list of attributes
+ # You still could pass +:include+ and +:exclude+ to set the list of attributes
# you want to wrap.
#
# By default, if you don't specify the key in which the parameters would be
@@ -73,7 +73,7 @@ module ActionController
included do
class_attribute :_wrapper_options
- self._wrapper_options = {:format => []}
+ self._wrapper_options = { :format => [] }
end
module ClassMethods
@@ -91,7 +91,7 @@ module ActionController
# # wraps parameters by determine the wrapper key from Person class
# (+person+, in this case) and the list of attribute names
#
- # wrap_parameters :only => [:username, :title]
+ # wrap_parameters :include => [:username, :title]
# # wraps only +:username+ and +:title+ attributes from parameters.
#
# wrap_parameters false
@@ -100,9 +100,9 @@ module ActionController
# ==== Options
# * <tt>:format</tt> - The list of formats in which the parameters wrapper
# will be enabled.
- # * <tt>:only</tt> - The list of attribute names which parameters wrapper
+ # * <tt>:include</tt> - The list of attribute names which parameters wrapper
# will wrap into a nested hash.
- # * <tt>:except</tt> - The list of attribute names which parameters wrapper
+ # * <tt>:exclude</tt> - The list of attribute names which parameters wrapper
# will exclude from a nested hash.
def wrap_parameters(name_or_model_or_options, options = {})
model = nil
@@ -164,10 +164,10 @@ module ActionController
def _set_wrapper_defaults(options, model=nil)
options = options.dup
- unless options[:only] || options[:except]
+ unless options[:include] || options[:exclude]
model ||= _default_wrap_model
if model.respond_to?(:attribute_names) && model.attribute_names.present?
- options[:only] = model.attribute_names
+ options[:include] = model.attribute_names
end
end
@@ -177,9 +177,9 @@ module ActionController
controller_name.singularize
end
- options[:only] = Array.wrap(options[:only]).collect(&:to_s) if options[:only]
- options[:except] = Array.wrap(options[:except]).collect(&:to_s) if options[:except]
- options[:format] = Array.wrap(options[:format])
+ options[:include] = Array.wrap(options[:include]).collect(&:to_s) if options[:include]
+ options[:exclude] = Array.wrap(options[:exclude]).collect(&:to_s) if options[:exclude]
+ options[:format] = Array.wrap(options[:format])
self._wrapper_options = options
end
@@ -216,11 +216,11 @@ module ActionController
# Returns the list of parameters which will be selected for wrapped.
def _wrap_parameters(parameters)
- value = if only = _wrapper_options[:only]
- parameters.slice(*only)
+ value = if include_only = _wrapper_options[:include]
+ parameters.slice(*include_only)
else
- except = _wrapper_options[:except] || []
- parameters.except(*(except + EXCLUDE_PARAMETERS))
+ exclude = _wrapper_options[:exclude] || []
+ parameters.except(*(exclude + EXCLUDE_PARAMETERS))
end
{ _wrapper_key => value }
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 24ebb8fed7..0057f64dd3 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -167,8 +167,8 @@ module ActionDispatch
handle_options(options)
- @set_cookies[key] = options
- @delete_cookies.delete(key)
+ @set_cookies[key.to_s] = options
+ @delete_cookies.delete(key.to_s)
value
end
@@ -181,7 +181,7 @@ module ActionDispatch
handle_options(options)
value = @cookies.delete(key.to_s)
- @delete_cookies[key] = options
+ @delete_cookies[key.to_s] = options
value
end
diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb
index 5d7a51e902..80c4fa2ee5 100644
--- a/actionpack/test/controller/log_subscriber_test.rb
+++ b/actionpack/test/controller/log_subscriber_test.rb
@@ -4,7 +4,7 @@ require "action_controller/log_subscriber"
module Another
class LogSubscribersController < ActionController::Base
- wrap_parameters :person, :only => :name, :format => :json
+ wrap_parameters :person, :include => :name, :format => :json
def show
render :nothing => true
@@ -34,11 +34,11 @@ module Another
cache_page("Super soaker", "/index.html")
render :nothing => true
end
-
+
def with_exception
raise Exception
end
-
+
end
end
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb
index a50065bcc7..7bef1e8d5d 100644
--- a/actionpack/test/controller/params_wrapper_test.rb
+++ b/actionpack/test/controller/params_wrapper_test.rb
@@ -65,9 +65,9 @@ class ParamsWrapperTest < ActionController::TestCase
end
end
- def test_specify_only_option
+ def test_specify_include_option
with_default_wrapper_options do
- UsersController.wrap_parameters :only => :username
+ UsersController.wrap_parameters :include => :username
@request.env['CONTENT_TYPE'] = 'application/json'
post :parse, { 'username' => 'sikachu', 'title' => 'Developer' }
@@ -75,9 +75,9 @@ class ParamsWrapperTest < ActionController::TestCase
end
end
- def test_specify_except_option
+ def test_specify_exclude_option
with_default_wrapper_options do
- UsersController.wrap_parameters :except => :title
+ UsersController.wrap_parameters :exclude => :title
@request.env['CONTENT_TYPE'] = 'application/json'
post :parse, { 'username' => 'sikachu', 'title' => 'Developer' }
@@ -85,9 +85,9 @@ class ParamsWrapperTest < ActionController::TestCase
end
end
- def test_specify_both_wrapper_name_and_only_option
+ def test_specify_both_wrapper_name_and_include_option
with_default_wrapper_options do
- UsersController.wrap_parameters :person, :only => :username
+ UsersController.wrap_parameters :person, :include => :username
@request.env['CONTENT_TYPE'] = 'application/json'
post :parse, { 'username' => 'sikachu', 'title' => 'Developer' }
diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb
index ebc16694db..e42c39f527 100644
--- a/actionpack/test/dispatch/cookies_test.rb
+++ b/actionpack/test/dispatch/cookies_test.rb
@@ -121,7 +121,7 @@ class CookiesTest < ActionController::TestCase
end
def string_key
- cookies['user_name'] = "david"
+ cookies['user_name'] = "dhh"
head :ok
end
@@ -417,14 +417,18 @@ class CookiesTest < ActionController::TestCase
assert_cookie_header "user_name=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"
end
+
def test_cookies_hash_is_indifferent_access
- [:symbol_key, :string_key].each do |cookie_key|
- get cookie_key
+ get :symbol_key
assert_equal "david", cookies[:user_name]
assert_equal "david", cookies['user_name']
- end
+ get :string_key
+ assert_equal "dhh", cookies[:user_name]
+ assert_equal "dhh", cookies['user_name']
end
+
+
def test_setting_request_cookies_is_indifferent_access
@request.cookies.clear
@request.cookies[:user_name] = "andrew"