Commit b4bf3cd6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add tests for nested groups in search service and search helper

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent d6febcaf
......@@ -41,6 +41,11 @@ describe SearchHelper do
expect(search_autocomplete_opts("gro").size).to eq(1)
end
it "includes nested group" do
create(:group, :nested, name: 'foo').add_owner(user)
expect(search_autocomplete_opts('foo').size).to eq(1)
end
it "includes the user's projects" do
project = create(:empty_project, namespace: create(:namespace, owner: user))
expect(search_autocomplete_opts(project.name).size).to eq(1)
......
......@@ -41,6 +41,25 @@ describe 'Search::GlobalService', services: true do
results = context.execute
expect(results.objects('projects')).to match_array [found_project]
end
context 'nested group' do
let!(:nested_group) { create(:group, :nested) }
let!(:project) { create(:project, namespace: nested_group) }
before { project.add_master(user) }
it 'returns result from nested group' do
context = Search::GlobalService.new(user, search: project.path)
results = context.execute
expect(results.objects('projects')).to match_array [project]
end
it 'returns result from descendants when search inside group' do
context = Search::GlobalService.new(user, search: project.path, group_id: nested_group.parent)
results = context.execute
expect(results.objects('projects')).to match_array [project]
end
end
end
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