Skip to content

Commit

Permalink
Creates lang directory when caching index file to prevent MultiViews …
Browse files Browse the repository at this point in the history
…confusion.
  • Loading branch information
gaspard committed Sep 5, 2012
1 parent 11af37a commit fd832d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/zena/use/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ def cache_page(opts={})
if perform_caching && caching_allowed(:authenticated => opts.delete(:authenticated))

url = page_cache_file(opts.delete(:url))
if url =~ %r{^/(\w\w)\.html$}
# Root cache: make sure we create directory to prevent
# Multiviews errors.
Dir.mkdir(SITES_ROOT + current_site.public_path + "/#{$1}")
end
opts = {:expire_after => nil,
:path => (current_site.public_path + url),
:content_data => response.body,
Expand Down
19 changes: 19 additions & 0 deletions test/integration/navigation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,25 @@ def test_bad_zip
follow_redirect!
assert_response :missing
end

def test_cache_root
without_files('test.host/public') do
preserving_files('/test.host/data') do
with_caching do
login(:anon)
root_path = "#{SITES_ROOT}#{visitor.site.public_path}/en.html"
lang_dir = "#{SITES_ROOT}#{visitor.site.public_path}/en"
assert !File.exists?(root_path), "No cached file yet"
assert !File.exists?(lang_dir), "No cached file yet"
get 'http://test.host/en'

# Both en.html and en directory exist
assert !File.exists?(root_path), "No cached file yet"
assert !File.exists?(lang_dir), "No cached file yet"
end
end
end
end

def test_should_not_change_session_lang_on_login
get 'http://test.host/'
Expand Down

0 comments on commit fd832d9

Please sign in to comment.