Skip to content

Commit

Permalink
Merge pull request rails#6050 from route/wrapped_keys_in_log
Browse files Browse the repository at this point in the history
Show in log correct wrapped keys
  • Loading branch information
josevalim committed May 20, 2012
2 parents 2575508 + 32a433e commit 3655d66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion actionpack/lib/action_controller/metal/params_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ def _set_wrapper_defaults(options, model=nil)
def process_action(*args)
if _wrapper_enabled?
wrapped_hash = _wrap_parameters request.request_parameters
wrapped_filtered_hash = _wrap_parameters request.filtered_parameters
wrapped_keys = request.request_parameters.keys
wrapped_filtered_hash = _wrap_parameters request.filtered_parameters.slice(*wrapped_keys)

# This will make the wrapped hash accessible from controller and view
request.parameters.merge! wrapped_hash
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/controller/params_wrapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def teardown
UsersController.last_parameters = nil
end

def test_filtered_parameters
with_default_wrapper_options do
@request.env['CONTENT_TYPE'] = 'application/json'
post :parse, { 'username' => 'sikachu' }
assert_equal @request.filtered_parameters, { 'controller' => 'params_wrapper_test/users', 'action' => 'parse', 'username' => 'sikachu', 'user' => { 'username' => 'sikachu' } }
end
end

def test_derived_name_from_controller
with_default_wrapper_options do
@request.env['CONTENT_TYPE'] = 'application/json'
Expand Down

0 comments on commit 3655d66

Please sign in to comment.