diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-11 12:09:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-11 12:09:06 +0000 |
commit | 9517d0eb2ca8bde02d7fae2173e0a43b67b2b9f5 (patch) | |
tree | c3807f1807384fda69b8a42a439700f52b5dd1f0 /spec/services/search | |
parent | 3454d4cbe3d553e14006e301a4d6843484ce675f (diff) | |
download | gitlab-ce-9517d0eb2ca8bde02d7fae2173e0a43b67b2b9f5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/search')
-rw-r--r-- | spec/services/search/snippet_service_spec.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/spec/services/search/snippet_service_spec.rb b/spec/services/search/snippet_service_spec.rb index ceaf3d055bf..d204f626635 100644 --- a/spec/services/search/snippet_service_spec.rb +++ b/spec/services/search/snippet_service_spec.rb @@ -49,12 +49,24 @@ RSpec.describe Search::SnippetService do expect(results.objects('snippet_titles')).to match_array [public_snippet, internal_snippet, private_snippet, project_public_snippet, project_internal_snippet] end - it 'returns all snippets when user is admin' do - admin = create(:admin) - search = described_class.new(admin, search: 'bar') - results = search.execute + context 'when admin mode is enabled', :enable_admin_mode do + it 'returns all snippets when user is admin' do + admin = create(:admin) + search = described_class.new(admin, search: 'bar') + results = search.execute + + expect(results.objects('snippet_titles')).to match_array [public_snippet, internal_snippet, private_snippet, project_public_snippet, project_internal_snippet, project_private_snippet] + end + end + + context 'when admin mode is disabled' do + it 'returns only public & internal snippets when user is admin' do + admin = create(:admin) + search = described_class.new(admin, search: 'bar') + results = search.execute - expect(results.objects('snippet_titles')).to match_array [public_snippet, internal_snippet, private_snippet, project_public_snippet, project_internal_snippet, project_private_snippet] + expect(results.objects('snippet_titles')).to match_array [public_snippet, internal_snippet, project_public_snippet, project_internal_snippet] + end end end end |