Commits

Jan-Jaap Driessen committed fefb2b3 Merge
  • Participants
  • Parent commits c7b8ca2, 65e529e

Comments (0)

Files changed (4)

 - Add "default" argument to Slot to specify a resource which will be filled
   in if there is no other resource specified in need().
 
+- Ensure published bundles carry the correct Content-Type header. Previously,
+  all bundles were delivered with `text/html`.
+
 
 0.14 (2012-10-30)
 =================

File fanstatic/publisher.py

         return webob.Response(
             body=b'\n'.join(contents),
             last_modified=mtime,
+            **self.kw
         ).conditional_response_app
 
 

File tests/test_bundle.py

     needed = NeededResources(resources=[x1, x2, x4, x5], bundle=True)
     assert needed.render() == '''<link rel="stylesheet" type="text/css" href="/fanstatic/foo/:bundle:a.css;b.css" />
 <link rel="stylesheet" type="text/css" href="/fanstatic/foo/subdir/subdir/:bundle:x4.css;x5.css" />'''
+

File tests/test_publisher.py

     request = webob.Request.blank('/fanstatic/foo/test.js')
     response = request.get_response(delegator)
     assert response.body == b'/* a test */'
+    assert response.content_type == 'text/javascript'
 
     # A deeper fanstatic.
     request = webob.Request.blank('/foo/bar/fanstatic/foo/test.js')
     response = request.get_response(delegator)
     assert response.body == b'/* a test */'
+    assert response.content_type == 'text/javascript'
 
     request = webob.Request.blank('/somethingelse')
     response = request.get_response(delegator)
     assert response.body == 'Hello world!'
+    #Default content type from WebOb
+    assert response.content_type == 'text/html'
 
 
 def test_publisher_ignores(tmpdir):
     assert response.body == b'''/* a test 1 */
 /* a test 2 */'''
     assert response.cache_control.max_age is None
+    assert response.content_type == 'text/javascript'
 
     request = webob.Request.blank('/foo/:version:123/:bundle:test1.js;test2.js')
     response = request.get_response(app)
     assert response
     assert response.cache_control.max_age is not None
+    assert response.content_type == 'text/javascript'
 
     # Dirty bundles yield a 404:
     request = webob.Request.blank('/foo/:bundle:test1.js;test2.js;test1.js')
     assert response.body == b'''r1
 r2
 r4'''
+    assert response.content_type == 'text/css'
 
     # An incorrect bundle, as the order of the paths does not correspond to
     # the dependency order of the Resources.