##// END OF EJS Templates
Adds a named route for thumbnails and use route helper in #thumbnail_tag....
Jean-Philippe Lang -
r10958:6ce28450c004
parent child
Show More
@@ -160,8 +160,8 module ApplicationHelper
160 end
160 end
161
161
162 def thumbnail_tag(attachment)
162 def thumbnail_tag(attachment)
163 link_to image_tag(url_for(:controller => 'attachments', :action => 'thumbnail', :id => attachment)),
163 link_to image_tag(thumbnail_path(attachment)),
164 {:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename},
164 named_attachment_path(attachment, attachment.filename),
165 :title => attachment.filename
165 :title => attachment.filename
166 end
166 end
167
167
@@ -260,7 +260,7 RedmineApp::Application.routes.draw do
260 get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
260 get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
261 get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
261 get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
262 get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
262 get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
263 get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/
263 get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
264 resources :attachments, :only => [:show, :destroy]
264 resources :attachments, :only => [:show, :destroy]
265
265
266 resources :groups do
266 resources :groups do
@@ -1077,6 +1077,12 RAW
1077 link_to_attachment(a, :only_path => false)
1077 link_to_attachment(a, :only_path => false)
1078 end
1078 end
1079
1079
1080 def test_thumbnail_tag
1081 a = Attachment.find(3)
1082 assert_equal '<a href="/attachments/3/logo.gif" title="logo.gif"><img alt="3" src="/attachments/thumbnail/3" /></a>',
1083 thumbnail_tag(a)
1084 end
1085
1080 def test_link_to_project
1086 def test_link_to_project
1081 project = Project.find(1)
1087 project = Project.find(1)
1082 assert_equal %(<a href="/projects/ecookbook">eCookbook</a>),
1088 assert_equal %(<a href="/projects/ecookbook">eCookbook</a>),
General Comments 0
You need to be logged in to leave comments. Login now