summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <gabriel@gitlab.com>2016-04-01 05:22:22 -0300
committerGabriel Mazetto <gabriel@gitlab.com>2016-04-06 03:13:46 -0300
commit22055e10580ae93c2cb87956eefba0a06e9b50d0 (patch)
tree49691215a4fd7c001368f34277f0885ddb2915fa
parent61fe0a23977749b0a5dba41ca26101b4a03de720 (diff)
downloadgitlab-ce-22055e10580ae93c2cb87956eefba0a06e9b50d0.tar.gz
Fix a few edited references from WikiLinkFilter and specs
-rw-r--r--lib/banzai/filter/wiki_link_filter.rb8
-rw-r--r--spec/features/markdown_spec.rb1
-rw-r--r--spec/support/matchers/markdown_matchers.rb9
3 files changed, 12 insertions, 6 deletions
diff --git a/lib/banzai/filter/wiki_link_filter.rb b/lib/banzai/filter/wiki_link_filter.rb
index 7a585eff653..06d10c98501 100644
--- a/lib/banzai/filter/wiki_link_filter.rb
+++ b/lib/banzai/filter/wiki_link_filter.rb
@@ -25,10 +25,10 @@ module Banzai
end
def process_link_attr(html_attr)
- return if html_attr.blank?
+ return if html_attr.blank? || file_reference?(html_attr)
uri = URI(html_attr.value)
- if uri.relative? && uri.path.present? && uri.path
+ if uri.relative? && uri.path.present?
html_attr.value = rebuild_wiki_uri(uri).to_s
end
rescue URI::Error
@@ -40,6 +40,10 @@ module Banzai
uri
end
+ def file_reference?(html_attr)
+ !File.extname(html_attr.value).blank?
+ end
+
def project_wiki
context[:project_wiki]
end
diff --git a/spec/features/markdown_spec.rb b/spec/features/markdown_spec.rb
index 12fd8d37210..5149ce9cf2f 100644
--- a/spec/features/markdown_spec.rb
+++ b/spec/features/markdown_spec.rb
@@ -230,6 +230,7 @@ describe 'GitLab Markdown', feature: true do
file = Gollum::File.new(@project_wiki.wiki)
expect(file).to receive(:path).and_return('images/example.jpg')
expect(@project_wiki).to receive(:find_file).with('images/example.jpg').and_return(file)
+ allow(@project_wiki).to receive(:wiki_base_path) { '/namespace1/gitlabhq/wikis' }
@html = markdown(@feat.raw_markdown, { pipeline: :wiki, project_wiki: @project_wiki })
end
diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb
index 1d52489e804..43cb6ef43f2 100644
--- a/spec/support/matchers/markdown_matchers.rb
+++ b/spec/support/matchers/markdown_matchers.rb
@@ -13,7 +13,7 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- link = actual.at_css('a:contains("Relative Link")')
+ link = actual.at_css('a:contains("Relative Link")')
image = actual.at_css('img[alt="Relative Image"]')
expect(link['href']).to end_with('master/doc/README.md')
@@ -72,14 +72,15 @@ module MarkdownMatchers
have_css("img[src$='#{src}']")
end
+ prefix = '/namespace1/gitlabhq/wikis'
set_default_markdown_messages
match do |actual|
- expect(actual).to have_link('linked-resource', href: 'linked-resource')
- expect(actual).to have_link('link-text', href: 'linked-resource')
+ expect(actual).to have_link('linked-resource', href: "#{prefix}/linked-resource")
+ expect(actual).to have_link('link-text', href: "#{prefix}/linked-resource")
expect(actual).to have_link('http://example.com', href: 'http://example.com')
expect(actual).to have_link('link-text', href: 'http://example.com/pdfs/gollum.pdf')
- expect(actual).to have_image('/gitlabhq/wikis/images/example.jpg')
+ expect(actual).to have_image("#{prefix}/images/example.jpg")
expect(actual).to have_image('http://example.com/images/example.jpg')
end
end