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
This commit is contained in:
Jean-Philippe Lang 2014-01-03 14:42:15 +00:00
parent 4ccc7dff14
commit 58a63c49c4
2 changed files with 10 additions and 1 deletions

View File

@ -847,7 +847,8 @@ module ApplicationHelper
repo_prefix = nil repo_prefix = nil
end end
when 'attachment' 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) if attachments && attachment = Attachment.latest_attach(attachments, name)
link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment') link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment')
end end

View File

@ -54,6 +54,14 @@ class PreviewsControllerTest < ActionController::TestCase
assert_tag :p, :content => 'Foo' assert_tag :p, :content => 'Foo'
end 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 def test_preview_new_news
get :news, :project_id => 1, get :news, :project_id => 1,
:news => {:title => '', :news => {:title => '',