]> source.dussan.org Git - redmine.git/commitdiff
Merged r22012 from trunk to 5.0-stable (#37881).
authorGo MAEDA <maeda@farend.jp>
Mon, 2 Jan 2023 05:52:39 +0000 (05:52 +0000)
committerGo MAEDA <maeda@farend.jp>
Mon, 2 Jan 2023 05:52:39 +0000 (05:52 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@22018 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting/macros.rb
test/functional/issues_controller_test.rb

index 83dc5dcc012ea057c180d9dcdac0dd700755b818..61218d93a29b64e4802769832d645bd4054c06be 100644 (file)
@@ -279,7 +279,8 @@ module Redmine
         size = size.to_i
         size = 200 unless size > 0
 
-        attachments = obj.attachments if obj.respond_to?(:attachments)
+        container = obj.is_a?(Journal) ? obj.journalized : obj
+        attachments = container.attachments if container.respond_to?(:attachments)
         if (controller_name == 'previews' || action_name == 'preview') && @attachments.present?
           attachments = (attachments.to_a + @attachments).compact
         end
index 1e0c028f6085569924a03b7ad6594f31c20d8d91..732c01956b3410a2a502e76e4c30cc3d5427092d 100644 (file)
@@ -8421,6 +8421,22 @@ class IssuesControllerTest < Redmine::ControllerTest
     end
   end
 
+  def test_show_with_thumbnail_macro_should_be_able_to_fetch_image_of_different_journal
+    @request.session[:user_id] = 1
+    issue = Issue.find(2)
+    attachment = Attachment.generate!(filename: 'foo.png', digest: Redmine::Utils.random_hex(32))
+    attachment.update(container: issue)
+
+    issue.init_journal(User.first, "{{thumbnail(#{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.thumbnail[title=?][href='/attachments/#{attachment.id}']", 'foo.png'
+    end
+  end
+
   def test_index_should_retrieve_default_query
     query = IssueQuery.find(4)
     IssueQuery.stubs(:default).returns query