make sure we're returning distinct user add-ons (bug 573774)
This commit is contained in:
Родитель
4305f6f747
Коммит
068822db4a
|
@ -79,8 +79,8 @@ class UserProfile(amo.models.ModelBase):
|
|||
|
||||
@amo.cached_property
|
||||
def addons_listed(self):
|
||||
"""public add-ons this user is listed as author of"""
|
||||
return self.addons.valid().filter(addonuser__listed=True)
|
||||
"""Public add-ons this user is listed as author of."""
|
||||
return self.addons.valid().filter(addonuser__listed=True).distinct()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.core import mail
|
|||
|
||||
from nose.tools import eq_
|
||||
|
||||
from addons.models import Addon
|
||||
from addons.models import Addon, AddonUser
|
||||
from reviews.models import Review
|
||||
from users.models import UserProfile, get_hexdigest
|
||||
|
||||
|
@ -108,6 +108,13 @@ class TestUserProfile(test.TestCase):
|
|||
assert new_reply.pk not in review_list, (
|
||||
'Developer reply must not show up in review list.')
|
||||
|
||||
def test_addons_listed(self):
|
||||
"""Make sure we're returning distinct add-ons."""
|
||||
AddonUser.objects.create(addon_id=3615, user_id=2519, listed=True)
|
||||
u = UserProfile.objects.get(id=2519)
|
||||
addons = u.addons_listed.values_list('id', flat=True)
|
||||
eq_(sorted(addons), [3615, 4664])
|
||||
|
||||
|
||||
class TestPasswords(test.TestCase):
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче