Add tests for nested groups in search service and search helper
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
d6febcaf3e
commit
b4bf3cd69b
2 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue