From 163c2cccfefb86767171a1967810845759768d5a Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Thu, 17 Sep 2026 13:42:38 +0900 Subject: [PATCH] Display the MIME type on the attachment preview page. --- app/assets/stylesheets/application.css | 2 +- app/views/layouts/_file.html.erb | 5 ++++- test/functional/attachments_controller_test.rb | 12 ++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 699b90689..ef21eb4df 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1451,7 +1451,7 @@ a.remove-upload:hover {text-decoration:none !important;} div.fileover, p.custom-field-filedroplistner.fileover { background-color: var(--oc-violet-0); } div.attachments img { vertical-align: middle; } -div.attachments span.author { font-size: 0.9em; color: var(--oc-gray-6); } +div.attachments span.author, div.attachments span.content-type { font-size: 0.9em; color: var(--oc-gray-6); } div.thumbnails {margin:0.6em;} div.thumbnail { diff --git a/app/views/layouts/_file.html.erb b/app/views/layouts/_file.html.erb index 902964bed..cd1180588 100644 --- a/app/views/layouts/_file.html.erb +++ b/app/views/layouts/_file.html.erb @@ -8,7 +8,10 @@

<%= "#{@attachment.description} - " unless @attachment.description.blank? %> - <%= link_to_user(@attachment.author) %>, <%= format_time(@attachment.created_on) %>

+ <%= link_to_user(@attachment.author) %>, <%= format_time(@attachment.created_on) %> + <% if @attachment.content_type.present? %> + (<%= @attachment.content_type %>) + <% end %>

<%= yield %> diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 9895f2294..c488b9870 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -144,6 +144,18 @@ class AttachmentsControllerTest < Redmine::ControllerTest assert_equal 'text/html', @response.media_type end + def test_show_should_display_content_type + get(:show, :params => {:id => 4}) + assert_response :success + assert_select 'div.attachments span.content-type', :text => '(application/x-ruby)' + end + + def test_show_should_not_display_content_type_if_blank + get(:show, :params => {:id => 22}) + assert_response :success + assert_select 'div.attachments span.content-type', 0 + end + def test_show_text_file_utf_8 set_tmp_attachments_directory a = Attachment.new(:container => Issue.find(1), -- 2.55.0