diff options
-rw-r--r-- | app/models/repository.rb | 2 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 8a9213f659c..6262b5c4c92 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -442,7 +442,7 @@ class Repository filename = nil startline = 0 - lines = result.lstrip.lines + lines = result.lines lines.each_with_index do |line, index| if line =~ /^.*:.*:\d+:/ ref, filename, startline = line.split(':') 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 |