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