Changeset 7321
- Timestamp:
- 08/15/07 18:59:37 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/layout.rb (modified) (1 diff)
- trunk/actionpack/test/controller/view_paths_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r7276 r7321 1 1 *SVN* 2 3 * Find layouts even if they're not in the first view_paths directory. Closes #9258 [caio] 2 4 3 5 * 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 308 308 # we cache this info in a class level hash 309 309 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 316 314 end 317 315 end trunk/actionpack/test/controller/view_paths_test.rb
r7034 r7321 19 19 end 20 20 21 class Test::SubController < ActionController::Base 22 layout 'test/sub' 23 def hello_world; render 'test/hello_world'; end 24 end 25 21 26 def setup 22 27 TestController.view_paths = [ LOAD_PATH_ROOT ] … … 28 33 @old_behavior = ActiveSupport::Deprecation.behavior 29 34 @last_message = nil 30 ActiveSupport::Deprecation.behavior = Proc.new { |message | @last_message = message }35 ActiveSupport::Deprecation.behavior = Proc.new { |message, callback| @last_message = message } 31 36 end 32 37 … … 50 55 assert_response :success 51 56 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 52 65 end 53 66