summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-06-17 08:48:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-06-17 08:48:23 +0000
commit7017874cc971d77448eb81ece974d061b2ca3a30 (patch)
tree72d8f5a5453753e52342c1391799f50fadeff384
parent4120b59e10241e9910cacd7c78124ffc10426d96 (diff)
downloadredmine-7017874cc971d77448eb81ece974d061b2ca3a30.tar.gz
redmine-7017874cc971d77448eb81ece974d061b2ca3a30.zip
Link to user by id (#4179).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@16671 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--test/unit/helpers/application_helper_test.rb1
2 files changed, 5 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 32d7c9640..09de3dc80 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -821,6 +821,7 @@ module ApplicationHelper
# Users:
# user:jsmith -> Link to user with login jsmith
# @jsmith -> Link to user with login jsmith
+ # user#2 -> Link to user with id 2
#
# Links can refer other objects from other projects, using project identifier:
# identifier:r52
@@ -908,6 +909,9 @@ module ApplicationHelper
if p = Project.visible.find_by_id(oid)
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
end
+ when 'user'
+ u = User.visible.where(:id => oid, :type => 'User').first
+ link = link_to_user(u) if u
end
elsif sep == ':'
name = remove_double_quotes(identifier)
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 678dcfda5..d58c7a633 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -386,6 +386,7 @@ RAW
"http://foo.bar/FAQ#3" => '<a class="external" href="http://foo.bar/FAQ#3">http://foo.bar/FAQ#3</a>',
# user
'user:jsmith' => link_to_user(User.find_by_id(2)),
+ 'user#2' => link_to_user(User.find_by_id(2)),
'@jsmith' => link_to_user(User.find_by_id(2)),
# invalid user
'user:foobar' => 'user:foobar',