link to correct link for Most Popular from Personas subnav (bug 697402)

This commit is contained in:
Chris Van 2011-10-27 10:03:11 -07:00
Родитель 0deb8ce9e5
Коммит 9254d08b33
3 изменённых файлов: 44 добавлений и 4 удалений

Просмотреть файл

@ -21,7 +21,12 @@
<nav id="site-nav" class="menu-nav c"> <nav id="site-nav" class="menu-nav c">
<ul> <ul>
{{ section('extensions', _('Extensions'), url('browse.extensions'), extras, extensions) }} {{ section('extensions', _('Extensions'), url('browse.extensions'), extras, extensions) }}
{{ section('personas', _('Personas'), url('browse.personas'), extras, personas) }} {% set persona_extras = (
('popular', _('Most Popular')),
('rating', _('Top Rated')),
('created', _('Newest')),
) %}
{{ section('personas', _('Personas'), url('browse.personas'), persona_extras, personas) }}
{% if themes %} {% if themes %}
{% set theme_extras = ( {% set theme_extras = (
('users', _('Most Popular')), ('users', _('Most Popular')),

Просмотреть файл

@ -15,9 +15,10 @@ from django.utils import translation
import elasticutils import elasticutils
import nose import nose
import mock import mock
from pyquery import PyQuery as pq
from nose.tools import eq_, nottest from nose.tools import eq_, nottest
import test_utils
from redisutils import mock_redis, reset_redis from redisutils import mock_redis, reset_redis
import test_utils
import amo import amo
from amo.urlresolvers import Prefixer, get_url_prefix, set_url_prefix from amo.urlresolvers import Prefixer, get_url_prefix, set_url_prefix
@ -68,6 +69,28 @@ def assert_required(error_msg):
eq_(error_msg, unicode(Field.default_error_messages['required'])) eq_(error_msg, unicode(Field.default_error_messages['required']))
def check_links(expected, elements, verify=True):
"""Useful for comparing an `expected` list of links against PyQuery
`elements`. Expected format of links is a list of tuples, like so:
[
('Home', '/'),
('Extensions', reverse('browse.extensions')),
...
]
Links are verified by default.
"""
for idx, element in enumerate(elements):
e = pq(element)
text, href = expected[idx]
eq_(e.text(), text)
eq_(e.attr('href'), href)
if verify and href != '#':
eq_(Client().head(href, follow=True).status_code, 200)
class RedisTest(object): class RedisTest(object):
"""Mixin for when you need to mock redis for testing.""" """Mixin for when you need to mock redis for testing."""

Просмотреть файл

@ -20,9 +20,10 @@ from waffle import helpers
import amo.tests import amo.tests
from access import acl from access import acl
from addons.models import Addon, AddonUser from addons.models import Addon, AddonUser
from amo.helpers import locale_url from amo.helpers import locale_url, urlparams
from amo.urlresolvers import reverse
from amo.pyquery_wrapper import PyQuery from amo.pyquery_wrapper import PyQuery
from amo.tests import check_links
from amo.urlresolvers import reverse
from stats.models import SubscriptionEvent, Contribution from stats.models import SubscriptionEvent, Contribution
from users.models import UserProfile from users.models import UserProfile
@ -566,6 +567,17 @@ class TestOtherStuff(amo.tests.TestCase):
eq_(doc('#site-nav #more .more-lang a').attr('href'), eq_(doc('#site-nav #more .more-lang a').attr('href'),
reverse('browse.language-tools')) reverse('browse.language-tools'))
def test_personas_subnav(self):
doc = pq(self.client.get(reverse('home')).content)
base_url = reverse('browse.personas')
expected = [
('Personas', base_url),
('Most Popular', urlparams(base_url, sort='popular')),
('Top Rated', urlparams(base_url, sort='rating')),
('Newest', urlparams(base_url, sort='created')),
]
check_links(expected, doc('#site-nav #personas a'))
def test_mobile_link_firefox(self): def test_mobile_link_firefox(self):
doc = pq(test.Client().get('/firefox', follow=True).content) doc = pq(test.Client().get('/firefox', follow=True).content)
eq_(doc('#site-nav #more .more-mobile a').attr('href'), eq_(doc('#site-nav #more .more-mobile a').attr('href'),