From 99ee822857cf3fdf0a2ac91c0d13ea68c79e8ba8 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 30 Mar 2016 10:56:25 +0200 Subject: [PATCH] Add method that returns markdown in file uploader --- app/uploaders/file_uploader.rb | 4 ++++ lib/gitlab/gfm/reference_rewriter.rb | 2 +- lib/gitlab/gfm/uploads_rewriter.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 25d879ff449..730153a4740 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -32,6 +32,10 @@ class FileUploader < CarrierWave::Uploader::Base File.join("/uploads", @secret, file.filename) end + def to_markdown + to_h[:markdown] + end + def to_h filename = image? ? self.file.basename : self.file.filename escaped_filename = filename.gsub("]", "\\]") diff --git a/lib/gitlab/gfm/reference_rewriter.rb b/lib/gitlab/gfm/reference_rewriter.rb index 47e1aa67976..78d7a4f27cf 100644 --- a/lib/gitlab/gfm/reference_rewriter.rb +++ b/lib/gitlab/gfm/reference_rewriter.rb @@ -46,7 +46,7 @@ module Gitlab end def needs_rewrite? - !(@text =~ @pattern).nil? + @text =~ @pattern end private diff --git a/lib/gitlab/gfm/uploads_rewriter.rb b/lib/gitlab/gfm/uploads_rewriter.rb index bdf054a6192..2e61f799a03 100644 --- a/lib/gitlab/gfm/uploads_rewriter.rb +++ b/lib/gitlab/gfm/uploads_rewriter.rb @@ -23,7 +23,7 @@ module Gitlab return markdown unless file.try(:exists?) new_uploader.store!(file) - new_uploader.to_h[:markdown] + new_uploader.to_markdown end end