From b553b23e6b9d712d9c1168cbb167a2bbfd9ec088 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 8 May 2016 08:04:51 +0000 Subject: [PATCH] Show attachment view even is no preview is available (#22482). Patch by Gregor Schmidt. git-svn-id: http://svn.redmine.org/redmine/trunk@15398 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/attachments_controller.rb | 2 +- app/views/attachments/other.html.erb | 3 +++ test/functional/attachments_controller_test.rb | 10 ++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 app/views/attachments/other.html.erb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 8c6b4484e..14025cb86 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -43,7 +43,7 @@ class AttachmentsController < ApplicationController elsif @attachment.is_image? render :action => 'image' else - download + render :action => 'other' end } format.api diff --git a/app/views/attachments/other.html.erb b/app/views/attachments/other.html.erb new file mode 100644 index 000000000..e6244c16e --- /dev/null +++ b/app/views/attachments/other.html.erb @@ -0,0 +1,3 @@ +<%= render :layout => 'layouts/file' do %> + <%= render :partial => 'common/other' %> +<% end %> diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 397be850c..5d3387975 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -179,12 +179,13 @@ class AttachmentsControllerTest < ActionController::TestCase end end - def test_show_text_file_should_send_if_too_big + def test_show_text_file_should_show_other_if_too_big with_settings :file_max_size_displayed => 512 do Attachment.find(4).update_attribute :filesize, 754.kilobyte get :show, :id => 4 assert_response :success - assert_equal 'application/x-ruby', @response.content_type + assert_template 'other' + assert_equal 'text/html', @response.content_type end set_tmp_attachments_directory end @@ -200,8 +201,9 @@ class AttachmentsControllerTest < ActionController::TestCase def test_show_other get :show, :id => 6 - assert_response :success - assert_equal 'application/zip', @response.content_type + assert_template 'other' + assert_equal 'text/html', @response.content_type + assert_select '.nodata', :text => 'No preview available' set_tmp_attachments_directory end -- 2.39.5