Browse files

Test for deleting cookies on logout + corrections in cookies deletion.

  • Loading branch information...
1 parent 9b33efa commit c51a622936348bf05e15632a8b17563180a5825e @fjern fjern committed May 24, 2012
Showing with 33 additions and 3 deletions.
  1. +31 −1 oscar/apps/customer/tests.py
  2. +1 −1 oscar/apps/customer/views.py
  3. +1 −1 oscar/defaults.py
View
32 oscar/apps/customer/tests.py
@@ -11,6 +11,13 @@
from oscar.test.helpers import create_product, create_order
+def create_test_user():
+ username = 'customer'
+ password = 'cheeseshop'
+ email = 'customer@example.com'
+
+
+
class HistoryHelpersTest(TestCase):
def setUp(self):
@@ -75,7 +82,7 @@ class EditProfileTests(TestCase):
def setUp(self):
User.objects.create_user(username=self.username,
email=self.email, password=self.password)
- is_successful = self.client.login(username=self.username,
+ is_successful = self.client.login(username=self.username,
password=self.password)
if not is_successful:
self.fail("Unable to login as %s" % self.username)
@@ -88,3 +95,26 @@ def test_update_profile_page_for_smoke(self):
response = self.client.get(url)
self.assertEqual(200, response.status_code)
self.assertTrue('form' in response.context)
+
+
+class AuthTestCase(TestCase):
+
+ username = 'customer'
+ password = 'cheeseshop'
+ email = 'customer@example.com'
+
+ def setUp(self):
+ self.client = Client()
+ self.product = create_product()
+ User.objects.create_user(username=self.username,
+ email=self.email, password=self.password)
+ self.client.login(username=self.username, password=self.password)
+
+ def test_cookies_deleted_on_logout(self):
+ response = self.client.get(self.product.get_absolute_url())
+ self.assertTrue('oscar_recently_viewed_products' in response.cookies)
+
+ response = self.client.get(reverse('customer:logout'))
+ self.assertTrue(('oscar_recently_viewed_products' not in response.cookies)
+ or not
+ self.client.cookies['oscar_recently_viewed_products'].coded_value)
View
2 oscar/apps/customer/views.py
@@ -37,7 +37,7 @@ def get(self, request, *args, **kwargs):
auth_logout(request)
response = super(LogoutView, self).get(request, *args, **kwargs)
- for cookie in settings.COOKIES_DELETE_ON_LOGOUT:
+ for cookie in settings.OSCAR_COOKIES_DELETE_ON_LOGOUT:
response.delete_cookie(cookie)
return response
View
2 oscar/defaults.py
@@ -54,4 +54,4 @@
OSCAR_MAX_BASKET_QUANTITY_THRESHOLD = None
#Cookies
-COOKIES_DELETE_ON_LOGOUT = ['oscar_recently_viewed_products', ]
+OSCAR_COOKIES_DELETE_ON_LOGOUT = ['oscar_recently_viewed_products', ]

0 comments on commit c51a622

Please sign in to comment.