From ace5e128946ef4a8af629ed415a501704be3e6dc Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Fri, 6 Feb 2026 16:59:14 +0900 Subject: [PATCH 1/2] Change IconsHelper#icon_for_mime_type to accept raw MIME types instead of CSS class names --- app/helpers/icons_helper.rb | 12 ++++++------ test/helpers/icons_helper_test.rb | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 6afb84537..3940896b5 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -40,7 +40,7 @@ module IconsHelper if entry.is_dir? sprite_icon("folder", name, **) else - icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(name)) + icon_name = icon_for_mime_type(Redmine::MimeType.of(name)) sprite_icon(icon_name, name, **) end end @@ -109,11 +109,11 @@ module IconsHelper end def icon_for_mime_type(mime) - if %w(text-plain text-x-c text-x-csharp text-x-java text-x-php - text-x-ruby text-xml text-css text-html text-css text-html - image-gif image-jpeg image-png image-tiff - application-pdf application-zip application-gzip application-javascript).include?(mime) - mime + if %w(text/plain text/x-c text/x-csharp text/x-java text/x-php + text/x-ruby text/xml text/css text/html text/css text/html + image/gif image/jpeg image/png image/tiff + application/pdf application/zip application/gzip application/javascript).include?(mime) + mime.tr('/', '-') else "file" end diff --git a/test/helpers/icons_helper_test.rb b/test/helpers/icons_helper_test.rb index 7ef071f86..4372e666a 100644 --- a/test/helpers/icons_helper_test.rb +++ b/test/helpers/icons_helper_test.rb @@ -125,11 +125,11 @@ class IconsHelperTest < Redmine::HelperTest end def test_icon_for_mime_type_should_return_specific_icon_for_known_mime_types - assert_equal 'text-plain', icon_for_mime_type('text-plain') - assert_equal 'application-pdf', icon_for_mime_type('application-pdf') + assert_equal 'text-plain', icon_for_mime_type('text/plain') + assert_equal 'application-pdf', icon_for_mime_type('application/pdf') end def test_icon_for_mime_type_should_return_generic_file_icon_for_unknown_mime_types - assert_equal 'file', icon_for_mime_type('unknown-type') + assert_equal 'file', icon_for_mime_type('unknown-type/unknown-subtype') end end -- 2.50.1