gitlab-org--gitlab-foss/spec/lib/gitlab/file_finder_spec.rb

30 lines
918 B
Ruby
Raw Normal View History

2017-05-12 03:16:33 -04:00
require 'spec_helper'
describe Gitlab::FileFinder do
2017-05-12 03:16:33 -04:00
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')
2017-08-24 09:46:08 -04:00
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
2017-05-12 03:16:33 -04:00
end
it 'finds by content' do
results = finder.find('files')
2017-08-24 09:46:08 -04:00
filename, blob = results.find { |_, blob| blob.filename == 'CHANGELOG' }
2017-05-12 03:16:33 -04:00
2017-08-24 09:46:08 -04:00
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
2017-05-12 03:16:33 -04:00
end
end
end