summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-09-18 14:03:42 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-09-18 14:03:42 -0400
commit619f04c196731b2a274802dfb4b4d3c3664e5465 (patch)
treef085bf8850272b0b06a39e25cefc48fb3139adc0 /spec/lib
parentbdfe6b9603a7a6947644929c4ea966018f98c840 (diff)
downloadgitlab-ce-619f04c196731b2a274802dfb4b4d3c3664e5465.tar.gz
Allow relative links to go up one directory level
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/markdown/relative_link_filter_spec.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/lib/gitlab/markdown/relative_link_filter_spec.rb b/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
index 7f4d67e403f..ab9c2008ea7 100644
--- a/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
@@ -4,14 +4,16 @@ require 'spec_helper'
module Gitlab::Markdown
describe RelativeLinkFilter do
- def filter(doc)
- described_class.call(doc, {
+ def filter(doc, contexts = {})
+ contexts.reverse_merge!({
commit: project.commit,
project: project,
project_wiki: project_wiki,
ref: ref,
requested_path: requested_path
})
+
+ described_class.call(doc, contexts)
end
def image(path)
@@ -75,6 +77,14 @@ module Gitlab::Markdown
to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end
+ it 'rebuilds relative URL for a file in the repo up one directory' do
+ relative_link = link('../api/README.md')
+ doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md')
+
+ expect(doc.at_css('a')['href']).
+ to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
+ end
+
it 'rebuilds relative URL for a file in the repo with an anchor' do
doc = filter(link('README.md#section'))
expect(doc.at_css('a')['href']).
@@ -108,8 +118,8 @@ module Gitlab::Markdown
escaped = Addressable::URI.escape(path)
# Stub these methods so the file doesn't actually need to be in the repo
- allow_any_instance_of(described_class).to receive(:file_exists?).
- and_return(true)
+ allow_any_instance_of(described_class).
+ to receive(:file_exists?).and_return(true)
allow_any_instance_of(described_class).
to receive(:image?).with(path).and_return(true)