Permalink
Browse files

Fix layouts in symlinked paths. Closes #9136 [court3nay, caio]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9120 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 6efee90 commit 5c0656c9ee9ecc7ffeebea69dc0cd371d978b254 @jeremy jeremy committed Mar 28, 2008
@@ -23,9 +23,8 @@ class << self #:nodoc:
def process_view_paths(*view_paths)
view_paths.flatten.compact.each do |dir|
next if @@processed_view_paths.has_key?(dir)
-
@@processed_view_paths[dir] = []
- Dir.glob("#{dir}/**/*").each do |file|
+ Dir.glob("#{dir}/**/*/**").each do |file|
unless File.directory?(file)
@@processed_view_paths[dir] << file.split(dir).last.sub(/^\//, '')
@@ -238,3 +238,22 @@ def test_layout_status_is_rendered
assert_response 401
end
end
+
+class LayoutSymlinkedTest < LayoutTest
+ layout "symlinked/symlinked_layout"
+end
+
+class LayoutSymlinkedIsRenderedTest < Test::Unit::TestCase
+ def setup
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_symlinked_layout_is_rendered
+ @controller = LayoutSymlinkedTest.new
+ get :hello
+ assert_response 200
+ assert_equal "layouts/symlinked/symlinked_layout", @response.layout
+ end
+end
+
@@ -0,0 +1,5 @@
+This is my layout
+
+<%= yield %>
+
+End.
@@ -21,14 +21,14 @@ def test_should_cache_file_extension_properly
assert_equal ["builder", "erb", "rhtml", "rjs", "rxml", "mab"].sort,
ActionView::TemplateFinder.file_extension_cache[LOAD_PATH_ROOT].values.flatten.uniq.sort
- assert_equal Dir.glob("#{LOAD_PATH_ROOT}/**/*.{erb,rjs,rhtml,builder,rxml,mab}").size,
+ assert_equal Dir.glob("#{LOAD_PATH_ROOT}/**/*/*.{erb,rjs,rhtml,builder,rxml,mab}").size,
ActionView::TemplateFinder.file_extension_cache[LOAD_PATH_ROOT].keys.size
end
def test_should_cache_dir_content_properly
assert ActionView::TemplateFinder.processed_view_paths[LOAD_PATH_ROOT]
- assert_equal Dir.glob("#{LOAD_PATH_ROOT}/**/*").find_all {|f| !File.directory?(f) }.size,
- ActionView::TemplateFinder.processed_view_paths[LOAD_PATH_ROOT].size
+ assert_equal Dir.glob("#{LOAD_PATH_ROOT}/**/*/**").find_all {|f| !File.directory?(f) }.size,
+ ActionView::TemplateFinder.processed_view_paths[LOAD_PATH_ROOT].size
end
def test_find_template_extension_from_first_render
@@ -62,7 +62,7 @@ def test_should_report_file_exists_correctly
assert_equal false, @finder.send(:file_exists?, 'baz')
assert_equal false, @finder.send(:file_exists?, 'baz.rb')
end
-
+
uses_mocha 'Template finder tests' do
def test_should_update_extension_cache_when_template_handler_is_registered
ActionView::TemplateFinder.expects(:update_extension_cache_for).with("funky")

0 comments on commit 5c0656c

Please sign in to comment.