aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorPatrik Stenmark <patrik.stenmark@gmail.com>2010-05-15 14:10:40 +0200
committerwycats <wycats@gmail.com>2010-07-04 11:17:16 -0700
commit7f7480f6fc1e88ce19bee8ac7f6fb2243343495e (patch)
tree519a59905724ea0cf65e20f2a7dd9cbe89897983 /actionpack/test
parent3cb53758324214ec8bc65979f47dd43d0e85a248 (diff)
downloadrails-7f7480f6fc1e88ce19bee8ac7f6fb2243343495e.tar.gz
rails-7f7480f6fc1e88ce19bee8ac7f6fb2243343495e.tar.bz2
rails-7f7480f6fc1e88ce19bee8ac7f6fb2243343495e.zip
Adds tests for content negotiation change introduced in dc5300adb6d46252c26e
Signed-off-by: wycats <wycats@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/mime_responds_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index d654338dba..b5ce391b61 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -36,6 +36,15 @@ class RespondToController < ActionController::Base
type.all { render :text => "Nothing" }
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
@@ -364,6 +373,17 @@ class RespondToControllerTest < ActionController::TestCase
get :handle_any_any
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"