Changeset 6574
- Timestamp:
- 04/24/07 18:29:37 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (1 diff)
- trunk/actionpack/test/controller/new_render_test.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/render_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6572 r6574 1 1 *SVN* 2 3 * Added that render :xml will try to call to_xml if it can [DHH]. Makes these work: 4 5 render :xml => post 6 render :xml => comments 2 7 3 8 * Added :location option to render so that the common pattern of rendering a response after creating a new resource is now a 1-liner [DHH] trunk/actionpack/lib/action_controller/base.rb
r6572 r6574 880 880 def render_xml(xml, status = nil) #:nodoc: 881 881 response.content_type = Mime::XML 882 render_text(xml , status)882 render_text(xml.respond_to?(:to_xml) ? xml.to_xml : xml, status) 883 883 end 884 884 trunk/actionpack/test/controller/new_render_test.rb
r6399 r6574 257 257 def head_with_status_code_first 258 258 head :forbidden, :x_custom_header => "something" 259 end 260 261 def render_with_location 262 render :xml => "<hello/>", :location => "http://example.com", :status => 201 263 end 264 265 def render_with_to_xml 266 to_xmlable = Class.new do 267 def to_xml 268 "<i-am-xml/>" 269 end 270 end.new 271 272 render :xml => to_xmlable 259 273 end 260 274 … … 743 757 assert_response :forbidden 744 758 end 759 760 def test_rendering_with_location_should_set_header 761 get :render_with_location 762 assert_equal "http://example.com", @response.headers["Location"] 763 end 764 765 def test_rendering_xml_should_call_to_xml_if_possible 766 get :render_with_to_xml 767 assert_equal "<i-am-xml/>", @response.body 768 end 745 769 end trunk/actionpack/test/controller/render_test.rb
r6572 r6574 72 72 def heading 73 73 head :ok 74 end75 76 def location77 render :xml => "<hello/>", :location => "http://example.com", :status => 20178 74 end 79 75 … … 373 369 end 374 370 375 def test_rendering_with_location_should_set_header376 get :location377 assert_equal "http://example.com", @response.headers["Location"]378 end379 380 371 381 372 protected