]> source.dussan.org Git - redmine.git/commitdiff
Fixed "can't convert Fixnum into String" error on projects with numerical identifier...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 6 Feb 2012 14:44:40 +0000 (14:44 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 6 Feb 2012 14:44:40 +0000 (14:44 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8804 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
test/unit/helpers/application_helper_test.rb

index 8a79ed67459dc8632fdcbc67a2ccb1e1637c60df..407f723c4902f1c0fe2825e6897fac07572fd1f5 100644 (file)
@@ -274,7 +274,7 @@ class Project < ActiveRecord::Base
 
   def to_param
     # id is used for projects with a numeric identifier (compatibility)
-    @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id : identifier)
+    @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier)
   end
 
   def active?
index 20e458b7bebc8d4bfe02ef07837253090a2520cf..3e00030b519869774f21c6e52584d395690b702a 100644 (file)
@@ -920,6 +920,14 @@ RAW
                  link_to_project(project, {:action => 'settings'}, :class => "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"
+
+    assert_equal '<a href="/projects/1">eCookbook</a>',
+                 link_to_project(Project.find(1))
+  end
+
   def test_principals_options_for_select_with_users
     User.current = nil
     users = [User.find(2), User.find(4)]