Commit 6caa32c4 by Timothée Peignier

Merge pull request #250 from caioariede/middleware_pipeline_enabled

MinifyHTMLMiddleware should rely on PIPELINE_ENABLED, not DEBUG
parents 8d8b8118 ee3f5f18
......@@ -17,6 +17,7 @@ or just made Pipeline more awesome.
* Brant Young <brant.young@gmail.com>
* Brian Montgomery <brianm@appliedsec.com>
* Bryan Chow <bryan@fullfactor.com>
* Caio Ariede <caio.ariede@gmail.com>
* Camilo Nova <camilo.nova@gmail.com>
* Carl Meyer <carl@oddbird.net>
* Casey Greene <csgreene@princeton.edu>
......
......@@ -9,8 +9,7 @@ from pipeline.conf import settings
class MinifyHTMLMiddleware(object):
def __init__(self):
if settings.DEBUG:
# On debug does not minify html
if not settings.PIPELINE_ENABLED:
raise MiddlewareNotUsed
def process_response(self, request, response):
......
......@@ -5,6 +5,8 @@ from django.test import TestCase
from django.conf import settings
from django.core.urlresolvers import reverse
from tests.utils import pipeline_settings
class MiddlewareTest(TestCase):
def test_middleware_off(self):
......@@ -27,3 +29,25 @@ class MiddlewareTest(TestCase):
length = str(len(response.content))
self.assertEqual(length, response['Content-Length'])
def test_middleware_pipeline_enabled(self):
CUSTOM_MIDDLEWARE = (
'django.middleware.gzip.GZipMiddleware',
'pipeline.middleware.MinifyHTMLMiddleware',
) + settings.MIDDLEWARE_CLASSES
with self.settings(MIDDLEWARE_CLASSES=CUSTOM_MIDDLEWARE):
with pipeline_settings(PIPELINE_ENABLED=True):
response = self.client.get(reverse('admin:index'))
self.assertNotIn(' ', response.content)
def test_middleware_pipeline_disabled(self):
CUSTOM_MIDDLEWARE = (
'django.middleware.gzip.GZipMiddleware',
'pipeline.middleware.MinifyHTMLMiddleware',
) + settings.MIDDLEWARE_CLASSES
with self.settings(MIDDLEWARE_CLASSES=CUSTOM_MIDDLEWARE):
with pipeline_settings(PIPELINE_ENABLED=False):
response = self.client.get(reverse('admin:index'))
self.assertIn(' ', response.content)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment