Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
6d38a4dc
Commit
6d38a4dc
authored
Aug 26, 2013
by
Caio Ariede
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MinifyHTMLMiddleware should rely on PIPELINE_ENABLED, not DEBUG
parent
8d8b8118
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
pipeline/middleware.py
+1
-2
tests/tests/test_middleware.py
+24
-0
No files found.
pipeline/middleware.py
View file @
6d38a4dc
...
...
@@ -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
):
...
...
tests/tests/test_middleware.py
View file @
6d38a4dc
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment