Feature #43797 » 0001-Change-IconsHelper-icon_for_mime_type-to-accept-raw-.patch
| app/helpers/icons_helper.rb | ||
|---|---|---|
| 40 | 40 |
if entry.is_dir? |
| 41 | 41 |
sprite_icon("folder", name, **)
|
| 42 | 42 |
else |
| 43 |
icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(name))
|
|
| 43 |
icon_name = icon_for_mime_type(Redmine::MimeType.of(name)) |
|
| 44 | 44 |
sprite_icon(icon_name, name, **) |
| 45 | 45 |
end |
| 46 | 46 |
end |
| ... | ... | |
| 109 | 109 |
end |
| 110 | 110 | |
| 111 | 111 |
def icon_for_mime_type(mime) |
| 112 |
if %w(text-plain text-x-c text-x-csharp text-x-java text-x-php
|
|
| 113 |
text-x-ruby text-xml text-css text-html text-css text-html
|
|
| 114 |
image-gif image-jpeg image-png image-tiff
|
|
| 115 |
application-pdf application-zip application-gzip application-javascript).include?(mime)
|
|
| 116 |
mime |
|
| 112 |
if %w(text/plain text/x-c text/x-csharp text/x-java text/x-php
|
|
| 113 |
text/x-ruby text/xml text/css text/html text/css text/html
|
|
| 114 |
image/gif image/jpeg image/png image/tiff
|
|
| 115 |
application/pdf application/zip application/gzip application/javascript).include?(mime)
|
|
| 116 |
mime.tr('/', '-')
|
|
| 117 | 117 |
else |
| 118 | 118 |
"file" |
| 119 | 119 |
end |
| test/helpers/icons_helper_test.rb | ||
|---|---|---|
| 125 | 125 |
end |
| 126 | 126 | |
| 127 | 127 |
def test_icon_for_mime_type_should_return_specific_icon_for_known_mime_types |
| 128 |
assert_equal 'text-plain', icon_for_mime_type('text-plain')
|
|
| 129 |
assert_equal 'application-pdf', icon_for_mime_type('application-pdf')
|
|
| 128 |
assert_equal 'text-plain', icon_for_mime_type('text/plain')
|
|
| 129 |
assert_equal 'application-pdf', icon_for_mime_type('application/pdf')
|
|
| 130 | 130 |
end |
| 131 | 131 | |
| 132 | 132 |
def test_icon_for_mime_type_should_return_generic_file_icon_for_unknown_mime_types |
| 133 |
assert_equal 'file', icon_for_mime_type('unknown-type')
|
|
| 133 |
assert_equal 'file', icon_for_mime_type('unknown-type/unknown-subtype')
|
|
| 134 | 134 |
end |
| 135 | 135 |
end |