Skip to content

Commit

Permalink
Merge branch '1228-dictize-whitespace'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Oct 7, 2013
2 parents eddd661 + 50f0d98 commit 59504d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -204,6 +204,9 @@ def package_dictize(pkg, context):
if not result:
raise logic.NotFound
result_dict = d.table_dictize(result, context)
#strip whitespace from title
if result_dict.get('title'):
result_dict['title'] = result_dict['title'].strip()
#resources
res_rev = model.resource_revision_table
resource_group = model.resource_group_table
Expand Down
18 changes: 18 additions & 0 deletions ckan/tests/lib/test_dictization.py
Expand Up @@ -1216,3 +1216,21 @@ def test_25_user_dictize_as_anonymous(self):

# Passwords should never be available
assert 'password' not in user_dict

def test_26_package_dictize_whitespace_strippped_from_title(self):

context = {"model": model,
"session": model.Session}

pkg = model.Session.query(model.Package).first()
original_title = pkg.title
pkg.title = " whitespace title \t"
model.Session.add(pkg)
model.Session.commit()

result = package_dictize(pkg, context)
assert result['title'] == 'whitespace title'
pkg.title = original_title
model.Session.add(pkg)
model.Session.commit()

0 comments on commit 59504d7

Please sign in to comment.