debian-mirror-gitlab/spec/lib/gitlab/file_finder_spec.rb

30 lines
918 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
require 'spec_helper'
describe Gitlab::FileFinder 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')
2018-03-17 18:26:18 +05:30
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-09-10 17:25:29 +05:30
end
it 'finds by content' do
results = finder.find('files')
2018-03-17 18:26:18 +05:30
filename, blob = results.find { |_, blob| blob.filename == 'CHANGELOG' }
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
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-09-10 17:25:29 +05:30
end
end
end