]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
filters: Re-add mistakenly removed method
authorStephen Finucane <stephen.finucane@intel.com>
Thu, 18 Feb 2016 15:25:52 +0000 (15:25 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Thu, 18 Feb 2016 21:13:16 +0000 (21:13 +0000)
Removing this method resulted in an issue whereby a user could not
access their "TODO list". Add tests to ensure this doesn't happen
again.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
patchwork/filters.py
patchwork/tests/test_user.py

index 7d0d03cad33b05afac19dcdf2d49f12f2987890c..565001487f92298715d012de952beea880b6512c 100644 (file)
@@ -390,6 +390,15 @@ class DelegateFilter(Filter):
             return self.delegate.id
         return self.delegate_match
 
+    def set_status(self, *args, **kwargs):
+        if 'delegate' in kwargs:
+            self.applied = self.forced = True
+            self.delegate = kwargs['delegate']
+        if self.AnyDelegate in args:
+            self.applied = False
+            self.forced = True
+
+
 filterclasses = [SubmitterFilter,
                  StateFilter,
                  SearchFilter,
index c27328e16e404e903afb0ba59d3580b6d6e0edb1..bd97eb74c109d6a634613c20b067a743b135dac8 100644 (file)
@@ -23,7 +23,8 @@ from django.core import mail
 from django.core.urlresolvers import reverse
 from django.test import TestCase
 
-from patchwork.models import EmailConfirmation, Person, Bundle, UserProfile
+from patchwork.models import (EmailConfirmation, Person, Bundle, UserProfile,
+                              Patch)
 from patchwork.tests.utils import defaults, error_strings
 
 
@@ -136,11 +137,30 @@ class UserLoginRedirectTest(TestCase):
 
 class UserProfileTest(TestCase):
 
+    fixtures = ['default_states']
+
     def setUp(self):
         self.user = TestUser()
         self.client.login(username=self.user.username,
                           password=self.user.password)
 
+    # FIXME(stephenfin) Remove duplication from this and test_xmlrpc
+    def _createPatches(self, count=1):
+        defaults.project.save()
+        defaults.patch_author_person.save()
+
+        patches = []
+
+        for _ in range(0, count):
+            patch = Patch(project=defaults.project,
+                          submitter=defaults.patch_author_person,
+                          msgid=make_msgid(),
+                          content=defaults.patch)
+            patch.save()
+            patches.append(patch)
+
+        return patches
+
     def testUserProfile(self):
         response = self.client.get('/user/')
         self.assertContains(response, 'User Profile: %s' % self.user.username)
@@ -162,6 +182,17 @@ class UserProfileTest(TestCase):
         self.assertContains(response, 'You have the following bundle')
         self.assertContains(response, bundle.get_absolute_url())
 
+    def testUserProfileTodos(self):
+        patches = self._createPatches(5)
+        for patch in patches:
+            patch.delegate = self.user.user
+            patch.save()
+
+        response = self.client.get('/user/')
+
+        self.assertContains(response, 'contains 5')
+        self.assertContains(response, reverse('user-todos'))
+
     def testUserProfileValidPost(self):
         user_profile = UserProfile.objects.get(user=self.user.user.id)
         old_ppp = user_profile.patches_per_page