Parse asset-hashes on JSON files
This commit is contained in:
parent
1b0b666130
commit
17cddce675
|
@ -1,5 +1,5 @@
|
||||||
Feature: Assets get a file hash appended to their and references to them are updated
|
Feature: Assets get a file hash appended to their and references to them are updated
|
||||||
Scenario: Hashed-asset files are produced, and HTML, CSS, and JavaScript gets rewritten to reference the new files
|
Scenario: Hashed-asset files are produced, and HTML, CSS, JSON and JavaScript gets rewritten to reference the new files
|
||||||
Given a successfully built app at "asset-hash-app"
|
Given a successfully built app at "asset-hash-app"
|
||||||
When I cd to "build"
|
When I cd to "build"
|
||||||
Then the following files should exist:
|
Then the following files should exist:
|
||||||
|
@ -14,6 +14,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
| index.html |
|
| index.html |
|
||||||
| subdir/index.html |
|
| subdir/index.html |
|
||||||
| other/index.html |
|
| other/index.html |
|
||||||
|
| api.json |
|
||||||
|
| subdir/api.json |
|
||||||
And the following files should not exist:
|
And the following files should not exist:
|
||||||
| images/100px.png |
|
| images/100px.png |
|
||||||
| images/100px.jpg |
|
| images/100px.jpg |
|
||||||
|
@ -33,6 +35,12 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
And the file "other/index.html" should contain 'href="../stylesheets/site-50eaa978.css"'
|
And the file "other/index.html" should contain 'href="../stylesheets/site-50eaa978.css"'
|
||||||
And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
||||||
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
||||||
|
And the file "api.json" should contain 'images/100px-5fd6fb90.gif'
|
||||||
|
And the file "api.json" should contain 'images/100px-5fd6fb90.jpg'
|
||||||
|
And the file "api.json" should contain 'images/100px-1242c368.png'
|
||||||
|
And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.gif'
|
||||||
|
And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.jpg'
|
||||||
|
And the file "subdir/api.json" should contain 'images/100px-1242c368.png'
|
||||||
|
|
||||||
Scenario: Hashed assets work in preview server
|
Scenario: Hashed assets work in preview server
|
||||||
Given the Server is running at "asset-hash-app"
|
Given the Server is running at "asset-hash-app"
|
||||||
|
@ -53,6 +61,14 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
||||||
When I go to "/stylesheets/site-50eaa978.css"
|
When I go to "/stylesheets/site-50eaa978.css"
|
||||||
Then I should see "background-image: url('../images/100px-5fd6fb90.jpg')"
|
Then I should see "background-image: url('../images/100px-5fd6fb90.jpg')"
|
||||||
|
When I go to "/api.json"
|
||||||
|
Then I should see 'images/100px-5fd6fb90.gif'
|
||||||
|
And I should see 'images/100px-5fd6fb90.jpg'
|
||||||
|
And I should see 'images/100px-1242c368.png'
|
||||||
|
When I go to "/subdir/api.json"
|
||||||
|
Then I should see 'images/100px-5fd6fb90.gif'
|
||||||
|
And I should see 'images/100px-5fd6fb90.jpg'
|
||||||
|
And I should see 'images/100px-1242c368.png'
|
||||||
|
|
||||||
Scenario: Enabling an asset host still produces hashed files and references
|
Scenario: Enabling an asset host still produces hashed files and references
|
||||||
Given the Server is running at "asset-hash-host-app"
|
Given the Server is running at "asset-hash-host-app"
|
||||||
|
@ -127,6 +143,8 @@ Feature: Assets get a file hash appended to their and references to them are upd
|
||||||
| index.html |
|
| index.html |
|
||||||
| subdir/index.html |
|
| subdir/index.html |
|
||||||
| other/index.html |
|
| other/index.html |
|
||||||
|
| api.json |
|
||||||
|
| subdir/api.json |
|
||||||
And the following files should not exist:
|
And the following files should not exist:
|
||||||
| images/100px-1242c368.png |
|
| images/100px-1242c368.png |
|
||||||
| images/100px-5fd6fb90.jpg |
|
| images/100px-5fd6fb90.jpg |
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<%= {gif: image_path('100px.gif'), jpg: image_path('100px.jpg'), png: image_path('100px.png')}.to_json %>
|
|
@ -0,0 +1 @@
|
||||||
|
<%= {gif: image_path('100px.gif'), jpg: image_path('100px.jpg'), png: image_path('100px.png')}.to_json %>
|
|
@ -75,7 +75,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
||||||
|
|
||||||
path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app)
|
path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app)
|
||||||
|
|
||||||
if path =~ /(^\/$)|(\.(htm|html|php|css|js)$)/
|
if path =~ /(^\/$)|(\.(htm|html|php|css|js|json)$)/
|
||||||
body = ::Middleman::Util.extract_response_text(response)
|
body = ::Middleman::Util.extract_response_text(response)
|
||||||
if body
|
if body
|
||||||
status, headers, response = Rack::Response.new(rewrite_paths(body, path), status, headers).finish
|
status, headers, response = Rack::Response.new(rewrite_paths(body, path), status, headers).finish
|
||||||
|
|
Loading…
Reference in a new issue