middleman/middleman-core/features/content_type.feature
Ben Hollis 7a4aa109a6 Overhaul content-type handling, making it configurable via page/proxy commands as well as frontmatter with the 'content_type' parameter.
Now, users can set content type explicitly for their files in a number of ways, or rely on automatic file-extension content types. Proxied files default to automatic file-extension content types, but then fall back to the content type of the resource they proxy to. There is also a bug fixed around correctly setting content type inside send_file. Fixes #821.
2013-04-06 15:11:25 -07:00

44 lines
1.6 KiB
Gherkin

Feature: Setting the right content type for files
Scenario: The right content type gets automatically determined
Given the Server is running at "content-type-app"
When I go to "/index.html"
Then the content type should be "text/html"
When I go to "/images/blank.gif"
Then the content type should be "image/gif"
When I go to "/javascripts/app.js"
Then the content type should be "application/javascript"
When I go to "/stylesheets/site.css"
Then the content type should be "text/css"
When I go to "/README"
Then the content type should be "text/plain"
Scenario: Content type can be set explicitly via page or proxy or frontmatter
Given a fixture app "content-type-app"
And a file named "config.rb" with:
"""
page "README", :content_type => 'text/awesome'
proxy "bar", "index.html", :content_type => 'text/custom'
proxy "foo", "README" # auto-delegate to target content type
"""
And the Server is running at "content-type-app"
When I go to "/README"
Then the content type should be "text/awesome"
When I go to "/bar"
Then the content type should be "text/custom"
When I go to "/foo"
Then the content type should be "text/awesome"
When I go to "/override.html"
Then the content type should be "text/neato"
Scenario: Content types can be overridden with mime_type
Given a fixture app "content-type-app"
And a file named "config.rb" with:
"""
mime_type('.js', 'application/x-javascript')
"""
And the Server is running at "content-type-app"
When I go to "/javascripts/app.js"
Then the content type should be "application/x-javascript"