Tests for using asset_host with asset_hash

This commit is contained in:
Ben Hollis 2012-04-01 18:05:20 -07:00
parent 183e9d68f3
commit c27a288f1a
11 changed files with 66 additions and 15 deletions

View file

@ -8,7 +8,7 @@ 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-92072d15.css |
| stylesheets/site-8c28fde3.css |
| index.html |
| subdir/index.html |
| other/index.html |
@ -20,35 +20,47 @@ Feature: Assets get a file hash appended to their and references to them are upd
| stylesheets/site.css |
And the file "javascripts/application-1d8d5276.js" should contain "img.src = '/images/100px-5fd6fb90.jpg'"
# TODO: This stylesheet should use the SASS "image-url" helper but can't because of https://github.com/middleman/middleman/issues/283
And the file "stylesheets/site-92072d15.css" should contain 'background-image: url("/images/100px-5fd6fb90.jpg")'
And the file "index.html" should contain 'href="stylesheets/site-92072d15.css"'
And the file "stylesheets/site-8c28fde3.css" should contain "background-image: url('../images/100px-5fd6fb90.jpg')"
And the file "index.html" should contain 'href="stylesheets/site-8c28fde3.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 'href="../stylesheets/site-92072d15.css"'
And the file "subdir/index.html" should contain 'href="../stylesheets/site-8c28fde3.css"'
And the file "subdir/index.html" should contain 'src="../javascripts/application-1d8d5276.js"'
And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"'
And the file "other/index.html" should contain 'href="../stylesheets/site-92072d15.css"'
And the file "other/index.html" should contain 'href="../stylesheets/site-8c28fde3.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 "/"
Then I should see 'href="stylesheets/site-92072d15.css"'
Then I should see 'href="stylesheets/site-8c28fde3.css"'
And I should see 'src="javascripts/application-1d8d5276.js"'
And I should see 'src="images/100px-5fd6fb90.jpg"'
When I go to "/subdir/"
Then I should see 'href="../stylesheets/site-92072d15.css"'
Then I should see 'href="../stylesheets/site-8c28fde3.css"'
And I should see 'src="../javascripts/application-1d8d5276.js"'
And I should see 'src="../images/100px-5fd6fb90.jpg"'
When I go to "/other/"
Then I should see 'href="../stylesheets/site-92072d15.css"'
Then I should see 'href="../stylesheets/site-8c28fde3.css"'
And I should see 'src="../javascripts/application-1d8d5276.js"'
And I should see 'src="../images/100px-5fd6fb90.jpg"'
When I go to "/javascripts/application-1d8d5276.js"
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
When I go to "/stylesheets/site-92072d15.css"
Then I should see 'background-image: url("/images/100px-5fd6fb90.jpg")'
When I go to "/stylesheets/site-8c28fde3.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-8c28fde3.css"'
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
When I go to "/subdir/"
Then I should see 'href="http://middlemanapp.com/stylesheets/site-8c28fde3.css"'
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
When I go to "/other/"
Then I should see 'href="http://middlemanapp.com/stylesheets/site-8c28fde3.css"'
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
# Asset helpers don't appear to work from Compass right now
# When I go to "/stylesheets/site-8c28fde3.css"
# Then I should see "background-image: url('http://middlemanapp.com/images/100px-5fd6fb90.jpg')"

View file

@ -1,6 +1,4 @@
#main {
padding: 50px;
// Can't use image-url until compass problem is fixed: https://github.com/middleman/middleman/issues/283
// background-image: image-url('100px.jpg');
background-image: url('/images/100px.jpg');
background-image: image-url('100px.jpg');
}

View file

@ -0,0 +1,6 @@
activate :asset_hash
activate :directory_indexes
activate :asset_host
set :asset_host, 'http://middlemanapp.com'

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

View file

@ -0,0 +1,6 @@
<% content_for :head do %>
<title>The Middleman!</title>
<% end %>
<h2>Image url:</h2>
<%= image_tag('100px.jpg') %>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%= stylesheet_link_tag "site" %>
<%= yield_content :head %>
</head>
<body class="<%= page_classes %>">
<div id="main" role="main">
<%= yield %>
</div>
</body>
</html>

View file

@ -0,0 +1,2 @@
<h2>Image url:</h2>
<img src="<%= image_path('100px.jpg') %>">

View file

@ -0,0 +1,4 @@
#main {
padding: 50px;
background-image: image-url('100px.jpg');
}

View file

@ -0,0 +1,6 @@
<% content_for :head do %>
<title>The Middleman!</title>
<% end %>
<h2>Image url:</h2>
<%= image_tag('100px.jpg') %>