Changeset 3157
- Timestamp:
- 11/22/05 08:37:04 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/base.rb (modified) (3 diffs)
- trunk/actionpack/test/controller/new_render_test.rb (modified) (2 diffs)
- trunk/actionpack/test/fixtures/test/render_file_with_ivar.rhtml (added)
- trunk/actionpack/test/fixtures/test/render_file_with_locals.rhtml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r3154 r3157 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 * Allow assert_tag(:conditions) to match the empty string when a tag has no children. Closes #2959. [Jamis Buck] trunk/actionpack/lib/action_controller/base.rb
r3084 r3157 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] … … 646 650 end 647 651 648 def render_file(template_path, status = nil, use_full_path = false )652 def render_file(template_path, status = nil, use_full_path = false, locals = {}) 649 653 add_variables_to_assigns 650 654 assert_existance_of_template_file(template_path) if use_full_path 651 655 logger.info("Rendering #{template_path}" + (status ? " (#{status})" : '')) if logger 652 render_text(@template.render_file(template_path, use_full_path ), status)656 render_text(@template.render_file(template_path, use_full_path, locals), status) 653 657 end 654 658 trunk/actionpack/test/controller/new_render_test.rb
r3084 r3157 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 … … 258 274 end 259 275 276 def test_render_file_with_instance_variables 277 get :render_file_with_instance_variables 278 assert_equal "The secret is in the sauce\n", @response.body 279 end 280 281 def test_render_file_not_using_full_path 282 get :render_file_not_using_full_path 283 assert_equal "The secret is in the sauce\n", @response.body 284 end 285 286 def test_render_file_with_locals 287 get :render_file_with_locals 288 assert_equal "The secret is in the sauce\n", @response.body 289 end 290 260 291 def test_attempt_to_access_object_method 261 292 assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }