From 148ffeced34b73395c810418294336b8709fee76 Mon Sep 17 00:00:00 2001 From: Erik Hetzner Date: Fri, 8 Oct 2010 17:13:44 -0700 Subject: [PATCH] Add failing test for accept header order [#5278] --- .../new_base/content_negotiation_test.rb | 31 ++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/actionpack/test/controller/new_base/content_negotiation_test.rb b/actionpack/test/controller/new_base/content_negotiation_test.rb index b98a22d..681dceb 100644 --- a/actionpack/test/controller/new_base/content_negotiation_test.rb +++ b/actionpack/test/controller/new_base/content_negotiation_test.rb @@ -9,10 +9,41 @@ module ContentNegotiation )] end + class AdvancedController < ActionController::Base + def xml_only + respond_to do |format| + format.xml do + render :content_type => 'application/xml', + :text => "invalid xml" and return + end + end + end + end + class TestContentNegotiation < Rack::TestCase test "A */* Accept header will return HTML" do get "/content_negotiation/basic/hello", {}, "HTTP_ACCEPT" => "*/*" assert_body "Hello world */*!" end end + + class TestContentNegotiationXml < Rack::TestCase + test "A */* Accept header will return XML" do + get "/content_negotiation/advanced/xml_only", {}, "HTTP_ACCEPT" => "*/*" + assert_header "Content-Type", "application/xml; charset=utf-8" + assert_body "invalid xml" + end + + test "A */*,text/html Accept header will return XML" do + get "/content_negotiation/advanced/xml_only", {}, "HTTP_ACCEPT" => "*/*,text/html" + assert_header "Content-Type", "application/xml; charset=utf-8" + assert_body "invalid xml" + end + + test "A text/html,*/* Accept header will return XML" do + get "/content_negotiation/advanced/xml_only", {}, "HTTP_ACCEPT" => "text/html,*/*" + assert_header "Content-Type", "application/xml; charset=utf-8" + assert_body "invalid xml" + end + end end -- 1.7.0.4