提交 67815272 编写于 作者: B Bob Van Landuyt

Return an empty array when no matches are found

上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册