From 6480d4974920ba3a22606770b49cb4140fa3ad40 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Wed, 15 Mar 2006 18:27:26 +0000 Subject: Add MimeResponds::Responder#any for managing multiple types with identical responses git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3876 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/mime_responds_test.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 94273cf4af..a2b8eaad60 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -64,6 +64,13 @@ class RespondToController < ActionController::Base end end + def handle_any + respond_to do |type| + type.html { render :text => "HTML" } + type.any(:js, :xml) { render :text => "Either JS or XML" } + end + end + def rescue_action(e) raise unless ActionController::MissingTemplate === e end @@ -195,4 +202,18 @@ class MimeControllerTest < Test::Unit::TestCase get :html_or_xml assert_equal 'HTML', @response.body end + + def test_handle_any + @request.env["HTTP_ACCEPT"] = "*/*" + get :handle_any + assert_equal 'HTML', @response.body + + @request.env["HTTP_ACCEPT"] = "text/javascript" + get :handle_any + assert_equal 'Either JS or XML', @response.body + + @request.env["HTTP_ACCEPT"] = "text/xml" + get :handle_any + assert_equal 'Either JS or XML', @response.body + end end \ No newline at end of file -- cgit v1.2.3