Changeset 3158
- Timestamp:
- 11/22/05 08:41:59 (3 years ago)
- Files:
-
- branches/stable/actionpack/CHANGELOG (modified) (1 diff)
- branches/stable/actionpack/lib/action_controller/base.rb (modified) (3 diffs)
- branches/stable/actionpack/test/controller/new_render_test.rb (modified) (2 diffs)
- branches/stable/actionpack/test/fixtures/test/render_file_with_ivar.rhtml (added)
- branches/stable/actionpack/test/fixtures/test/render_file_with_locals.rhtml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/stable/actionpack/CHANGELOG
r3137 r3158 1 1 *SVN* 2 3 * Make ActionController's render honor the :locals option when rendering a :file. #1665. [Emanuel Borsboom, Marcel Molina Jr.] 2 4 3 5 * Strip out trailing &_= for raw post bodies. Closes #2868. [Sam Stephenson] branches/stable/actionpack/lib/action_controller/base.rb
r3016 r3158 460 460 end 461 461 462 def session_enabled? 463 request.session_options[:disabled] != false 464 end 465 462 466 protected 463 467 # Renders the content that will be returned to the browser as the response body. … … 597 601 else 598 602 if file = options[:file] 599 render_file(file, options[:status], options[:use_full_path] )603 render_file(file, options[:status], options[:use_full_path], options[:locals] || {}) 600 604 601 605 elsif template = options[:template] … … 645 649 end 646 650 647 def render_file(template_path, status = nil, use_full_path = false )651 def render_file(template_path, status = nil, use_full_path = false, locals = {}) 648 652 add_variables_to_assigns 649 653 assert_existance_of_template_file(template_path) if use_full_path 650 654 logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger 651 render_text(@template.render_file(template_path, use_full_path ), status)655 render_text(@template.render_file(template_path, use_full_path, locals), status) 652 656 end 653 657 branches/stable/actionpack/test/controller/new_render_test.rb
r2777 r3158 43 43 def render_custom_code 44 44 render :text => "hello world", :status => "404 Moved" 45 end 46 47 def render_file_with_instance_variables 48 @secret = 'in the sauce' 49 path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.rhtml') 50 render :file => path 51 end 52 53 def render_file_with_locals 54 path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.rhtml') 55 render :file => path, :locals => {:secret => 'in the sauce'} 56 end 57 58 def render_file_not_using_full_path 59 @secret = 'in the sauce' 60 render :file => 'test/render_file_with_ivar', :use_full_path => true 45 61 end 46 62 … … 243 259 end 244 260 261 def test_render_file_with_instance_variables 262 get :render_file_with_instance_variables 263 assert_equal "The secret is in the sauce\n", @response.body 264 end 265 266 def test_render_file_not_using_full_path 267 get :render_file_not_using_full_path 268 assert_equal "The secret is in the sauce\n", @response.body 269 end 270 271 def test_render_file_with_locals 272 get :render_file_with_locals 273 assert_equal "The secret is in the sauce\n", @response.body 274 end 275 245 276 def test_attempt_to_access_object_method 246 277 assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }