Commit ec8a7a36 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Make sure all ancestors are loaded when searching groups

parent dda023d6
......@@ -2,7 +2,7 @@ module GroupTree
def render_group_tree(groups)
if params[:filter].present?
@groups = Gitlab::GroupHierarchy.new(groups).all_groups
@groups = @groups.search(params[:filter])
@groups = Gitlab::GroupHierarchy.new(@groups.search(params[:filter])).base_and_ancestors
else
# Only show root groups if no parent-id is given
@groups = groups.where(parent_id: params[:parent_id])
......
......@@ -45,12 +45,12 @@ describe GroupTree do
expect(assigns(:groups)).to contain_exactly(subgroup)
end
it 'allows filtering for subgroups' do
it 'allows filtering for subgroups and includes the parents for rendering' do
subgroup = create(:group, :public, parent: group, name: 'filter')
get :index, filter: 'filt', format: :json
expect(assigns(:groups)).to contain_exactly(subgroup)
expect(assigns(:groups)).to contain_exactly(group, subgroup)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment