2015-02-22 23:44:17 +01:00
|
|
|
Feature: Assets get file hashes appended to them and references to them are updated
|
2014-09-28 22:39:46 +02:00
|
|
|
Scenario: Hashed-asset files are produced, and HTML, CSS, JSON and JavaScript gets rewritten to reference the new files
|
2012-03-05 00:24:38 +01:00
|
|
|
Given a successfully built app at "asset-hash-app"
|
|
|
|
When I cd to "build"
|
|
|
|
Then the following files should exist:
|
|
|
|
| index.html |
|
2012-05-27 00:08:59 +02:00
|
|
|
| apple-touch-icon.png |
|
2012-06-02 08:54:57 +02:00
|
|
|
| favicon.ico |
|
2012-03-05 00:24:38 +01:00
|
|
|
| images/100px-1242c368.png |
|
|
|
|
| images/100px-5fd6fb90.jpg |
|
2014-11-16 21:25:28 +01:00
|
|
|
| images/200px-c11eb203.jpg |
|
|
|
|
| images/300px-59adce76.jpg |
|
2012-03-05 00:24:38 +01:00
|
|
|
| images/100px-5fd6fb90.gif |
|
2012-05-24 23:29:29 +02:00
|
|
|
| javascripts/application-1d8d5276.js |
|
2015-09-17 22:53:43 +02:00
|
|
|
| stylesheets/site-8bc55985.css |
|
2012-03-05 00:24:38 +01:00
|
|
|
| index.html |
|
|
|
|
| subdir/index.html |
|
|
|
|
| other/index.html |
|
2014-09-28 22:39:46 +02:00
|
|
|
| api.json |
|
|
|
|
| subdir/api.json |
|
2012-03-05 00:24:38 +01:00
|
|
|
And the following files should not exist:
|
|
|
|
| images/100px.png |
|
|
|
|
| images/100px.jpg |
|
|
|
|
| images/100px.gif |
|
|
|
|
| javascripts/application.js |
|
|
|
|
| stylesheets/site.css |
|
2013-09-26 23:09:47 +02:00
|
|
|
|
2012-05-24 23:29:29 +02:00
|
|
|
And the file "javascripts/application-1d8d5276.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'"
|
2015-09-17 22:53:43 +02:00
|
|
|
And the file "stylesheets/site-8bc55985.css" should contain:
|
2014-04-07 21:43:16 +02:00
|
|
|
"""
|
|
|
|
background-image: url("../images/100px-5fd6fb90.jpg")
|
|
|
|
"""
|
2012-05-27 00:08:59 +02:00
|
|
|
And the file "index.html" should contain 'href="apple-touch-icon.png"'
|
2015-09-17 22:53:43 +02:00
|
|
|
And the file "index.html" should contain 'href="stylesheets/site-8bc55985.css"'
|
2012-05-24 23:29:29 +02:00
|
|
|
And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"'
|
2012-03-05 08:03:21 +01:00
|
|
|
And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
|
2015-09-17 22:53:43 +02:00
|
|
|
And the file "subdir/index.html" should contain 'href="../stylesheets/site-8bc55985.css"'
|
2014-11-16 21:25:28 +01:00
|
|
|
And the file "index.html" should contain 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
|
|
|
And the file "index.html" should contain 'src="images/100px-5fd6fb90.gif"'
|
|
|
|
And the file "index.html" should contain 'src="images/100px-1242c368.png"'
|
2012-05-24 23:29:29 +02:00
|
|
|
And the file "subdir/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
2012-03-05 08:03:21 +01:00
|
|
|
And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
2015-09-17 22:53:43 +02:00
|
|
|
And the file "other/index.html" should contain 'href="../stylesheets/site-8bc55985.css"'
|
2012-05-24 23:29:29 +02:00
|
|
|
And the file "other/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
|
2012-03-05 08:03:21 +01:00
|
|
|
And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
|
2014-09-28 22:39:46 +02:00
|
|
|
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'
|
2013-09-26 23:09:47 +02:00
|
|
|
|
2015-05-28 16:21:50 +02:00
|
|
|
Scenario: Hashed fonts assets work with woff and woff2 extension
|
|
|
|
Given a successfully built app at "asset-hash-app"
|
|
|
|
When I cd to "build"
|
|
|
|
Then the following files should exist:
|
|
|
|
| fonts/fontawesome-webfont-56ce13e7.woff |
|
|
|
|
| fonts/fontawesome-webfont-10752316.woff2 |
|
|
|
|
And the file "stylesheets/uses_fonts-88aa3e2b.css" should contain "src: url('../fonts/fontawesome-webfont-10752316.woff2')"
|
|
|
|
And the file "stylesheets/uses_fonts-88aa3e2b.css" should contain "url('../fonts/fontawesome-webfont-56ce13e7.woff')"
|
|
|
|
|
2012-03-05 00:24:38 +01:00
|
|
|
Scenario: Hashed assets work in preview server
|
|
|
|
Given the Server is running at "asset-hash-app"
|
|
|
|
When I go to "/"
|
2012-05-27 00:08:59 +02:00
|
|
|
Then I should see 'href="apple-touch-icon.png"'
|
2015-11-12 00:30:26 +01:00
|
|
|
And I should see 'href="stylesheets/site-d2959d87.css"'
|
2015-12-21 22:07:01 +01:00
|
|
|
And I should see 'href="stylesheets/fragment-a06f0dfc.css"'
|
2012-05-24 23:29:29 +02:00
|
|
|
And I should see 'src="javascripts/application-1d8d5276.js"'
|
2012-03-05 08:03:21 +01:00
|
|
|
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
2014-11-16 21:25:28 +01:00
|
|
|
And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
2015-12-21 22:07:01 +01:00
|
|
|
And I should see 'src="images/100px-5fd6fb90.jpg?test"'
|
|
|
|
And I should see 'src="images/100px-5fd6fb90.jpg?#test"'
|
|
|
|
And I should see 'src="images/100px-5fd6fb90.jpg#test"'
|
2012-03-05 00:24:38 +01:00
|
|
|
When I go to "/subdir/"
|
2015-11-12 00:30:26 +01:00
|
|
|
Then I should see 'href="../stylesheets/site-d2959d87.css"'
|
2012-05-24 23:29:29 +02:00
|
|
|
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
2012-03-05 08:03:21 +01:00
|
|
|
And I should see 'src="../images/100px-5fd6fb90.jpg"'
|
2012-03-05 00:24:38 +01:00
|
|
|
When I go to "/other/"
|
2015-11-12 00:30:26 +01:00
|
|
|
Then I should see 'href="../stylesheets/site-d2959d87.css"'
|
2012-05-24 23:29:29 +02:00
|
|
|
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
2012-03-05 08:03:21 +01:00
|
|
|
And I should see 'src="../images/100px-5fd6fb90.jpg"'
|
2015-12-21 22:07:01 +01:00
|
|
|
And I should see 'src="../images/100px-5fd6fb90.jpg?test"'
|
|
|
|
And I should see 'src="../images/100px-5fd6fb90.jpg?#test"'
|
|
|
|
And I should see 'src="../images/100px-5fd6fb90.jpg#test"'
|
2012-05-24 23:29:29 +02:00
|
|
|
When I go to "/javascripts/application-1d8d5276.js"
|
2012-03-05 00:24:38 +01:00
|
|
|
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
2015-11-12 00:30:26 +01:00
|
|
|
When I go to "/stylesheets/site-d2959d87.css"
|
2014-11-19 18:04:56 +01:00
|
|
|
Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
|
2014-09-28 22:39:46 +02:00
|
|
|
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'
|
2015-12-21 22:07:01 +01:00
|
|
|
When I go to "/stylesheets/fragment-a06f0dfc.css"
|
|
|
|
And I should see 'url("../images/100px-5fd6fb90.jpg")'
|
|
|
|
And I should see 'url("../images/100px-5fd6fb90.jpg?test")'
|
|
|
|
And I should see 'url("../images/100px-5fd6fb90.jpg?#test")'
|
|
|
|
And I should see 'url("../images/100px-5fd6fb90.jpg#test")'
|
2012-03-05 00:24:38 +01:00
|
|
|
|
2015-04-26 18:31:39 +02:00
|
|
|
Scenario: Hashed assets work with Slim
|
|
|
|
Given the Server is running at "asset-hash-app"
|
|
|
|
When I go to "/slim.html"
|
2015-04-26 18:43:20 +02:00
|
|
|
And I should see 'src="images/300px-59adce76.jpg"'
|
2015-04-26 18:31:39 +02:00
|
|
|
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
|
|
|
And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
|
|
|
|
2013-09-26 23:09:47 +02:00
|
|
|
Scenario: Enabling an asset host still produces hashed files and references
|
2012-04-02 03:05:20 +02:00
|
|
|
Given the Server is running at "asset-hash-host-app"
|
|
|
|
When I go to "/"
|
2015-11-12 00:30:26 +01:00
|
|
|
Then I should see 'href="http://middlemanapp.com/stylesheets/site-e587b659.css"'
|
2015-12-21 22:07:01 +01:00
|
|
|
Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-7af0b5ab.css"'
|
2012-04-02 03:05:20 +02:00
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
2015-12-21 22:07:01 +01:00
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
2012-04-02 03:05:20 +02:00
|
|
|
When I go to "/subdir/"
|
2015-11-12 00:30:26 +01:00
|
|
|
Then I should see 'href="http://middlemanapp.com/stylesheets/site-e587b659.css"'
|
2012-04-02 03:05:20 +02:00
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
|
|
|
When I go to "/other/"
|
2015-11-12 00:30:26 +01:00
|
|
|
Then I should see 'href="http://middlemanapp.com/stylesheets/site-e587b659.css"'
|
2012-04-02 03:05:20 +02:00
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
2015-12-21 22:07:01 +01:00
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
|
|
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
|
|
|
When I go to "/stylesheets/fragment-7af0b5ab.css"
|
|
|
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg")'
|
|
|
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?test")'
|
|
|
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test")'
|
|
|
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg#test")'
|
2012-04-04 09:00:33 +02:00
|
|
|
|
2012-05-24 23:29:29 +02:00
|
|
|
Scenario: The asset hash should change when a SASS partial changes
|
2012-04-04 09:00:33 +02:00
|
|
|
Given the Server is running at "asset-hash-app"
|
|
|
|
And the file "source/stylesheets/_partial.sass" has the contents
|
|
|
|
"""
|
|
|
|
body
|
|
|
|
font-size: 14px
|
|
|
|
"""
|
|
|
|
When I go to "/partials/"
|
2015-11-12 00:30:26 +01:00
|
|
|
Then I should see 'href="../stylesheets/uses_partials-44fb2764.css'
|
2012-04-04 09:00:33 +02:00
|
|
|
And the file "source/stylesheets/_partial.sass" has the contents
|
|
|
|
"""
|
|
|
|
body
|
|
|
|
font-size: 18px !important
|
|
|
|
"""
|
|
|
|
When I go to "/partials/"
|
2015-11-12 00:30:26 +01:00
|
|
|
Then I should see 'href="../stylesheets/uses_partials-10d8ae33.css'
|
2012-09-06 21:30:47 +02:00
|
|
|
|
|
|
|
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'
|
2014-04-16 00:16:52 +02:00
|
|
|
use ::Middleware
|
2012-09-06 21:30:47 +02:00
|
|
|
"""
|
|
|
|
Given the Server is running at "asset-hash-app"
|
|
|
|
When I go to "/"
|
2015-11-12 00:30:26 +01:00
|
|
|
Then I should see 'href="stylesheets/site-30784643.css'
|
|
|
|
When I go to "stylesheets/site-30784643.css"
|
2012-09-11 06:56:12 +02:00
|
|
|
Then I should see 'background-image'
|
|
|
|
Then I should see 'Added by Rack filter'
|
2014-04-07 21:43:16 +02:00
|
|
|
When I go to "stylesheets/site-7474cadd.css"
|
2012-09-11 06:56:12 +02:00
|
|
|
Then I should see 'Not Found'
|
2012-12-18 11:19:41 +01:00
|
|
|
|
|
|
|
Scenario: Hashed-asset files are not produced for ignored paths
|
|
|
|
Given a fixture app "asset-hash-app"
|
|
|
|
And a file named "config.rb" with:
|
|
|
|
"""
|
2014-06-03 00:56:07 +02:00
|
|
|
is_stylesheet = proc { |path| path.start_with? 'stylesheets' }
|
|
|
|
activate :asset_hash, ignore: [
|
|
|
|
%r(javascripts/*),
|
|
|
|
'images/*',
|
|
|
|
is_stylesheet
|
|
|
|
]
|
2012-12-18 11:19:41 +01:00
|
|
|
activate :relative_assets
|
|
|
|
activate :directory_indexes
|
|
|
|
"""
|
|
|
|
And a successfully built app at "asset-hash-app"
|
|
|
|
When I cd to "build"
|
|
|
|
Then the following files should exist:
|
|
|
|
| index.html |
|
|
|
|
| apple-touch-icon.png |
|
|
|
|
| favicon.ico |
|
|
|
|
| images/100px.png |
|
|
|
|
| images/100px.jpg |
|
|
|
|
| images/100px.gif |
|
|
|
|
| javascripts/application.js |
|
2014-06-03 00:56:07 +02:00
|
|
|
| stylesheets/site.css |
|
2012-12-18 11:19:41 +01:00
|
|
|
| index.html |
|
|
|
|
| subdir/index.html |
|
|
|
|
| other/index.html |
|
2014-09-28 22:39:46 +02:00
|
|
|
| api.json |
|
|
|
|
| subdir/api.json |
|
2012-12-18 11:19:41 +01:00
|
|
|
And the following files should not exist:
|
|
|
|
| images/100px-1242c368.png |
|
|
|
|
| images/100px-5fd6fb90.jpg |
|
|
|
|
| images/100px-5fd6fb90.gif |
|
|
|
|
| javascripts/application-1d8d5276.js |
|
2014-04-07 21:43:16 +02:00
|
|
|
| stylesheets/site-7474cadd.css |
|
2013-09-26 23:09:47 +02:00
|
|
|
|
2016-01-08 22:56:42 +01:00
|
|
|
Scenario: Hashed-asset files are not replaced for rewrite ignored paths
|
|
|
|
Given a fixture app "asset-hash-app"
|
|
|
|
And a file named "config.rb" with:
|
|
|
|
"""
|
|
|
|
is_stylesheet = proc { |path| path.start_with? '/stylesheets' }
|
|
|
|
activate :asset_hash, rewrite_ignore: [
|
|
|
|
%r(javascripts/*),
|
|
|
|
'/subdir/*',
|
|
|
|
is_stylesheet
|
|
|
|
]
|
|
|
|
activate :relative_assets
|
|
|
|
activate :directory_indexes
|
|
|
|
"""
|
|
|
|
And a successfully built app at "asset-hash-app"
|
|
|
|
When I cd to "build"
|
|
|
|
Then the following files should exist:
|
|
|
|
| index.html |
|
|
|
|
| subdir/index.html |
|
|
|
|
| images/100px-5fd6fb90.jpg |
|
|
|
|
| javascripts/application-1d8d5276.js |
|
|
|
|
| stylesheets/site-8bc55985.css |
|
|
|
|
And the following files should not exist:
|
|
|
|
| images/100px.jpg |
|
|
|
|
| javascripts/application.js |
|
|
|
|
| stylesheets/site.css |
|
|
|
|
And the file "javascripts/application-1d8d5276.js" should contain "img.src = '/images/100px.jpg'"
|
|
|
|
And the file "stylesheets/site-8bc55985.css" should contain:
|
|
|
|
"""
|
|
|
|
background-image: url("../images/100px.jpg")
|
|
|
|
"""
|
|
|
|
And the file "index.html" should contain 'href="stylesheets/site-8bc55985.css"'
|
|
|
|
And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"'
|
|
|
|
And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"'
|
|
|
|
And the file "subdir/index.html" should contain:
|
|
|
|
"""
|
|
|
|
<h2>Image url3:</h2>
|
|
|
|
<p><img src="../images/100px.jpg"></p>
|
|
|
|
"""
|
|
|
|
|
2015-12-13 21:32:21 +01:00
|
|
|
Scenario: Already minified files should still be hashed
|
|
|
|
Given a successfully built app at "asset-hash-minified-app"
|
|
|
|
When I cd to "build"
|
|
|
|
Then the following files should exist:
|
|
|
|
| javascripts/jquery.min-276c87ff.js |
|
|
|
|
And the following files should not exist:
|
|
|
|
| javascripts/jquery.min.js |
|