Fix undefined variable error in cache_buster, and make its tests more explicit.

This commit is contained in:
Ben Hollis 2012-04-01 18:25:57 -07:00
parent 7e816c04c0
commit 0a97aa7ec3
3 changed files with 9 additions and 7 deletions

View file

@ -5,22 +5,23 @@ Feature: Generate mtime-based query string for busting browser caches
Given "cache_buster" feature is "disabled" Given "cache_buster" feature is "disabled"
And the Server is running at "cache-buster-app" And the Server is running at "cache-buster-app"
When I go to "/stylesheets/relative_assets.css" When I go to "/stylesheets/relative_assets.css"
Then I should not see "?" Then I should see "blank.gif'"
Scenario: Rendering html with the feature disabled Scenario: Rendering html with the feature disabled
Given "cache_buster" feature is "disabled" Given "cache_buster" feature is "disabled"
And the Server is running at "cache-buster-app" And the Server is running at "cache-buster-app"
When I go to "/cache-buster.html" When I go to "/cache-buster.html"
Then I should not see "?" Then I should see 'site.css"'
Scenario: Rendering css with the feature enabled Scenario: Rendering css with the feature enabled
Given "cache_buster" feature is "enabled" Given "cache_buster" feature is "enabled"
And the Server is running at "cache-buster-app" And the Server is running at "cache-buster-app"
When I go to "/stylesheets/relative_assets.css" When I go to "/stylesheets/relative_assets.css"
Then I should see "?" Then I should see "blank.gif?"
Scenario: Rendering html with the feature enabled Scenario: Rendering html with the feature enabled
Given "cache_buster" feature is "enabled" Given "cache_buster" feature is "enabled"
And the Server is running at "cache-buster-app" And the Server is running at "cache-buster-app"
When I go to "/cache-buster.html" When I go to "/cache-buster.html"
Then I should see "?" Then I should see "site.css?"
Then I should see "blank.gif?"

View file

@ -1,2 +1,3 @@
<%= stylesheet_link_tag "site.css" %> <%= stylesheet_link_tag "site.css" %>
<%= javascript_include_tag "empty-with-include.js" %> <%= javascript_include_tag "empty-with-include.js" %>
<%= image_tag "blank.gif" %>

View file

@ -54,7 +54,7 @@ module Middleman::Extensions
elsif sitemap.exists?(real_path_static) elsif sitemap.exists?(real_path_static)
page = sitemap.page(real_path_static) page = sitemap.page(real_path_static)
if !page.template? if !page.template?
http_path << "?" + File.mtime(result[0]).strftime("%s") http_path << "?" + File.mtime(page.source_file).strftime("%s")
else else
# It's a template, possible with partials. We can't really know when # It's a template, possible with partials. We can't really know when
# it's updated, so generate fresh cache buster every time durin # it's updated, so generate fresh cache buster every time durin