Changeset 5591
- Timestamp:
- 11/20/06 11:03:21 (3 years 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) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r5587 r5591 1 1 *SVN* 2 3 * Ensure render_to_string cleans up after itself when an exception is raised. #6658 [rsanheim] 2 4 3 5 * Extract template_changed_since? from compile_template? so plugins may override its behavior for non-file-based templates. #6651 [Jeff Barczewski] trunk/actionpack/lib/action_controller/base.rb
r5253 r5591 764 764 # of sending it as the response body to the browser. 765 765 def render_to_string(options = nil, &block) #:doc: 766 result =ActiveSupport::Deprecation.silence { render(options, &block) }767 766 ActiveSupport::Deprecation.silence { render(options, &block) } 767 ensure 768 768 erase_render_results 769 769 forget_variables_added_to_assigns 770 770 reset_variables_added_to_assigns 771 772 result773 771 end 774 772 trunk/actionpack/test/controller/new_render_test.rb
r5466 r5591 161 161 render :text => "How's there? #{render_to_string("test/list")}" 162 162 end 163 164 def render_to_string_with_assigns 165 @before = "i'm before the render" 166 render_to_string :text => "foo" 167 @after = "i'm after the render" 168 render :action => "test/hello_world" 169 end 170 171 def render_to_string_with_exception 172 render_to_string :file => "exception that will not be caught - this will certainly not work", :use_full_path => true 173 end 174 175 def render_to_string_with_caught_exception 176 @before = "i'm before the render" 177 begin 178 render_to_string :file => "exception that will be caught- hope my future instance vars still work!", :use_full_path => true 179 rescue 180 end 181 @after = "i'm after the render" 182 render :action => "test/hello_world" 183 end 163 184 164 185 def accessing_params_in_template … … 187 208 render :text => "hello" 188 209 redirect_to :action => "double_render" 210 end 211 212 def render_to_string_and_render 213 @stuff = render_to_string :text => "here is some cached stuff" 214 render :text => "Hi web users! #{@stuff}" 189 215 end 190 216 … … 524 550 assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body 525 551 end 552 553 def test_render_to_string_doesnt_break_assigns 554 get :render_to_string_with_assigns 555 assert_equal "i'm before the render", assigns(:before) 556 assert_equal "i'm after the render", assigns(:after) 557 end 558 559 def test_bad_render_to_string_still_throws_exception 560 assert_raises(ActionController::MissingTemplate) { get :render_to_string_with_exception } 561 end 562 563 def test_render_to_string_that_throws_caught_exception_doesnt_break_assigns 564 assert_nothing_raised { get :render_to_string_with_caught_exception } 565 assert_equal "i'm before the render", assigns(:before) 566 assert_equal "i'm after the render", assigns(:after) 567 end 526 568 527 569 def test_nested_rendering … … 555 597 def test_render_and_redirect 556 598 assert_raises(ActionController::DoubleRenderError) { get :render_and_redirect } 599 end 600 601 # specify the one exception to double render rule - render_to_string followed by render 602 def test_render_to_string_and_render 603 get :render_to_string_and_render 604 assert_equal("Hi web users! here is some cached stuff", @response.body) 557 605 end 558 606