Skip to content

Commit

Permalink
[#1038] Fix display of tree hierarchy, broken in reversal af6c039.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Sep 12, 2013
1 parent 34b3fb7 commit 527f3e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ckan/model/group.py
Expand Up @@ -404,7 +404,7 @@ def __repr__(self):
WHERE m.table_id = c.group_id AND m.table_name = 'group'
AND m.state = 'active'
)
SELECT G.*, child.group_id as parent_id FROM child
SELECT G.*, child.table_id as parent_id FROM child
INNER JOIN public.group G ON G.id = child.group_id
WHERE G.type = :type AND G.state='active';"""

Expand Down
9 changes: 9 additions & 0 deletions ckan/tests/models/test_group.py
Expand Up @@ -116,6 +116,15 @@ def test_get_children_groups(self):
assert_in(res[0]['name'], ('national-health-service', 'food-standards-agency'))
assert_in(res[0]['title'], ('National Health Service', 'Food Standards Agency'))

def test_get_children_group_hierarchy__from_top_2(self):
groups = model.Group.by_name(u'department-of-health').\
get_children_group_hierarchy(type=group_type)
# the first group must be NHS or Food Standards Agency - i.e. on the
# first level down
nhs = groups[0]
assert_in(nhs[0].name, ('national-health-service', 'food-standards-agency'))
assert_equal(model.Group.get(nhs[1]).name, 'department-of-health')

def test_get_children_group_hierarchy__from_top(self):
assert_equal(name_set_from_group_tuple(model.Group.by_name(u'department-of-health').\
get_children_group_hierarchy(type=group_type)),
Expand Down

0 comments on commit 527f3e9

Please sign in to comment.