Skip to content

Commit

Permalink
Bug 826866: Update tabzilla css redirect to use MEDIA_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
pmac committed Jan 5, 2013
1 parent 16b4e0c commit 92a7cd5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
9 changes: 6 additions & 3 deletions apps/redirects/urls.py
Expand Up @@ -8,6 +8,11 @@
from util import redirect


def tabzilla_css_redirect(r):
ext = '.less' if settings.TEMPLATE_DEBUG else '-min'
return '%scss/tabzilla%s.css' % (settings.MEDIA_URL, ext)


urlpatterns = patterns('',

redirect(r'^b2g', 'firefoxos.firefoxos'),
Expand Down Expand Up @@ -56,7 +61,5 @@

# Tabzilla
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'),
redirect(r'tabzilla/media/css/tabzilla\.css$', tabzilla_css_redirect),
)
21 changes: 21 additions & 0 deletions apps/tabzilla/tests.py
Expand Up @@ -3,6 +3,7 @@

from funfactory.urlresolvers import reverse
from mock import patch
from nose.tools import eq_

from mozorg.tests import TestCase

Expand Down Expand Up @@ -30,3 +31,23 @@ def test_locale_preserved(self):
self.assertEqual(resp.status_code, 301)
self.assertEqual(resp['Location'],
'http://testserver/de/tabzilla/tabzilla.js')

@patch.object(settings, 'MEDIA_URL', '//example.com/')
@patch.object(settings, 'TEMPLATE_DEBUG', False)
def test_tabzilla_css_redirect(self):
"""
Tabzilla css redirect should use MEDIA_URL setting and switch
based on TEMPLATE_DEBUG setting.
Bug 826866.
"""
tabzilla_css_url = '/en-US/tabzilla/media/css/tabzilla.css'
with self.activate('en-US'):
response = self.client.get(tabzilla_css_url)
eq_(response.status_code, 301)
eq_(response['Location'], 'http://example.com/css/tabzilla-min.css')

with patch.object(settings, 'TEMPLATE_DEBUG', True):
with self.activate('en-US'):
response = self.client.get(tabzilla_css_url)
eq_(response.status_code, 301)
eq_(response['Location'], 'http://example.com/css/tabzilla.less.css')

0 comments on commit 92a7cd5

Please sign in to comment.