mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 19:47:14 +00:00
Thumbnail macro does not work when a file is attached and preview is displayed immediately (#37379).
Patch by Mizuki ISHIKAWA. git-svn-id: https://svn.redmine.org/redmine/trunk@21716 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
34b6581d55
commit
20ed193d93
@ -278,8 +278,12 @@ module Redmine
|
||||
|
||||
size = size.to_i
|
||||
size = 200 unless size > 0
|
||||
if obj && obj.respond_to?(:attachments) &&
|
||||
attachment = Attachment.latest_attach(obj.attachments, filename)
|
||||
|
||||
attachments = obj.attachments if obj.respond_to?(:attachments)
|
||||
if (controller_name == 'previews' || action_name == 'preview') && @attachments.present?
|
||||
attachments = (attachments.to_a + @attachments).compact
|
||||
end
|
||||
if attachments.present? && (attachment = Attachment.latest_attach(attachments, filename))
|
||||
title = options[:title] || attachment.title
|
||||
thumbnail_url =
|
||||
url_for(:controller => 'attachments', :action => 'thumbnail',
|
||||
|
||||
@ -88,6 +88,25 @@ class PreviewsControllerTest < Redmine::ControllerTest
|
||||
assert_select 'a.attachment', :text => 'foo.bar'
|
||||
end
|
||||
|
||||
def test_preview_issue_notes_should_show_thumbnail_of_file_immidiately_after_attachment
|
||||
attachment = Attachment.generate!(filename: 'foo.png', digest: Redmine::Utils.random_hex(64))
|
||||
attachment.update(container: nil)
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
post(
|
||||
:issue,
|
||||
params: {
|
||||
project_id: '1',
|
||||
issue_id: 1,
|
||||
field: 'notes',
|
||||
text: '{{thumbnail(foo.png)}}',
|
||||
attachments: {'1': { token: attachment.token }}
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
assert_select 'a.thumbnail[title=?]', 'foo.png'
|
||||
end
|
||||
|
||||
def test_preview_new_news
|
||||
get(
|
||||
:news,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user