Skip to content

Commit

Permalink
Fixed 500 instead of not found error when +notFound template does not…
Browse files Browse the repository at this point in the history
… exist, fixed expire on assets when site is private.
  • Loading branch information
gaspard committed Sep 28, 2010
1 parent c71f0de commit 2e5d0c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/zena/use/rendering.rb
Expand Up @@ -134,6 +134,11 @@ def render_and_cache(options={})

# Cache page content into a static file in the current sites directory : SITES_ROOT/test.host/public
def cache_page(opts={})
if cachestamp_format?(params['format'])
headers['Expires'] = (Time.now + 365*24*3600).strftime("%a, %d %b %Y %H:%M:%S GMT")
headers['Cache-Control'] = (!current_site.authentication? && @node.public?) ? 'public' : 'private'
end

return unless perform_caching && caching_allowed(:authenticated => opts.delete(:authenticated))
url = page_cache_file(opts.delete(:url))
opts = {:expire_after => nil,
Expand All @@ -142,10 +147,6 @@ def cache_page(opts={})
:node_id => @node[:id]
}.merge(opts)
secure!(CachedPage) { CachedPage.create(opts) }
if cachestamp_format?(params['format'])
headers['Expires'] = (Time.now + 365*24*3600).strftime("%a, %d %b %Y %H:%M:%S GMT")
headers['Cache-Control'] = 'public'
end
end

# Return true if we can cache the current page
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/use/zafu_templates.rb
Expand Up @@ -141,7 +141,7 @@ def valid_template?(content, opts)
def default_template_url(opts = {})
if opts[:format] && opts[:format] != 'html'
raise ActiveRecord::RecordNotFound
elsif %w{+login +index +adminLayout +popupLayout}.include?(opts[:mode])
elsif %w{+login +index +adminLayout +popupLayout +notFound}.include?(opts[:mode])
zafu_url ="$default/Node-#{opts[:mode]}"
elsif opts[:mode]
raise ActiveRecord::RecordNotFound
Expand Down
8 changes: 8 additions & 0 deletions test/integration/navigation_test.rb
Expand Up @@ -239,6 +239,14 @@ def test_bad_url
get 'http://test.host/en/node1.html'
assert_response :missing
end

def test_bad_url_without_notFound_template
$_test_site = 'zena'
Node.connection.execute "UPDATE nodes SET kpath='N' where id = #{nodes_id(:Node_not_found_zafu)}"
post 'http://test.host/session', :login=>'tiger', :password=>'tiger'
get 'http://test.host/oo/node1.html'
assert_response :missing
end

def test_bad_zip
get 'http://test.host/1'
Expand Down

0 comments on commit 2e5d0c3

Please sign in to comment.