From 4076666c19b431d619a5fe11c3a892426b05a3ff Mon Sep 17 00:00:00 2001 From: Adam Luikart Date: Thu, 6 Sep 2012 14:30:47 -0500 Subject: [PATCH] Add test for asset_hashing rack-filtered items. --- middleman-more/features/asset_hash.feature | 16 +++++++++++++++- .../fixtures/asset-hash-app/lib/middleware.rb | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 middleman-more/fixtures/asset-hash-app/lib/middleware.rb diff --git a/middleman-more/features/asset_hash.feature b/middleman-more/features/asset_hash.feature index 34d9355f..b5945ba5 100644 --- a/middleman-more/features/asset_hash.feature +++ b/middleman-more/features/asset_hash.feature @@ -84,4 +84,18 @@ Feature: Assets get a file hash appended to their and references to them are upd font-size: 18px !important """ When I go to "/partials/" - Then I should see 'href="../stylesheets/uses_partials-e8c3d4eb.css' \ No newline at end of file + Then I should see 'href="../stylesheets/uses_partials-e8c3d4eb.css' + + Scenario: The asset hash should change when a Rack-based filter changes + Given a fixture app "asset-hash-app" + And a file named "config.rb" with: + """ + activate :asset_hash + activate :relative_assets + activate :directory_indexes + require 'lib/middleware.rb' + use Middleware + """ + Given the Server is running at "asset-hash-app" + When I go to "/" + Then I should see 'href="stylesheets/site-5770af52.css' diff --git a/middleman-more/fixtures/asset-hash-app/lib/middleware.rb b/middleman-more/fixtures/asset-hash-app/lib/middleware.rb new file mode 100644 index 00000000..8ee825fd --- /dev/null +++ b/middleman-more/fixtures/asset-hash-app/lib/middleware.rb @@ -0,0 +1,16 @@ +class Middleware + def initialize(app) + @app = app + end + + def call(env) + status, headers, response = @app.call(env) + body = '' + response.each {|part| body += part } + if (env["PATH_INFO"] =~ /css$/) + body += "\n/* Added by Rack filter */" + status, headers, response = Rack::Response.new(body, status, headers).finish + end + [status, headers, response] + end +end