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

Return an empty array when no matches are found

parent 167fd713
......@@ -6,7 +6,7 @@ module GroupDescendant
def self.build_hierarchy(descendants, hierarchy_top = nil)
descendants = Array.wrap(descendants)
return if descendants.empty?
return [] if descendants.empty?
unless descendants.all? { |hierarchy| hierarchy.is_a?(GroupDescendant) }
raise ArgumentError.new('element is not a hierarchy')
......
......@@ -331,6 +331,16 @@ describe GroupsController do
expect(response).to have_http_status(200)
end
it 'returns an empty array when there are no search results' do
subgroup = create(:group, :public, parent: group)
l2_subgroup = create(:group, :public, parent: subgroup)
create(:project, :public, namespace: l2_subgroup, name: 'no-match')
get :children, id: subgroup.to_param, filter: 'test', format: :json
expect(json_response).to eq([])
end
it 'includes pagination headers' do
2.times { |i| create(:group, :public, parent: public_subgroup, name: "filterme#{i}") }
......
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