From 3a0a55c8ba37dda072d9d3e788713ad430ed7bb4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 20 Oct 2014 21:11:08 +0000 Subject: [PATCH] Merged r13451 (#18119). git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13463 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 2 +- lib/redmine/wiki_formatting/macros.rb | 4 ++-- .../redmine/wiki_formatting/macros_test.rb | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e9cbf6dd4..6b5dd08e0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -589,7 +589,7 @@ module ApplicationHelper end return '' if text.blank? project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil) - only_path = options.delete(:only_path) == false ? false : true + @only_path = only_path = options.delete(:only_path) == false ? false : true text = text.dup macros = catch_macros(text) diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb index d3a728963..df4f7a15f 100644 --- a/lib/redmine/wiki_formatting/macros.rb +++ b/lib/redmine/wiki_formatting/macros.rb @@ -236,8 +236,8 @@ module Redmine size = nil unless size > 0 if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename) title = options[:title] || attachment.title - thumbnail_url = url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size, :only_path => false) - image_url = url_for(:controller => 'attachments', :action => 'show', :id => attachment, :only_path => false) + thumbnail_url = url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment, :size => size, :only_path => @only_path) + image_url = url_for(:controller => 'attachments', :action => 'show', :id => attachment, :only_path => @only_path) img = image_tag(thumbnail_url, :alt => attachment.filename) link_to(img, image_url, :class => 'thumbnail', :title => title) diff --git a/test/unit/lib/redmine/wiki_formatting/macros_test.rb b/test/unit/lib/redmine/wiki_formatting/macros_test.rb index 443b6f4d8..7f5308d1b 100644 --- a/test/unit/lib/redmine/wiki_formatting/macros_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/macros_test.rb @@ -302,17 +302,26 @@ RAW end def test_macro_thumbnail + link = link_to('testfile.PNG'.html_safe, + "/attachments/17", + :class => "thumbnail", + :title => "testfile.PNG") + assert_equal "

#{link}

", + textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14)) + end + + def test_macro_thumbnail_with_full_path link = link_to('testfile.PNG'.html_safe, "http://test.host/attachments/17", :class => "thumbnail", :title => "testfile.PNG") assert_equal "

#{link}

", - textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14)) + textilizable("{{thumbnail(testfile.png)}}", :object => Issue.find(14), :only_path => false) end def test_macro_thumbnail_with_size - link = link_to('testfile.PNG'.html_safe, - "http://test.host/attachments/17", + link = link_to('testfile.PNG'.html_safe, + "/attachments/17", :class => "thumbnail", :title => "testfile.PNG") assert_equal "

#{link}

", @@ -320,8 +329,8 @@ RAW end def test_macro_thumbnail_with_title - link = link_to('testfile.PNG'.html_safe, - "http://test.host/attachments/17", + link = link_to('testfile.PNG'.html_safe, + "/attachments/17", :class => "thumbnail", :title => "Cool image") assert_equal "

#{link}

", -- 2.39.5