diff options
author | Valery Sizov <valery@gitlab.com> | 2017-05-12 10:16:33 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2017-05-12 13:21:30 +0300 |
commit | f6c4ccd1f234e1b5bab8f7ffbd98b3d1092b4873 (patch) | |
tree | cf4c5e58d875d78724ab84daa7328b6bc54ab68d /spec | |
parent | 180ec7113e358a7f8388e1436dc0670a11ba68df (diff) |
Backport FileFinder from EE
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/file_finder_spec.rb | 21 | ||||
-rw-r--r-- | spec/lib/gitlab/project_search_results_spec.rb | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/spec/lib/gitlab/file_finder_spec.rb b/spec/lib/gitlab/file_finder_spec.rb new file mode 100644 index 00000000000..5a32ffd462c --- /dev/null +++ b/spec/lib/gitlab/file_finder_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Gitlab::FileFinder, lib: true do + describe '#find' do + let(:project) { create(:project, :public, :repository) } + let(:finder) { described_class.new(project, project.default_branch) } + + it 'finds by name' do + results = finder.find('files') + expect(results.map(&:first)).to include('files/images/wm.svg') + end + + it 'finds by content' do + results = finder.find('files') + + blob = results.select { |result| result.first == "CHANGELOG" }.flatten.last + + expect(blob.filename).to eq("CHANGELOG") + end + end +end diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index 6e0b1192706..1b8690ba613 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -55,7 +55,7 @@ describe Gitlab::ProjectSearchResults, lib: true do end it 'finds by name' do - expect(results).to include(["files/images/wm.svg", nil]) + expect(results.map(&:first)).to include('files/images/wm.svg') end it 'finds by content' do |