diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index c4c9e0c16..064f207b3 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -56,13 +56,13 @@ class AttachmentsController < ApplicationController User.current.preference.save end render :action => 'diff' - elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte - @content = File.read(@attachment.diskfile, :mode => "rb") - render :action => 'file' elsif @attachment.is_image? render :action => 'image' elsif @attachment.is_pdf? render :action => 'pdf' + elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte + @content = File.read(@attachment.diskfile, :mode => "rb") + render :action => 'file' elsif @content = @attachment.markdownized_preview_content render :action => 'markdownized' else diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 623805202..2d43aba1a 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -241,6 +241,21 @@ class AttachmentsControllerTest < Redmine::ControllerTest assert_select 'img.filecontent', :src => attachments(:attachments_010).filename end + def test_show_svg_file_as_image + set_tmp_attachments_directory + attachment = Attachment.create!( + :container => Issue.find(1), + :file => uploaded_test_file('testfile.svg', 'image/svg+xml'), + :author => User.find(1) + ) + + get(:show, :params => {:id => attachment.id}) + + assert_response :success + assert_equal 'text/html', @response.media_type + assert_select 'img.filecontent', :src => attachment.filename + end + def test_show_pdf @request.session[:user_id] = 2 get(:show, :params => {:id => 23})