Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix Bug 823908: Preserve locale for tabzilla redirects.

- Ensures that if a locale is used with the old tabzilla URL it will 
  keep that locale through the redirect.
- Fixes a test that assumed the en-US locale was activated (and broke
  as a result of the tabzilla test activating a different one).
  • Loading branch information...
commit 6a84f64f2e6bce0856ef92c49d422039809e3a39 1 parent 26ce6cf
@Osmose Osmose authored
View
2  apps/redirects/urls.py
@@ -55,7 +55,7 @@
redirect(r'gameon/$', 'https://gameon.mozilla.org'),
# Tabzilla
- redirect(r'tabzilla/media/js/tabzilla\.js$', '/tabzilla/tabzilla.js'),
+ redirect(r'tabzilla/media/js/tabzilla\.js$', 'tabzilla'),
redirect(r'tabzilla/media/css/tabzilla\.css$',
lambda r: '/media/css/tabzilla.less.css' if settings.TEMPLATE_DEBUG
else '/media/css/tabzilla-min.css'),
View
16 apps/tabzilla/tests.py
@@ -1,6 +1,8 @@
+from django.conf import settings
from django.test import Client
from funfactory.urlresolvers import reverse
+from mock import patch
from mozorg.tests import TestCase
@@ -14,3 +16,17 @@ def test_tabzilla_content_type(self):
with self.activate('en-US'):
resp = self.client.get(reverse('tabzilla'))
self.assertEqual(resp['content-type'], 'text/javascript')
+
+
+@patch.object(settings, 'DEV_LANGUAGES', ['en-US', 'de'])
+@patch.object(settings, 'PROD_LANGUAGES', ['en-US', 'de'])
+class TabzillaRedirectTests(TestCase):
+ def setUp(self):
+ self.client = Client()
+
+ def test_locale_preserved(self):
+ """The old tabzilla URL should preserve the locale through redirects."""
+ resp = self.client.get('/de/tabzilla/media/js/tabzilla.js')
+ self.assertEqual(resp.status_code, 301)
+ self.assertEqual(resp['Location'],
+ 'http://testserver/de/tabzilla/tabzilla.js')
View
9 lib/l10n_utils/tests/test_dotlang.py
@@ -155,11 +155,12 @@ def test_extract_message_tweaks_do_not_break(self):
# translation
# path won't exist for en-US as there isn't a dir for that
# in locale.
- result = translate(dirty_string, ['does_not_exist'])
- eq_(result, dirty_string)
+ with self.activate('en-US'):
+ result = translate(dirty_string, ['does_not_exist'])
+ eq_(result, dirty_string)
- result = translate(dirty_string, ['tweaked_message_translation'])
- eq_(result, trans_string)
+ result = translate(dirty_string, ['tweaked_message_translation'])
+ eq_(result, trans_string)
@patch('l10n_utils.dotlang.translate')
def test_new_lang_files_do_not_modify_settings(self, trans_patch):
Please sign in to comment.
Something went wrong with that request. Please try again.