Exclude vendor JS in mozmarket when necessary

This commit is contained in:
Kumar McMillan 2012-06-22 17:57:43 -05:00
Родитель fad2e86bbc
Коммит 662523f077
4 изменённых файлов: 21 добавлений и 4 удалений

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

@ -1455,3 +1455,8 @@ IN_TEST_SUITE = False
# Until bug 753421 gets fixed, we're skipping ES tests. Sad times. I know. # Until bug 753421 gets fixed, we're skipping ES tests. Sad times. I know.
# Flip this on in your local settings to experience the joy of ES tests. # Flip this on in your local settings to experience the joy of ES tests.
RUN_ES_TESTS = False RUN_ES_TESTS = False
# All JS vendor libraries in this list will be excluded from mozmarket.js.
# For example, if receiptverifier is broken and you need to disable it, add
# 'receiptverifier' to the list. See also mkt/site/views.py.
MOZMARKET_VENDOR_EXCLUDE = ['receiptverifier']

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

@ -83,6 +83,12 @@ class TestMozmarketJS(amo.tests.TestCase):
resp = self.render() resp = self.render()
self.assertContains(resp, 'exports.receipts.Verifier') self.assertContains(resp, 'exports.receipts.Verifier')
@mock.patch.object(settings, 'MOZMARKET_VENDOR_EXCLUDE',
['receiptverifier'])
def test_exclude(self):
resp = self.render()
self.assertNotContains(resp, 'exports.receipts.Verifier')
class TestRobots(amo.tests.TestCase): class TestRobots(amo.tests.TestCase):

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

@ -94,9 +94,13 @@ def record(request):
@cache_page(60 * 60) @cache_page(60 * 60)
@no_login_required @no_login_required
def mozmarket_js(request): def mozmarket_js(request):
with open(os.path.join(settings.ROOT, 'vendor', 'js', vendor_js = []
'receiptverifier', for lib, path in (('receiptverifier',
'receiptverifier.js'), 'r') as fp: 'receiptverifier/receiptverifier.js'),):
vendor_js = [('receiptverifier', fp.read())] if lib in settings.MOZMARKET_VENDOR_EXCLUDE:
continue
with open(os.path.join(settings.ROOT,
'vendor', 'js', path), 'r') as fp:
vendor_js.append((lib, fp.read()))
return jingo.render(request, 'site/mozmarket.js', {'vendor_js': vendor_js}, return jingo.render(request, 'site/mozmarket.js', {'vendor_js': vendor_js},
content_type='text/javascript') content_type='text/javascript')

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

@ -90,3 +90,5 @@ DEBUG_TOOLBAR_CONFIG = {
'TAG': 'div', 'TAG': 'div',
'ENABLE_STACKTRACES' : False, 'ENABLE_STACKTRACES' : False,
} }
MOZMARKET_VENDOR_EXCLUDE = []