]> source.dussan.org Git - redmine.git/commitdiff
Fix exception raised during thumbnail macro to image tag conversion in emails (#38697).
authorGo MAEDA <maeda@farend.jp>
Wed, 30 Aug 2023 07:30:16 +0000 (07:30 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 30 Aug 2023 07:30:16 +0000 (07:30 +0000)
Patch by Y saku and Mizuki ISHIKAWA.

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

lib/redmine/wiki_formatting/macros.rb
test/unit/mailer_test.rb

index a2acd07eb3b0befe1394a3474b2a9e10d88993c0..cb4976eb78b4afef66089c999c20932214f0e08b 100644 (file)
@@ -281,7 +281,7 @@ module Redmine
 
         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?
+        if (controller_path == 'previews' || action_name == 'preview') && @attachments.present?
           attachments = (attachments.to_a + @attachments).compact
         end
         if attachments.present? && (attachment = Attachment.latest_attach(attachments, filename))
index ee029d3e60558c7202f38feea8395e51e88dfbd3..889035a27d2626791ef457aa2a61513c0034f70a 100644 (file)
@@ -199,6 +199,18 @@ class MailerTest < ActiveSupport::TestCase
     end
   end
 
+  def test_thumbnail_macro_in_email
+    set_tmp_attachments_directory
+    issue = Issue.generate!(:description => '{{thumbnail(image.png)}}')
+    issue.attachments << Attachment.new(:file => mock_file_with_options(:original_filename => 'image.png'), :author => User.find(1))
+    issue.save!
+
+    assert Mailer.deliver_issue_add(issue)
+    assert_select_email do
+      assert_select 'img[alt="image.png"]'
+    end
+  end
+
   def test_email_headers
     with_settings :mail_from => 'Redmine <redmine@example.net>' do
       issue = Issue.find(1)