From: Stephen Finucane Date: Thu, 18 Feb 2016 15:25:52 +0000 (+0000) Subject: filters: Re-add mistakenly removed method X-Git-Tag: v1.1.0~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=30a175622b89f2354ab357a23caf1c60c45796cc;p=thirdparty%2Fpatchwork.git filters: Re-add mistakenly removed method 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 --- diff --git a/patchwork/filters.py b/patchwork/filters.py index 7d0d03ca..56500148 100644 --- a/patchwork/filters.py +++ b/patchwork/filters.py @@ -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, diff --git a/patchwork/tests/test_user.py b/patchwork/tests/test_user.py index c27328e1..bd97eb74 100644 --- a/patchwork/tests/test_user.py +++ b/patchwork/tests/test_user.py @@ -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