mirror of
https://github.com/redmine/redmine.git
synced 2026-02-15 11:07:49 +01:00
Change IconsHelper#icon_for_mime_type to accept raw MIME types instead of CSS class names (#43797).
Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@24401 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -125,8 +125,8 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user