Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7321

Show
Ignore:
Timestamp:
08/15/07 18:59:37 (1 year ago)
Author:
rick
Message:

Find layouts even if they're not in the first view_paths directory. Closes #9258 [caio]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r7276 r7321  
    11*SVN* 
     2 
     3* Find layouts even if they're not in the first view_paths directory.  Closes #9258 [caio] 
    24 
    35* Major improvement to the documentation for the options / select form helpers. Closes #9038 [kampers, jardeon, wesg] 
  • trunk/actionpack/lib/action_controller/layout.rb

    r6736 r7321  
    308308      # we cache this info in a class level hash 
    309309      def layout_directory?(layout_name) 
    310         view_paths.find do |path| 
    311           File.file?(File.join(path, 'layouts', layout_name)) 
    312         end 
    313         template_path ||= File.join(view_paths.first, 'layouts', layout_name) 
    314         dirname = File.dirname(template_path) 
    315         self.class.send(:layout_directory_exists_cache)[dirname] 
     310        view_paths.find do |path|  
     311          next unless template_path = Dir[File.join(path, 'layouts', layout_name) + ".*"].first 
     312          self.class.send(:layout_directory_exists_cache)[File.dirname(template_path)] 
     313        end 
    316314      end 
    317315  end 
  • trunk/actionpack/test/controller/view_paths_test.rb

    r7034 r7321  
    1919  end 
    2020   
     21  class Test::SubController < ActionController::Base 
     22    layout 'test/sub' 
     23    def hello_world; render 'test/hello_world'; end 
     24  end 
     25   
    2126  def setup 
    2227    TestController.view_paths = [ LOAD_PATH_ROOT ] 
     
    2833    @old_behavior = ActiveSupport::Deprecation.behavior 
    2934    @last_message = nil 
    30     ActiveSupport::Deprecation.behavior = Proc.new { |message| @last_message = message } 
     35    ActiveSupport::Deprecation.behavior = Proc.new { |message, callback| @last_message = message } 
    3136  end 
    3237   
     
    5055    assert_response :success 
    5156    assert_equal "Hello overridden world!", @response.body 
     57  end 
     58   
     59  def test_view_paths_override_for_layouts_in_controllers_with_a_module 
     60    @controller = Test::SubController.new 
     61    Test::SubController.view_paths = [ "#{LOAD_PATH_ROOT}/override", LOAD_PATH_ROOT, "#{LOAD_PATH_ROOT}/override2" ] 
     62    get :hello_world 
     63    assert_response :success 
     64    assert_equal "layout: Hello overridden world!", @response.body 
    5265  end 
    5366