From 2738e8ea69c861117f905f6a912141f250185c58 Mon Sep 17 00:00:00 2001 From: Ali Bosworth Date: Thu, 26 Sep 2013 14:09:47 -0700 Subject: [PATCH] Add test against URL fragments for asset hashes --- middleman-core/features/asset_hash.feature | 20 +++++++++++++++---- .../source/stylesheets/fragment.css.scss | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 middleman-core/fixtures/asset-hash-host-app/source/stylesheets/fragment.css.scss diff --git a/middleman-core/features/asset_hash.feature b/middleman-core/features/asset_hash.feature index 06d395fd..67abdd43 100644 --- a/middleman-core/features/asset_hash.feature +++ b/middleman-core/features/asset_hash.feature @@ -20,7 +20,7 @@ Feature: Assets get a file hash appended to their and references to them are upd | images/100px.gif | | javascripts/application.js | | stylesheets/site.css | - + And the file "javascripts/application-1d8d5276.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'" And the file "stylesheets/site-50eaa978.css" should contain "background-image: url('../images/100px-5fd6fb90.jpg')" And the file "index.html" should contain 'href="apple-touch-icon.png"' @@ -33,7 +33,7 @@ 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 'src="../javascripts/application-1d8d5276.js"' And the file "other/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"' - + Scenario: Hashed assets work in preview server Given the Server is running at "asset-hash-app" When I go to "/" @@ -54,7 +54,7 @@ Feature: Assets get a file hash appended to their and references to them are upd When I go to "/stylesheets/site-50eaa978.css" Then I should see "background-image: url('../images/100px-5fd6fb90.jpg')" - 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" When I go to "/" Then I should see 'href="http://middlemanapp.com/stylesheets/site-54baaf3a.css"' @@ -132,4 +132,16 @@ Feature: Assets get a file hash appended to their and references to them are upd | images/100px-5fd6fb90.jpg | | images/100px-5fd6fb90.gif | | javascripts/application-1d8d5276.js | - | stylesheets/site.css | \ No newline at end of file + | stylesheets/site.css | + + Scenario: Enabling an asset host and referencing assets in CSS with URL fragments are rewritten correctly + Given a successfully built app at "asset-hash-host-app" + When I cd to "build" + + Then the following files should exist: + | images/100px-5fd6fb90.jpg | + And the following files should not exist: + | images/100px.jpg | + + And the file "stylesheets/fragment-c058ecb2.css" should contain "http://middlemanapp.com/images/100px-5fd6fb90.jpg#test" + And the file "stylesheets/fragment-c058ecb2.css" should not contain "http://middlemanapp.com/images/100px.jpg#test" diff --git a/middleman-core/fixtures/asset-hash-host-app/source/stylesheets/fragment.css.scss b/middleman-core/fixtures/asset-hash-host-app/source/stylesheets/fragment.css.scss new file mode 100644 index 00000000..b169b432 --- /dev/null +++ b/middleman-core/fixtures/asset-hash-host-app/source/stylesheets/fragment.css.scss @@ -0,0 +1,4 @@ +#main { + padding: 50px; + background-image: image-url('100px.jpg#test'); +}