diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2012-04-29 10:13:59 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-04-29 10:15:54 +0100 |
commit | 7a80b69e00f68e673c6ceb5cc684aa9196ed3d9f (patch) | |
tree | 1413c59211ea7093a6f2465ca5d8f739a7dbf853 /actionpack/test | |
parent | ffc861c101c3d7284a512c1ac407a4027a0f175e (diff) | |
download | rails-7a80b69e00f68e673c6ceb5cc684aa9196ed3d9f.tar.gz rails-7a80b69e00f68e673c6ceb5cc684aa9196ed3d9f.tar.bz2 rails-7a80b69e00f68e673c6ceb5cc684aa9196ed3d9f.zip |
Don't convert params if the request isn't HTML - fixes #5341
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 03b7396d5b..6c176b5144 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -45,6 +45,10 @@ class TestCaseTest < ActionController::TestCase render :text => request.fullpath end + def test_format + render :text => request.format + end + def test_query_string render :text => request.query_string end @@ -579,14 +583,34 @@ XML ) end + def test_params_passing_with_fixnums_when_not_html_request + get :test_params, :format => 'json', :count => 999 + parsed_params = eval(@response.body) + assert_equal( + {'controller' => 'test_case_test/test', 'action' => 'test_params', + 'format' => 'json', 'count' => 999 }, + parsed_params + ) + end + + def test_params_passing_path_parameter_is_string_when_not_html_request + get :test_params, :format => 'json', :id => 1 + parsed_params = eval(@response.body) + assert_equal( + {'controller' => 'test_case_test/test', 'action' => 'test_params', + 'format' => 'json', 'id' => '1' }, + parsed_params + ) + end + def test_params_passing_with_frozen_values assert_nothing_raised do - get :test_params, :frozen => 'icy'.freeze, :frozens => ['icy'.freeze].freeze + get :test_params, :frozen => 'icy'.freeze, :frozens => ['icy'.freeze].freeze, :deepfreeze => { :frozen => 'icy'.freeze }.freeze end parsed_params = eval(@response.body) assert_equal( {'controller' => 'test_case_test/test', 'action' => 'test_params', - 'frozen' => 'icy', 'frozens' => ['icy']}, + 'frozen' => 'icy', 'frozens' => ['icy'], 'deepfreeze' => { 'frozen' => 'icy' }}, parsed_params ) end @@ -687,6 +711,20 @@ XML assert_equal "http://", @response.body end + def test_request_format + get :test_format, :format => 'html' + assert_equal 'text/html', @response.body + + get :test_format, :format => 'json' + assert_equal 'application/json', @response.body + + get :test_format, :format => 'xml' + assert_equal 'application/xml', @response.body + + get :test_format + assert_equal 'text/html', @response.body + end + def test_should_have_knowledge_of_client_side_cookie_state_even_if_they_are_not_set cookies['foo'] = 'bar' get :no_op |