Add test for asset_hashing rack-filtered items.
This commit is contained in:
parent
266e24e03e
commit
4076666c19
2 changed files with 31 additions and 1 deletions
|
@ -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'
|
||||
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'
|
||||
|
|
16
middleman-more/fixtures/asset-hash-app/lib/middleware.rb
Normal file
16
middleman-more/fixtures/asset-hash-app/lib/middleware.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue