diff options
author | Nick Thomas <nick@gitlab.com> | 2017-08-24 16:46:08 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-08-25 12:36:32 +0300 |
commit | fa2915ec2deaf9aa73ae18a60836a831376da943 (patch) | |
tree | 52ca1260718fe6639008f4365180342add4ec64f /spec/lib/gitlab/file_finder_spec.rb | |
parent | eae604e6de0136f2cc1c06b48fb1503408059ce8 (diff) |
Fix searching for files by path
Diffstat (limited to 'spec/lib/gitlab/file_finder_spec.rb')
-rw-r--r-- | spec/lib/gitlab/file_finder_spec.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/spec/lib/gitlab/file_finder_spec.rb b/spec/lib/gitlab/file_finder_spec.rb index 3fb6315a39a..07cb10e563e 100644 --- a/spec/lib/gitlab/file_finder_spec.rb +++ b/spec/lib/gitlab/file_finder_spec.rb @@ -7,15 +7,23 @@ describe Gitlab::FileFinder do it 'finds by name' do results = finder.find('files') - expect(results.map(&:first)).to include('files/images/wm.svg') + + filename, blob = results.find { |_, blob| blob.filename == 'files/images/wm.svg' } + expect(filename).to eq('files/images/wm.svg') + expect(blob).to be_a(Gitlab::SearchResults::FoundBlob) + expect(blob.ref).to eq(finder.ref) + expect(blob.data).not_to be_empty end it 'finds by content' do results = finder.find('files') - blob = results.select { |result| result.first == "CHANGELOG" }.flatten.last + filename, blob = results.find { |_, blob| blob.filename == 'CHANGELOG' } - expect(blob.filename).to eq("CHANGELOG") + expect(filename).to eq('CHANGELOG') + expect(blob).to be_a(Gitlab::SearchResults::FoundBlob) + expect(blob.ref).to eq(finder.ref) + expect(blob.data).not_to be_empty end end end |