1
0
Fork 0
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:
Patrik Stenmark 2010-05-15 14:10:40 +02:00 committed by wycats
parent 3cb5375832
commit 7f7480f6fc

View file

@ -37,6 +37,15 @@ class RespondToController < ActionController::Base
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
request.format = :xml
@ -365,6 +374,17 @@ class RespondToControllerTest < ActionController::TestCase
assert_equal 'Whatever you ask for, I got it', @response.body
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
@request.accept = "text/javascript"
get :all_types_with_layout