2019-11-07 22:06:48 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-12 03:16:33 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Gitlab::FileFinder do
|
2017-05-12 03:16:33 -04:00
|
|
|
describe '#find' do
|
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2018-06-06 20:14:10 -04:00
|
|
|
subject { described_class.new(project, project.default_branch) }
|
2017-05-12 03:16:33 -04:00
|
|
|
|
2018-06-04 07:41:37 -04:00
|
|
|
it_behaves_like 'file finder' do
|
2019-10-23 20:07:18 -04:00
|
|
|
let(:expected_file_by_path) { 'files/images/wm.svg' }
|
2018-06-04 07:41:37 -04:00
|
|
|
let(:expected_file_by_content) { 'CHANGELOG' }
|
2017-05-12 03:16:33 -04:00
|
|
|
end
|
2018-06-06 20:14:10 -04:00
|
|
|
|
2019-10-23 20:07:18 -04:00
|
|
|
it 'filters by filename' do
|
2018-06-06 20:14:10 -04:00
|
|
|
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:svg')
|
|
|
|
|
|
|
|
expect(results.count).to eq(1)
|
|
|
|
end
|
2017-05-12 03:16:33 -04:00
|
|
|
end
|
|
|
|
end
|