Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
My Apps should be listed in reverse chronological order (Bug 982854)
Browse files Browse the repository at this point in the history
  • Loading branch information
nearlyfreeapps committed Mar 22, 2014
1 parent e823522 commit 47ffd79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions mkt/account/tests/test_api.py
Expand Up @@ -263,8 +263,11 @@ def test_installed(self):

def test_installed_pagination(self):
ins1 = Installed.objects.create(user=self.user, addon=app_factory())
ins1.update(created=self.days_ago(1))
ins2 = Installed.objects.create(user=self.user, addon=app_factory())
ins2.update(created=self.days_ago(2))
ins3 = Installed.objects.create(user=self.user, addon=app_factory())
ins3.update(created=self.days_ago(3))
res = self.client.get(self.list_url, {'limit': 2})
eq_(res.status_code, 200)
data = json.loads(res.content)
Expand Down Expand Up @@ -294,6 +297,19 @@ def test_installed_pagination(self):
eq_(data['meta']['offset'], 2)
eq_(data['meta']['next'], None)

def test_installed_order(self):
# Should be reverse chronological order.
ins1 = Installed.objects.create(user=self.user, addon=app_factory())
ins1.update(created=self.days_ago(1))
ins2 = Installed.objects.create(user=self.user, addon=app_factory())
ins2.update(created=self.days_ago(2))
res = self.client.get(self.list_url)
eq_(res.status_code, 200)
data = json.loads(res.content)
eq_(len(data['objects']), 2)
eq_(data['objects'][0]['id'], ins1.addon.id)
eq_(data['objects'][1]['id'], ins2.addon.id)

def not_there(self):
res = self.client.get(self.list_url)
eq_(res.status_code, 200, res.content)
Expand Down
2 changes: 1 addition & 1 deletion mkt/account/views.py
Expand Up @@ -66,7 +66,7 @@ def get_queryset(self):
return Webapp.objects.no_cache().filter(
installed__user=self.request.amo_user,
installed__install_type=INSTALL_TYPE_USER).order_by(
'installed__id')
'-installed__created')


class CreateAPIViewWithoutModel(CreateAPIView):
Expand Down

0 comments on commit 47ffd79

Please sign in to comment.