From 6ce28450c00483f0f6962d3e9022735cbe5b7903 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 14 Jan 2013 20:51:49 +0000 Subject: [PATCH] Adds a named route for thumbnails and use route helper in #thumbnail_tag. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11188 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 4 ++-- config/routes.rb | 2 +- test/unit/helpers/application_helper_test.rb | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2a06ad926..d384ffa8b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 7a1eb663a..061bdf7ba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 506c30cc7..e097efe52 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -1077,6 +1077,12 @@ RAW link_to_attachment(a, :only_path => false) end + def test_thumbnail_tag + a = Attachment.find(3) + assert_equal '3', + thumbnail_tag(a) + end + def test_link_to_project project = Project.find(1) assert_equal %(eCookbook), -- 2.39.5