@@ -45,6 +45,10 @@ def test_uri
4545 render :text => request . fullpath
4646 end
4747
48+ def test_format
49+ render :text => request . format
50+ end
51+
4852 def test_query_string
4953 render :text => request . query_string
5054 end
@@ -579,14 +583,34 @@ def test_params_passing_with_fixnums
579583 )
580584 end
581585
586+ def test_params_passing_with_fixnums_when_not_html_request
587+ get :test_params , :format => 'json' , :count => 999
588+ parsed_params = eval ( @response . body )
589+ assert_equal (
590+ { 'controller' => 'test_case_test/test' , 'action' => 'test_params' ,
591+ 'format' => 'json' , 'count' => 999 } ,
592+ parsed_params
593+ )
594+ end
595+
596+ def test_params_passing_path_parameter_is_string_when_not_html_request
597+ get :test_params , :format => 'json' , :id => 1
598+ parsed_params = eval ( @response . body )
599+ assert_equal (
600+ { 'controller' => 'test_case_test/test' , 'action' => 'test_params' ,
601+ 'format' => 'json' , 'id' => '1' } ,
602+ parsed_params
603+ )
604+ end
605+
582606 def test_params_passing_with_frozen_values
583607 assert_nothing_raised do
584- get :test_params , :frozen => 'icy' . freeze , :frozens => [ 'icy' . freeze ] . freeze
608+ get :test_params , :frozen => 'icy' . freeze , :frozens => [ 'icy' . freeze ] . freeze , :deepfreeze => { :frozen => 'icy' . freeze } . freeze
585609 end
586610 parsed_params = eval ( @response . body )
587611 assert_equal (
588612 { 'controller' => 'test_case_test/test' , 'action' => 'test_params' ,
589- 'frozen' => 'icy' , 'frozens' => [ 'icy' ] } ,
613+ 'frozen' => 'icy' , 'frozens' => [ 'icy' ] , 'deepfreeze' => { 'frozen' => 'icy' } } ,
590614 parsed_params
591615 )
592616 end
@@ -687,6 +711,20 @@ def test_request_protocol_is_reset_after_request
687711 assert_equal "http://" , @response . body
688712 end
689713
714+ def test_request_format
715+ get :test_format , :format => 'html'
716+ assert_equal 'text/html' , @response . body
717+
718+ get :test_format , :format => 'json'
719+ assert_equal 'application/json' , @response . body
720+
721+ get :test_format , :format => 'xml'
722+ assert_equal 'application/xml' , @response . body
723+
724+ get :test_format
725+ assert_equal 'text/html' , @response . body
726+ end
727+
690728 def test_should_have_knowledge_of_client_side_cookie_state_even_if_they_are_not_set
691729 cookies [ 'foo' ] = 'bar'
692730 get :no_op
0 commit comments