diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-12 13:03:12 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-07-12 13:03:12 +0000 |
commit | d3d1e9ef65b165b1807a08880a334ce8906cd9e1 (patch) | |
tree | 1ce15c2ba0ff749db7036a682713f9090714bc19 /spec | |
parent | f94587eccbeda3bd0092588a12ddf9a586b29dce (diff) | |
parent | ed97b057f61e219c252a18e3421b158c905ec317 (diff) | |
download | gitlab-ce-d3d1e9ef65b165b1807a08880a334ce8906cd9e1.tar.gz |
Merge branch 'search-git-grep' into 'master'
Implement faster search of code (via git grep)
Much faster than iterating over each file using rugged.
Performance compare for Linux repository using keyword `sha`:
```
OLD: 250 seconds
NEW: 9 seconds
```
See merge request !957
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index a083dcb1274..d25351b0f0e 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -47,4 +47,28 @@ describe Repository do it { is_expected.to be_falsey } end end + + describe "search_files" do + let(:results) { repository.search_files('feature', 'master') } + subject { results } + + it { is_expected.to be_an Array } + + describe 'result' do + subject { results.first } + + it { is_expected.to be_an String } + it { expect(subject.lines[2]).to eq("master:CHANGELOG:188: - Feature: Replace teams with group membership\n") } + end + + describe 'parsing result' do + subject { repository.parse_search_result(results.first) } + + it { is_expected.to be_an OpenStruct } + it { expect(subject.filename).to eq('CHANGELOG') } + it { expect(subject.ref).to eq('master') } + it { expect(subject.startline).to eq(186) } + it { expect(subject.data.lines[2]).to eq(" - Feature: Replace teams with group membership\n") } + end + end end |