diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-28 20:54:26 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-28 20:54:26 +0000 |
commit | 5c0656c9ee9ecc7ffeebea69dc0cd371d978b254 (patch) | |
tree | fff923a09f4eb9c1f94a18d02458275249f8d705 | |
parent | 6efee90bf234328e3672bc79408c2da5b9673539 (diff) | |
download | rails-5c0656c9ee9ecc7ffeebea69dc0cd371d978b254.tar.gz rails-5c0656c9ee9ecc7ffeebea69dc0cd371d978b254.tar.bz2 rails-5c0656c9ee9ecc7ffeebea69dc0cd371d978b254.zip |
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
5 files changed, 30 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/template_finder.rb b/actionpack/lib/action_view/template_finder.rb index 0fb5eaa65e..aaf34de538 100644 --- a/actionpack/lib/action_view/template_finder.rb +++ b/actionpack/lib/action_view/template_finder.rb @@ -23,9 +23,8 @@ module ActionView #: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(/^\//, '') diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index c8507af532..145543a357 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -238,3 +238,22 @@ class LayoutStatusIsRenderedTest < Test::Unit::TestCase 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 +
\ No newline at end of file diff --git a/actionpack/test/fixtures/layout_tests/layouts/symlinked b/actionpack/test/fixtures/layout_tests/layouts/symlinked new file mode 120000 index 0000000000..0ddc1154ab --- /dev/null +++ b/actionpack/test/fixtures/layout_tests/layouts/symlinked @@ -0,0 +1 @@ +../../symlink_parent
\ No newline at end of file diff --git a/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb b/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb new file mode 100644 index 0000000000..bda57d0fae --- /dev/null +++ b/actionpack/test/fixtures/symlink_parent/symlinked_layout.erb @@ -0,0 +1,5 @@ +This is my layout + +<%= yield %> + +End. diff --git a/actionpack/test/template/template_finder_test.rb b/actionpack/test/template/template_finder_test.rb index 296815f4cb..a162640de3 100644 --- a/actionpack/test/template/template_finder_test.rb +++ b/actionpack/test/template/template_finder_test.rb @@ -21,14 +21,14 @@ class TemplateFinderTest < Test::Unit::TestCase 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 @@ class TemplateFinderTest < Test::Unit::TestCase 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") |