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)
975 975
              attachments = options[:attachments] || []
976 976
              attachments += obj.attachments if obj.respond_to?(:attachments)
977 977
              if attachments && attachment = Attachment.latest_attach(attachments, name)
978
                link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment')
978
                link = link_to_attachment(attachment, :only_path => only_path, :class => 'attachment')
979 979
              end
980 980
            when 'project'
981 981
              if p = Project.visible.where("identifier = :s OR LOWER(name) = :s", :s => name.downcase).first
test/unit/helpers/application_helper_test.rb (working copy)
667 667

  
668 668
  def test_attachment_links
669 669
    text = 'attachment:error281.txt'
670
    result = link_to("error281.txt", "/attachments/download/1/error281.txt",
670
    result = link_to("error281.txt", "/attachments/1/error281.txt",
671 671
                     :class => "attachment")
672 672
    assert_equal "<p>#{result}</p>",
673 673
                 textilizable(text,
......
679 679
    set_tmp_attachments_directory
680 680
    a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago)
681 681
    a2 = Attachment.generate!(:filename => "test.txt")
682
    result = link_to("test.txt", "/attachments/download/#{a2.id}/test.txt",
682
    result = link_to("test.txt", "/attachments/#{a2.id}/test.txt",
683 683
                     :class => "attachment")
684 684
    assert_equal "<p>#{result}</p>",
685 685
                 textilizable('attachment:test.txt', :attachments => [a1, a2])
(2-2/2)