diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-02 21:12:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-02 21:12:20 +0300 |
commit | 3c4d101de003ea292be5ac5baf5d73c6c2747367 (patch) | |
tree | 5918d12b69c4bfd84f05a585d62174586a80fd18 /spec/lib/gitlab/file_finder_spec.rb | |
parent | b2c21b99c7eb52b5fd906b1e7b4b08d4eb7a296c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/file_finder_spec.rb')
-rw-r--r-- | spec/lib/gitlab/file_finder_spec.rb | 126 |
1 files changed, 30 insertions, 96 deletions
diff --git a/spec/lib/gitlab/file_finder_spec.rb b/spec/lib/gitlab/file_finder_spec.rb index 27750f10e87..8afaec3c381 100644 --- a/spec/lib/gitlab/file_finder_spec.rb +++ b/spec/lib/gitlab/file_finder_spec.rb @@ -13,124 +13,58 @@ RSpec.describe Gitlab::FileFinder, feature_category: :global_search do let(:expected_file_by_content) { 'CHANGELOG' } end - context 'when code_basic_search_files_by_regexp is enabled' do - before do - stub_feature_flags(code_basic_search_files_by_regexp: true) - end - - context 'with inclusive filters' do - it 'filters by filename' do - results = subject.find('files filename:wm.svg') - - expect(results.count).to eq(1) - end - - it 'filters by path' do - results = subject.find('white path:images') - - expect(results.count).to eq(2) - end - - it 'filters by extension' do - results = subject.find('files extension:md') - - expect(results.count).to eq(4) - end - end - - context 'with exclusive filters' do - it 'filters by filename' do - results = subject.find('files -filename:wm.svg') - - expect(results.count).to eq(26) - end - - it 'filters by path' do - results = subject.find('white -path:images') - - expect(results.count).to eq(5) - end - - it 'filters by extension' do - results = subject.find('files -extension:md') + context 'with inclusive filters' do + it 'filters by filename' do + results = subject.find('files filename:wm.svg') - expect(results.count).to eq(23) - end + expect(results.count).to eq(1) end - context 'with white space in the path' do - it 'filters by path correctly' do - results = subject.find('directory path:"with space/README.md"') + it 'filters by path' do + results = subject.find('white path:images') - expect(results.count).to eq(1) - end + expect(results.count).to eq(2) end - it 'does not cause N+1 query' do - expect(Gitlab::GitalyClient).to receive(:call).at_most(10).times.and_call_original + it 'filters by extension' do + results = subject.find('files extension:md') - subject.find(': filename:wm.svg') + expect(results.count).to eq(4) end end - context 'when code_basic_search_files_by_regexp is disabled' do - before do - stub_feature_flags(code_basic_search_files_by_regexp: false) - end - - context 'with inclusive filters' do - it 'filters by filename' do - results = subject.find('files filename:wm.svg') - - expect(results.count).to eq(1) - end - - it 'filters by path' do - results = subject.find('white path:images') - - expect(results.count).to eq(1) - end - - it 'filters by extension' do - results = subject.find('files extension:md') + context 'with exclusive filters' do + it 'filters by filename' do + results = subject.find('files -filename:wm.svg') - expect(results.count).to eq(4) - end + expect(results.count).to eq(26) end - context 'with exclusive filters' do - it 'filters by filename' do - results = subject.find('files -filename:wm.svg') + it 'filters by path' do + results = subject.find('white -path:images') - expect(results.count).to eq(26) - end - - it 'filters by path' do - results = subject.find('white -path:images') - - expect(results.count).to eq(4) - end + expect(results.count).to eq(5) + end - it 'filters by extension' do - results = subject.find('files -extension:md') + it 'filters by extension' do + results = subject.find('files -extension:md') - expect(results.count).to eq(23) - end + expect(results.count).to eq(23) end + end - context 'with white space in the path' do - it 'filters by path correctly' do - results = subject.find('directory path:"with space/README.md"') + context 'with white space in the path' do + it 'filters by path correctly' do + results = subject.find('directory path:"with space/README.md"') - expect(results.count).to eq(1) - end + expect(results.count).to eq(1) end + end - it 'does not cause N+1 query' do - expect(Gitlab::GitalyClient).to receive(:call).at_most(10).times.and_call_original + it 'does not cause N+1 query' do + expect(Gitlab::GitalyClient).to receive(:call).at_most(10).times.and_call_original - subject.find(': filename:wm.svg') - end + subject.find(': filename:wm.svg') end end end |