Project

General

Profile

Defect #26310 » fix-attachment-link-destination.diff

patch - Go MAEDA, 2017-07-02 08:01

View differences:

app/helpers/application_helper.rb (working copy)
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')
link = link_to_attachment(attachment, :only_path => only_path, :class => 'attachment')
end
when 'project'
if p = Project.visible.where("identifier = :s OR LOWER(name) = :s", :s => name.downcase).first
test/unit/helpers/application_helper_test.rb (working copy)
def test_attachment_links
text = 'attachment:error281.txt'
result = link_to("error281.txt", "/attachments/download/1/error281.txt",
result = link_to("error281.txt", "/attachments/1/error281.txt",
:class => "attachment")
assert_equal "<p>#{result}</p>",
textilizable(text,
......
set_tmp_attachments_directory
a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago)
a2 = Attachment.generate!(:filename => "test.txt")
result = link_to("test.txt", "/attachments/download/#{a2.id}/test.txt",
result = link_to("test.txt", "/attachments/#{a2.id}/test.txt",
:class => "attachment")
assert_equal "<p>#{result}</p>",
textilizable('attachment:test.txt', :attachments => [a1, a2])
(2-2/2)