Patch #16710

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

Added by Szilveszter Ördög about 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Gems support
Target version:2.5.2

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

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

Associated revisions

Revision 13107
Added by Jean-Philippe Lang almost 4 years ago

Support for the 1.x versions of mime-types gem (#16710).

Patch by Szilveszter Ördög.

History

#1 Updated by Pierre-Louis Bonicoli almost 4 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'

#2 Updated by Etienne Massip almost 4 years ago

  • Target version set to Candidate for next minor release

#3 Updated by Jean-Philippe Lang almost 4 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.

#4 Updated by Jean-Philippe Lang almost 4 years ago

  • Status changed from Resolved to Closed

Merged.

Also available in: Atom PDF