Skip to content
Browse files

Account for mw.script_name.

  • Loading branch information...
1 parent 1feb5ef commit 60406cfefa46bf4f74105106874047e1bf9f4862 @ralphbean ralphbean committed May 21, 2012
Showing with 11 additions and 2 deletions.
  1. +9 −1 tests/test_jquery.py
  2. +2 −1 tw2/jquery/version.py
View
10 tests/test_jquery.py
@@ -18,7 +18,7 @@ def request_local_tst():
_request_local = {}
_request_id = 'whatever'
-def setup():
+def setUp():
twc.core.request_local = request_local_tst
twc.core.request_local()['middleware'] = twc.make_middleware()
@@ -32,6 +32,14 @@ def test_jquery_js_function():
from tw2.jquery import jQuery
eq_(str(jQuery('foo')), 'jQuery("foo")')
+def test_jquery_script_name():
+ twc.core.request_local()['middleware'] = \
+ twc.make_middleware(script_name='/lol')
+ from tw2.jquery import jquery_js
+ twc.core.request_local()['middleware'].script_name = '/lol'
+ the_link = '/lol/resources/tw2.jquery/static/jquery/1.7.1/jquery.js'
+ eq_(jquery_js.req().link, the_link)
+
def test_jquery_external():
from tw2.jquery import jquery_js
jquery_js.external = True
View
3 tw2/jquery/version.py
@@ -75,12 +75,13 @@ def _get_link(self):
link = self.external_link
else:
link = ('/' + '/'.join((
+ mw.config.script_name.strip('/'),
mw.config.res_prefix.strip('/'),
self.modname,
'static',
self.dirname,
self.core_filename
- )))
+ ))).replace('//', '/')
self._link = link
return self._link % self.substitutions

0 comments on commit 60406cf

Please sign in to comment.
Something went wrong with that request. Please try again.