From 1da158edcffbb3db0ae88e781bcd4a412124f478 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 14 Jan 2013 19:16:29 +0000 Subject: [PATCH] Use route helper in #link_to_project. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11184 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 20 +++++++++++++++++--- app/views/admin/projects.html.erb | 2 +- test/unit/helpers/application_helper_test.rb | 11 +++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ae6c48bec..493721cb3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -141,10 +141,24 @@ module ApplicationHelper # def link_to_project(project, options={}, html_options = nil) if project.archived? - h(project) - else + h(project.name) + elsif options.key?(:action) + ActiveSupport::Deprecation.warn "#link_to_project with :action option is deprecated and will be removed in Redmine 3.0." url = {:controller => 'projects', :action => 'show', :id => project}.merge(options) - link_to(h(project), url, html_options) + link_to project.name, url, html_options + else + link_to project.name, project_path(project, options), html_options + end + end + + # Generates a link to a project settings if active + def link_to_project_settings(project, options={}, html_options=nil) + if project.active? + link_to project.name, settings_project_path(project, options), html_options + elsif project.archived? + h(project.name) + else + link_to project.name, project_path(project, options), html_options end end diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb index c2da70cbe..00c13d581 100644 --- a/app/views/admin/projects.html.erb +++ b/app/views/admin/projects.html.erb @@ -27,7 +27,7 @@ <% project_tree(@projects) do |project, level| %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>"> - <%= link_to_project(project, {:action => (project.active? ? 'settings' : 'show')}, :title => project.short_description) %> + <%= link_to_project_settings(project, {}, :title => project.short_description) %> <%= checked_image project.is_public? %> <%= format_date(project.created_on) %> diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 4b5c896d7..c5b3aaadc 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -1075,6 +1075,17 @@ RAW link_to_project(project, {:action => 'settings'}, :class => "project") end + def test_link_to_project_settings + project = Project.find(1) + assert_equal 'eCookbook', link_to_project_settings(project) + + project.status = Project::STATUS_CLOSED + assert_equal 'eCookbook', link_to_project_settings(project) + + project.status = Project::STATUS_ARCHIVED + assert_equal 'eCookbook', link_to_project_settings(project) + end + def test_link_to_legacy_project_with_numerical_identifier_should_use_id # numeric identifier are no longer allowed Project.update_all "identifier=25", "id=1"