link to correct link for Most Popular from Personas subnav (bug 697402)
This commit is contained in:
Родитель
0deb8ce9e5
Коммит
9254d08b33
|
@ -21,7 +21,12 @@
|
|||
<nav id="site-nav" class="menu-nav c">
|
||||
<ul>
|
||||
{{ 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 %}
|
||||
{% set theme_extras = (
|
||||
('users', _('Most Popular')),
|
||||
|
|
|
@ -15,9 +15,10 @@ from django.utils import translation
|
|||
import elasticutils
|
||||
import nose
|
||||
import mock
|
||||
from pyquery import PyQuery as pq
|
||||
from nose.tools import eq_, nottest
|
||||
import test_utils
|
||||
from redisutils import mock_redis, reset_redis
|
||||
import test_utils
|
||||
|
||||
import amo
|
||||
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']))
|
||||
|
||||
|
||||
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):
|
||||
"""Mixin for when you need to mock redis for testing."""
|
||||
|
||||
|
|
|
@ -20,9 +20,10 @@ from waffle import helpers
|
|||
import amo.tests
|
||||
from access import acl
|
||||
from addons.models import Addon, AddonUser
|
||||
from amo.helpers import locale_url
|
||||
from amo.urlresolvers import reverse
|
||||
from amo.helpers import locale_url, urlparams
|
||||
from amo.pyquery_wrapper import PyQuery
|
||||
from amo.tests import check_links
|
||||
from amo.urlresolvers import reverse
|
||||
from stats.models import SubscriptionEvent, Contribution
|
||||
from users.models import UserProfile
|
||||
|
||||
|
@ -566,6 +567,17 @@ class TestOtherStuff(amo.tests.TestCase):
|
|||
eq_(doc('#site-nav #more .more-lang a').attr('href'),
|
||||
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):
|
||||
doc = pq(test.Client().get('/firefox', follow=True).content)
|
||||
eq_(doc('#site-nav #more .more-mobile a').attr('href'),
|
||||
|
|
Загрузка…
Ссылка в новой задаче