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

Commit

Permalink
no ratings for categories/applications (bug 859516)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Short committed May 7, 2013
1 parent 0032101 commit daec432
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion apps/api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pyquery import PyQuery as pq

import amo
from addons.models import (Addon, AppSupport, CompatOverride,
from addons.models import (Addon, AppSupport, Category, CompatOverride,
CompatOverrideRange, Persona, Preview)
from amo import helpers
from amo.helpers import absolutify
Expand Down Expand Up @@ -1266,6 +1266,16 @@ def test_suggestions(self):
eq_(data['name'], a.name)
eq_(data['rating'], a.average_rating)

def test_category_suggestions(self):
cat = Category.objects.get(slug='feeds')
response = self.client.get(
'/en-US/firefox/api/%.1f/search_suggestions/?q=Feed' %
api.CURRENT_VERSION)
data = json.loads(response.content)['suggestions'][0]
eq_(data['id'], cat.pk)
eq_(data['name'], cat.name)
assert 'rating' not in data


class LanguagePacks(UploadTest):
fixtures = ['addons/listed', 'base/apps', 'base/platforms']
Expand Down
3 changes: 2 additions & 1 deletion apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ def search_suggestions(request):
suggester = suggesterClass(request, ratings=True)
suggs = _build_suggestions(request, cat, suggester)
for s in suggs:
s['rating'] = float(s['rating'])
if 'rating' in s:
s['rating'] = float(s['rating'])
return {'suggestions': suggs}


Expand Down

0 comments on commit daec432

Please sign in to comment.