diff --git a/django/website/hid/tests/fast_dispatch.py b/django/website/hid/tests/fast_dispatch.py index a6448738dfa7a00fca4ebe110e59c2c2ab3c5498..27c76334d46eb785f3a97f27e89dc03a8dbac312 100644 --- a/django/website/hid/tests/fast_dispatch.py +++ b/django/website/hid/tests/fast_dispatch.py @@ -39,14 +39,18 @@ class FakeSession(collections.MutableMapping): def set_test_cookie(self): pass + def flush(self): + pass + + class FastDispatchMixin(object): default_cms_page = None - def get_fake_request(self, path, method='get', get_params=None, + def get_fake_request(self, path, method='get', get_params=None, post_params=None, request_extras=None, file_params=None): - get_params = get_params if get_params else {} + get_params = get_params if get_params else {} post_params = post_params if post_params else {} file_params = file_params if file_params else {} @@ -107,12 +111,12 @@ class FastDispatchMixin(object): return request - def fast_dispatch(self, view_name, method='get', url_args=None, + def fast_dispatch(self, view_name, method='get', url_args=None, url_kwargs=None, post_params=None, get_params=None, language=None, request_extras=None, file_params=None): - url_args = url_args if url_args else [] - url_kwargs = url_kwargs if url_kwargs else {} + url_args = url_args if url_args else [] + url_kwargs = url_kwargs if url_kwargs else {} from django.utils.translation import override with override(language): diff --git a/django/website/hid/tests/site_needs_authentication_tests.py b/django/website/hid/tests/site_needs_authentication_tests.py index 18ca667086810cd84f1a817c88ca56c9911d54a1..dd8dc443f4d37155bc497851ea6791c983b51592 100644 --- a/django/website/hid/tests/site_needs_authentication_tests.py +++ b/django/website/hid/tests/site_needs_authentication_tests.py @@ -18,3 +18,18 @@ class SiteNeedsAuthenticationTests(FastDispatchMixin, SimpleTestCase): response.render() self.assertIn('dashboard', response.content) + + def test_logout_view_logs_user_out(self): + self.user = User() + + self.fast_dispatch('dashboard') + + # The user when logged out should be None or AnonymousUser + # We check that logout works by getting the user from the logout + # request and using it as the user for the next one. + response = self.fast_dispatch('logout') + self.user = response.view.request.user + + response = self.fast_dispatch('dashboard') + + self.assertEqual(settings.LOGIN_URL + '?next=' + reverse('dashboard'), response['Location']) diff --git a/django/website/templates/registration/logged_out.html b/django/website/templates/registration/logged_out.html new file mode 100644 index 0000000000000000000000000000000000000000..2e883607951a0bf2fd914975f7afea900c71abb6 --- /dev/null +++ b/django/website/templates/registration/logged_out.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% load i18n %} +{% load bootstrap3 %} + + +{% block content %} +<h1>{% trans "Logged out" %}</h1> +<p> + You are logged out. + <a href="{% url "login" %}">{% trans "Log in again." %}</a> +</p> +{% endblock content %} \ No newline at end of file