Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 5c30352328f8a0223746139e024b6bea7b3d36c0 1 parent ace2a66
@dhh dhh authored
View
2  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]
View
2  actionpack/lib/action_controller/base.rb
@@ -649,7 +649,7 @@ def render(options = nil, deprecated_status = nil, &block) #:doc:
end
if content_type = options[:content_type]
- headers["Content-Type"] = content_type
+ headers["Content-Type"] = content_type.to_s
end
if text = options[:text]
View
10 actionpack/test/controller/action_pack_assertions_test.rb
@@ -61,6 +61,10 @@ def render_url
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 @@ def test_rendering_xml_respects_content_type
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
Please sign in to comment.
Something went wrong with that request. Please try again.