]> source.dussan.org Git - redmine.git/commitdiff
Use route helper in #link_to_project.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 14 Jan 2013 19:16:29 +0000 (19:16 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 14 Jan 2013 19:16:29 +0000 (19:16 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11184 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
app/views/admin/projects.html.erb
test/unit/helpers/application_helper_test.rb

index ae6c48bec2c90b6014cd50af77af99928072aae2..493721cb3db6f5efb031b0e465e69cde32cc5547 100644 (file)
@@ -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
 
index c2da70cbe94a03d76ca4367fa348928a39d7871b..00c13d5810a8039836d965998f456de71f6597f8 100644 (file)
@@ -27,7 +27,7 @@
   <tbody>
 <% project_tree(@projects) do |project, level| %>
   <tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
-  <td class="name"><span><%= link_to_project(project, {:action => (project.active? ? 'settings' : 'show')}, :title => project.short_description) %></span></td>
+  <td class="name"><span><%= link_to_project_settings(project, {}, :title => project.short_description) %></span></td>
   <td align="center"><%= checked_image project.is_public? %></td>
   <td align="center"><%= format_date(project.created_on) %></td>
   <td class="buttons">
index 4b5c896d7bd7eb8517cadc22b8e0d11ea6cc73f0..c5b3aaadc600f8ddb48058f6718db736542f6234 100644 (file)
@@ -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 '<a href="/projects/ecookbook/settings">eCookbook</a>', link_to_project_settings(project)
+
+    project.status = Project::STATUS_CLOSED
+    assert_equal '<a href="/projects/ecookbook">eCookbook</a>', 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"