diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2016-03-09 07:50:34 +0300 |
---|---|---|
committer | Hiroyuki Sato <sathiroyuki@gmail.com> | 2016-03-17 02:58:52 +0300 |
commit | f0b052e16868107e1693e9b3454039420bee1dde (patch) | |
tree | 2fb9af9740f5afa6b7a649b33ba05990f74372a0 /spec | |
parent | 374037b8a326b82a7787b2e29da820aa9c4390b3 (diff) |
Fix wiki search results point to raw source
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 34866be3395..fc2ab2d9931 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -101,13 +101,29 @@ describe Repository, models: true do end describe 'parsing result' do - subject { repository.parse_search_result(results.first) } + subject { repository.parse_search_result(search_result) } + let(:search_result) { results.first } it { is_expected.to be_an OpenStruct } it { expect(subject.filename).to eq('CHANGELOG') } + it { expect(subject.basename).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") } + + context "when filename has extension" do + let(:search_result) { "master:CONTRIBUTE.md:5:- [Contribute to GitLab](#contribute-to-gitlab)\n" } + + it { expect(subject.filename).to eq('CONTRIBUTE.md') } + it { expect(subject.basename).to eq('CONTRIBUTE') } + end + + context "when file under directory" do + let(:search_result) { "master:a/b/c.md:5:a b c\n" } + + it { expect(subject.filename).to eq('a/b/c.md') } + it { expect(subject.basename).to eq('a/b/c') } + end end end |