Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Keep mobile dashboard from crashing on nameless locale. Bug 609339.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Wenzel committed Nov 9, 2010
1 parent de2a790 commit a57f814
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/dashboard/templates/dashboard/mobile/locales.html
@@ -1,5 +1,5 @@
{% macro locale_item(locale, count=0, selected=False) %}
{{ mobile_bar(name='locale', id='loc_'+locale,
{{ mobile_bar(name='locale', id='loc_%s' % locale,
value=locale|default('unknown', True),
selected=selected, count=count, total=opinion_count,
label=locale_name(locale)) }}
Expand Down
18 changes: 18 additions & 0 deletions apps/dashboard/tests.py
Expand Up @@ -48,3 +48,21 @@ class TestOS(object):
# No error, please.
tpl = render_template('dashboard/mobile/platforms.html', ctx)
assert tpl.find('id="os_None"') >= 0

def test_locale_none(self):
"""Test that locale with no name does not crash locale helper."""

class TestLocale(object):
"""Test locale with no name."""
locale = None
count = 10

ctx = {
'defaults': {'locale': None},
'locales': (TestLocale(),),
'opinion_count': 20
}

# No error, please.
tpl = render_template('dashboard/mobile/locales.html', ctx)
assert tpl.find('id="loc_None"') >= 0

0 comments on commit a57f814

Please sign in to comment.