mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Adds tests for content negotiation change introduced in dc5300adb6
Signed-off-by: wycats <wycats@gmail.com>
This commit is contained in:
parent
3cb5375832
commit
7f7480f6fc
1 changed files with 20 additions and 0 deletions
|
@ -36,6 +36,15 @@ class RespondToController < ActionController::Base
|
||||||
type.all { render :text => "Nothing" }
|
type.all { render :text => "Nothing" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def json_xml_or_html
|
||||||
|
respond_to do |type|
|
||||||
|
type.json { render :text => 'JSON' }
|
||||||
|
type.xml { render :xml => 'XML' }
|
||||||
|
type.html { render :text => 'HTML' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def forced_xml
|
def forced_xml
|
||||||
request.format = :xml
|
request.format = :xml
|
||||||
|
@ -364,6 +373,17 @@ class RespondToControllerTest < ActionController::TestCase
|
||||||
get :handle_any_any
|
get :handle_any_any
|
||||||
assert_equal 'Whatever you ask for, I got it', @response.body
|
assert_equal 'Whatever you ask for, I got it', @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_browser_check_with_any_any
|
||||||
|
@request.accept = "application/json, application/xml"
|
||||||
|
get :json_xml_or_html
|
||||||
|
assert_equal 'JSON', @response.body
|
||||||
|
|
||||||
|
@request.accept = "application/json, application/xml, */*"
|
||||||
|
get :json_xml_or_html
|
||||||
|
assert_equal 'HTML', @response.body
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_rjs_type_skips_layout
|
def test_rjs_type_skips_layout
|
||||||
@request.accept = "text/javascript"
|
@request.accept = "text/javascript"
|
||||||
|
|
Loading…
Reference in a new issue