Permalink
Browse files

Merge pull request #2851 from marcfor/ckan-ckan

fix ckan.root_path
  • Loading branch information...
wardi committed Jan 28, 2016
2 parents 3ac74d7 + 22bf30f commit a63de1b9d97c86fe80be30c43fcaf0fa5167e465
Showing with 10 additions and 2 deletions.
  1. +1 −2 ckan/lib/helpers.py
  2. +9 −0 ckan/tests/lib/test_helpers.py
View
@@ -13,7 +13,6 @@
import pytz
import tzlocal
import urllib
import urlparse
import pprint
import copy
import urlparse
@@ -294,7 +293,7 @@ def _add_i18n_to_url(url_to_amend, **kw):
if default_locale:
root_path = re.sub('/{{LANG}}', '', root_path)
else:
root_path = re.sub('{{LANG}}', locale, root_path)
root_path = re.sub('{{LANG}}', str(locale), root_path)
# make sure we don't have a trailing / on the root
if root_path[-1] == '/':
root_path = root_path[:-1]
@@ -1,5 +1,6 @@
import nose
import i18n
from babel import Locale
import ckan.lib.helpers as h
import ckan.exceptions
@@ -74,6 +75,14 @@ def test_url_for_with_locale(self):
locale='de')
eq_(generated_url, url)
@helpers.change_config('ckan.site_url', 'http://example.com')
@helpers.change_config('ckan.root_path', '/foo/{{LANG}}')
def test_url_for_with_locale_object(self):
url = '/foo/de/dataset/my_dataset'
generated_url = h.url_for('/dataset/my_dataset',
locale=Locale('de'))
eq_(generated_url, url)
@helpers.change_config('ckan.site_url', 'http://example.com')
def test_url_for_not_qualified(self):
url = '/dataset/my_dataset'

0 comments on commit a63de1b

Please sign in to comment.