From df9ca1c312a16b05e6c4fd9a7f5d9f84a1a8447d Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Thu, 17 Sep 2026 13:42:38 +0900 Subject: [PATCH 2/3] Display the MIME type on the attachment preview page. --- app/views/layouts/_file.html.erb | 3 ++- test/functional/attachments_controller_test.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_file.html.erb b/app/views/layouts/_file.html.erb index 2ca56f5b9..e8f776e51 100644 --- a/app/views/layouts/_file.html.erb +++ b/app/views/layouts/_file.html.erb @@ -8,7 +8,8 @@

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

+ <% content_type = content_tag(:span, @attachment.content_type, :class => 'content-type') if @attachment.content_type.present? %> + <%= safe_join([link_to_user(@attachment.author), format_time(@attachment.created_on), content_type].compact, ', ') %>

<%= yield %> diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 9895f2294..31e58e089 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -144,6 +144,19 @@ 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.author span.content-type', :text => 'application/x-ruby' + assert_select 'div.attachments span.author', :text => /, application\/x-ruby\z/ + 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