]> source.dussan.org Git - redmine.git/commitdiff
Adds a named route for thumbnails and use route helper in #thumbnail_tag.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 14 Jan 2013 20:51:49 +0000 (20:51 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 14 Jan 2013 20:51:49 +0000 (20:51 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11188 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
config/routes.rb
test/unit/helpers/application_helper_test.rb

index 2a06ad926ef2ca74e1e0cb6a7cd7ebb3de787dbe..d384ffa8bfce1d57b2137a73458777f224d5e1e9 100644 (file)
@@ -160,8 +160,8 @@ module ApplicationHelper
   end
 
   def thumbnail_tag(attachment)
-    link_to image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment)),
-      {:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename},
+    link_to image_tag(thumbnail_path(attachment)),
+      named_attachment_path(attachment, attachment.filename),
       :title => attachment.filename
   end
 
index 7a1eb663aefebce365a1082d5b80fb9d518d42fc..061bdf7bab411f5878bacef7ebec67fb4a39719b 100644 (file)
@@ -260,7 +260,7 @@ RedmineApp::Application.routes.draw do
   get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
   get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
   get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
-  get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/
+  get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
   resources :attachments, :only => [:show, :destroy]
 
   resources :groups do
index 506c30cc7be4d73a45962d49fad6e10a56bf0f23..e097efe5248c9958b18e37d1a50cec4ddfd19b3f 100644 (file)
@@ -1077,6 +1077,12 @@ RAW
       link_to_attachment(a, :only_path => false)
   end
 
+  def test_thumbnail_tag
+    a = Attachment.find(3)
+    assert_equal '<a href="/attachments/3/logo.gif" title="logo.gif"><img alt="3" src="/attachments/thumbnail/3" /></a>',
+      thumbnail_tag(a)
+  end
+
   def test_link_to_project
     project = Project.find(1)
     assert_equal %(<a href="/projects/ecookbook">eCookbook</a>),