]> source.dussan.org Git - redmine.git/commitdiff
Wiki notation `attachment:file_name` cannot make a link to a file attached to other...
authorGo MAEDA <maeda@farend.jp>
Thu, 26 May 2022 15:36:46 +0000 (15:36 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 26 May 2022 15:36:46 +0000 (15:36 +0000)
Patch by Mizuki ISHIKAWA.

git-svn-id: https://svn.redmine.org/redmine/trunk@21605 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/functional/issues_controller_test.rb

index 031273d445cb9227cca0078654de922372772763..4f2debeb7833606a38616d0ea727f20e42430bbf 100644 (file)
@@ -1251,7 +1251,11 @@ module ApplicationHelper
               end
             when 'attachment'
               attachments = options[:attachments] || []
-              attachments += obj.attachments if obj.respond_to?(:attachments)
+              if obj.is_a?(Journal)
+                attachments += obj.journalized.attachments if obj.journalized.respond_to?(:attachments)
+              else
+                attachments += obj.attachments if obj.respond_to?(:attachments)
+              end
               if attachments && attachment = Attachment.latest_attach(attachments, name)
                 link = link_to_attachment(attachment, :only_path => only_path, :class => 'attachment')
               end
index 9b1842e0d5c8e57f5a3fca5d42698e441d68b440..60d1ff638283114e8ac788a4fc8f2b210835bd40 100644 (file)
@@ -8386,6 +8386,21 @@ class IssuesControllerTest < Redmine::ControllerTest
     end
   end
 
+  def test_show_should_be_able_to_link_to_another_journal_attachment_of_the_same_issue
+    @request.session[:user_id] = 1
+    issue = Issue.find(2)
+    attachment = issue.journals.first.attachments.first
+
+    issue.init_journal(User.first, "attachment:#{attachment.filename}")
+    issue.save!
+    issue.reload
+
+    get :show, params: { id: issue.id }
+    assert_select "div#history div#journal-#{issue.journals.last.id}-notes" do
+      assert_select "a[href='/attachments/#{attachment.id}']", :text => 'source.rb'
+    end
+  end
+
   def test_index_should_retrieve_default_query
     query = IssueQuery.find(4)
     IssueQuery.stubs(:default).returns query