From 58a63c49c49bfdde9ad1d5db5157662ca60c2c8e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 3 Jan 2014 14:42:15 +0000 Subject: [PATCH] Fixed that magic links to existing attachments are not converted when previewing issue notes. git-svn-id: http://svn.redmine.org/redmine/trunk@12476 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 3 ++- test/functional/previews_controller_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fac002565..bb7208e36 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -847,7 +847,8 @@ module ApplicationHelper repo_prefix = nil end when 'attachment' - attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil) + attachments = options[:attachments] || [] + attachments += obj.attachments if obj.respond_to?(:attachments) if attachments && attachment = Attachment.latest_attach(attachments, name) link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment') end diff --git a/test/functional/previews_controller_test.rb b/test/functional/previews_controller_test.rb index f99ccb401..490e62320 100644 --- a/test/functional/previews_controller_test.rb +++ b/test/functional/previews_controller_test.rb @@ -54,6 +54,14 @@ class PreviewsControllerTest < ActionController::TestCase assert_tag :p, :content => 'Foo' end + def test_preview_issue_notes_should_support_links_to_existing_attachments + Attachment.generate!(:container => Issue.find(1), :filename => 'foo.bar') + @request.session[:user_id] = 2 + post :issue, :project_id => '1', :id => 1, :notes => 'attachment:foo.bar' + assert_response :success + assert_select 'a.attachment', :text => 'foo.bar' + end + def test_preview_new_news get :news, :project_id => 1, :news => {:title => '', -- 2.39.5