From 0a97aa7ec3b45a3eafd615fa06649e346a3bfe54 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 1 Apr 2012 18:25:57 -0700 Subject: [PATCH] Fix undefined variable error in cache_buster, and make its tests more explicit. --- middleman-more/features/cache_buster.feature | 9 +++++---- .../cache-buster-app/source/cache-buster.html.erb | 3 ++- .../lib/middleman-more/extensions/cache_buster.rb | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/middleman-more/features/cache_buster.feature b/middleman-more/features/cache_buster.feature index 732902ee..7c094f7f 100644 --- a/middleman-more/features/cache_buster.feature +++ b/middleman-more/features/cache_buster.feature @@ -5,22 +5,23 @@ Feature: Generate mtime-based query string for busting browser caches Given "cache_buster" feature is "disabled" And the Server is running at "cache-buster-app" 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 Given "cache_buster" feature is "disabled" And the Server is running at "cache-buster-app" 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 Given "cache_buster" feature is "enabled" And the Server is running at "cache-buster-app" 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 Given "cache_buster" feature is "enabled" And the Server is running at "cache-buster-app" When I go to "/cache-buster.html" - Then I should see "?" \ No newline at end of file + Then I should see "site.css?" + Then I should see "blank.gif?" diff --git a/middleman-more/fixtures/cache-buster-app/source/cache-buster.html.erb b/middleman-more/fixtures/cache-buster-app/source/cache-buster.html.erb index 056b7ae4..41d2045f 100755 --- a/middleman-more/fixtures/cache-buster-app/source/cache-buster.html.erb +++ b/middleman-more/fixtures/cache-buster-app/source/cache-buster.html.erb @@ -1,2 +1,3 @@ <%= stylesheet_link_tag "site.css" %> -<%= javascript_include_tag "empty-with-include.js" %> \ No newline at end of file +<%= javascript_include_tag "empty-with-include.js" %> +<%= image_tag "blank.gif" %> diff --git a/middleman-more/lib/middleman-more/extensions/cache_buster.rb b/middleman-more/lib/middleman-more/extensions/cache_buster.rb index 647406fe..291c4ced 100755 --- a/middleman-more/lib/middleman-more/extensions/cache_buster.rb +++ b/middleman-more/lib/middleman-more/extensions/cache_buster.rb @@ -54,7 +54,7 @@ module Middleman::Extensions elsif sitemap.exists?(real_path_static) page = sitemap.page(real_path_static) if !page.template? - http_path << "?" + File.mtime(result[0]).strftime("%s") + http_path << "?" + File.mtime(page.source_file).strftime("%s") else # It's a template, possible with partials. We can't really know when # it's updated, so generate fresh cache buster every time durin @@ -71,4 +71,4 @@ module Middleman::Extensions # Register the extension # register :cache_buster, CacheBuster -end \ No newline at end of file +end