aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-06-02 03:39:56 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-06-02 03:39:56 +0000
commit5c30352328f8a0223746139e024b6bea7b3d36c0 (patch)
tree02be13f488a586b6c88fb85da06f6ed44ada32e9 /actionpack
parentace2a66f0cdda4b752b6226eadf07873c402e380 (diff)
downloadrails-5c30352328f8a0223746139e024b6bea7b3d36c0.tar.gz
rails-5c30352328f8a0223746139e024b6bea7b3d36c0.tar.bz2
rails-5c30352328f8a0223746139e024b6bea7b3d36c0.zip
Added support for Mime objects in render :content_type option [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4404 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/base.rb2
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb10
3 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 9d6dcfc80d..23da55ca6b 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added support for Mime objects in render :content_type option [DHH]. Example: render :text => some_atom, :content_type => Mime::ATOM
+
* Add :status option to send_data and send_file. Defaults to '200 OK'. #5243 [Manfred Stienstra <m.stienstra@fngtps.com>]
* Routing rewrite. Simpler, faster, easier to understand. The published API for config/routes.rb is unchanged, but nearly everything else is different, so expect breakage in plugins and libs that try to fiddle with routes. [Nicholas Seckar, Jamis Buck]
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 0902e70082..38a255192e 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -649,7 +649,7 @@ module ActionController #:nodoc:
end
if content_type = options[:content_type]
- headers["Content-Type"] = content_type
+ headers["Content-Type"] = content_type.to_s
end
if text = options[:text]
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index bd9c8c1ff8..0ef31cb851 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -61,6 +61,10 @@ class ActionPackAssertionsController < ActionController::Base
render_text "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>"
end
+ def render_text_with_custom_content_type
+ render :text => "Hello!", :content_type => Mime::RSS
+ end
+
# puts something in the session
def session_stuffing
session['xmas'] = 'turkey'
@@ -532,4 +536,10 @@ class ActionPackHeaderTest < Test::Unit::TestCase
process :hello_xml_world
assert_equal('application/pdf', @controller.headers['Content-Type'])
end
+
+
+ def test_render_text_with_custom_content_type
+ get :render_text_with_custom_content_type
+ assert_equal 'application/rss+xml', @response.headers['Content-Type']
+ end
end