Project

General

Profile

Actions

Patch #16710

closed

Support for the 1.x versions of mime-types gem

Added by Szilveszter Ördög over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Category:
Gems support
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Even though Redmine doesn't specify in its Gemfile a minimum version for the mime-types gem, it still assumes that version is 2.x or later. This is because it uses MIME::Types.find.

Unfortunately, upgrading to mime-types 2.x would break the dependencies of the mail gem.

The attached patch uses MIME::Types.type_for which is present in both 1.x and 2.x versions of mime-types.

Tested with Redmine 2.5.1 + ruby 1.8.7 + rails 3.2.17


Files

redmine-2.5.1-mime-types.patch (633 Bytes) redmine-2.5.1-mime-types.patch Patch for the issue Szilveszter Ördög, 2014-04-17 14:39
Actions #1

Updated by Pierre-Louis Bonicoli over 10 years ago

MIME::Types.find has been added in mime-types here.
There is another error if this additional commit is not used.
Both commits are included in mime-types 1.23.

Particularly MIME::Types.find is used in lib/redmine/mime_type.rb since r12483.

The problem doesn't occur:

First error fixed by 644259db36c69884735aa66aa6fdee690dfa9f7b:

ActionView::Template::Error (undefined method `find' for MIME::Types:Class):
    1: <div class="attachments">
    2: <% for attachment in attachments %>
    3: <p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
    4:   <% if attachment.is_text? %>
    5:     <%= link_to image_tag('magnifier.png'),
    6:                 :controller => 'attachments', :action => 'show',
  lib/redmine/mime_type.rb:63:in `block in of'
  lib/redmine/mime_type.rb:66:in `yield'
  lib/redmine/mime_type.rb:66:in `default'
  lib/redmine/mime_type.rb:66:in `of'
  lib/redmine/mime_type.rb:78:in `main_mimetype_of'
  lib/redmine/mime_type.rb:85:in `is_type?'
  app/models/attachment.rb:217:in `is_text?'
  app/views/attachments/_links.html.erb:3:in `block in _app_views_attachments__links_html_erb___3782281663955472009_30361420'
  app/views/attachments/_links.html.erb:2:in `_app_views_attachments__links_html_erb___3782281663955472009_30361420'
  app/helpers/attachments_helper.rb:31:in `link_to_attachments'
  app/views/documents/show.html.erb:19:in `_app_views_documents_show_html_erb___505910332762640252_28753000'

Second error fixed by fd53425e33046932cebcf0d3d8f92c3e35cd4472:

ActionView::Template::Error (undefined method `extensions' for #<Array:0x000000053ecdf8>):
    1: <div class="attachments">
    2: <% for attachment in attachments %>
    3: <p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
    4:   <% if attachment.is_text? %>
    5:     <%= link_to image_tag('magnifier.png'),
    6:                 :controller => 'attachments', :action => 'show',
  lib/redmine/mime_type.rb:63:in `block (2 levels) in of'
  lib/redmine/mime_type.rb:63:in `find'
  lib/redmine/mime_type.rb:63:in `block in of'
  lib/redmine/mime_type.rb:66:in `yield'
  lib/redmine/mime_type.rb:66:in `default'
  lib/redmine/mime_type.rb:66:in `of'
  lib/redmine/mime_type.rb:78:in `main_mimetype_of'
  lib/redmine/mime_type.rb:85:in `is_type?'
  app/models/attachment.rb:217:in `is_text?'
  app/views/attachments/_links.html.erb:3:in `block in _app_views_attachments__links_html_erb__4198667861296620514_35003500'
  app/views/attachments/_links.html.erb:2:in `_app_views_attachments__links_html_erb__4198667861296620514_35003500'
  app/helpers/attachments_helper.rb:31:in `link_to_attachments'
  app/views/documents/show.html.erb:19:in `_app_views_documents_show_html_erb__1410191189284416881_31521860'

Actions #2

Updated by Etienne Massip over 10 years ago

  • Target version set to Candidate for next minor release
Actions #3

Updated by Jean-Philippe Lang over 10 years ago

  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Target version changed from Candidate for next minor release to 2.5.2

Patch committed in r13107, thanks.

Actions #4

Updated by Jean-Philippe Lang over 10 years ago

  • Status changed from Resolved to Closed

Merged.

Actions

Also available in: Atom PDF