etianen/django-reversion — pull request #285 by jmoldow (2014-01-30 05:06:26+00:00)
Title: Fixes integration tests for RevisionMiddleware

```RevisionMiddleware``` is tested by applying it as a decorator to various view
functions. Django's ```decorator_from_middleware()``` utility function does the trick
of converting a middleware class to a decorator. However, in projects that
include the middleware in the ```MIDDLEWARE_CLASSES``` setting, the wrapped view
function is processed twice by the middleware. When ```RevisionMiddleware```
processes a function twice, an ```ImproperlyConfigured``` exception is raised. Thus,
use of Django's definition of ```decorator_from_middleware()``` was preventing
reversion integration tests from passing in projects that include
```RevisionMiddleware``` in ```MIDDLEWARE_CLASSES```.

To avoid this problem, this commit redefines ```decorator_from_middleware()``` to
return a decorator that does not reapply the middleware if it is in
```MIDDLEWARE_CLASSES```. ```@decorator_from_middleware(RevisionMiddleware)``` is then
used to wrap almost all ```RevisionMiddleware``` test views.

Thanks to @pricem and @gkanwar for identifying this issue.