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
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
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>),