summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-11 10:48:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-11-11 10:48:54 +0000
commitc31411ec0029d5b2033d2d91aef18f601a8a7224 (patch)
treedbbf2414f6d85a7bb05aad58297398fd0e692c99
parent8f40750ad7f7ad512fd816757f072c42fae20e66 (diff)
downloadredmine-c31411ec0029d5b2033d2d91aef18f601a8a7224.tar.gz
redmine-c31411ec0029d5b2033d2d91aef18f601a8a7224.zip
Fixes ApplicationHelper#link_to_user
* No link to a locked user page (closes #4182) * Translate Anonymous string git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3024 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb11
-rw-r--r--app/models/user.rb2
-rw-r--r--config/locales/bg.yml1
-rw-r--r--config/locales/bs.yml1
-rw-r--r--config/locales/ca.yml1
-rw-r--r--config/locales/cs.yml1
-rw-r--r--config/locales/da.yml1
-rw-r--r--config/locales/de.yml1
-rw-r--r--config/locales/el.yml1
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/locales/es.yml1
-rw-r--r--config/locales/fi.yml1
-rw-r--r--config/locales/fr.yml1
-rw-r--r--config/locales/gl.yml1
-rw-r--r--config/locales/he.yml1
-rw-r--r--config/locales/hu.yml1
-rw-r--r--config/locales/it.yml1
-rw-r--r--config/locales/ja.yml1
-rw-r--r--config/locales/ko.yml1
-rw-r--r--config/locales/lt.yml1
-rw-r--r--config/locales/nl.yml1
-rw-r--r--config/locales/no.yml1
-rw-r--r--config/locales/pl.yml1
-rw-r--r--config/locales/pt-BR.yml1
-rw-r--r--config/locales/pt.yml1
-rw-r--r--config/locales/ro.yml1
-rw-r--r--config/locales/ru.yml1
-rw-r--r--config/locales/sk.yml1
-rw-r--r--config/locales/sl.yml1
-rw-r--r--config/locales/sr.yml1
-rw-r--r--config/locales/sv.yml1
-rw-r--r--config/locales/th.yml1
-rw-r--r--config/locales/tr.yml1
-rw-r--r--config/locales/uk.yml1
-rw-r--r--config/locales/vi.yml1
-rw-r--r--config/locales/zh-TW.yml1
-rw-r--r--config/locales/zh.yml1
-rw-r--r--test/fixtures/users.yml2
-rw-r--r--test/unit/helpers/application_helper_test.rb20
39 files changed, 65 insertions, 5 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index bab883083..cacfe2986 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -44,12 +44,17 @@ module ApplicationHelper
link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action])
end
- # Display a link to user's account page
+ # Displays a link to user's account page if active
def link_to_user(user, options={})
if user.is_a?(User)
- !user.anonymous? ? link_to(user.name(options[:format]), :controller => 'users', :action => 'show', :id => user) : 'Anonymous'
+ name = h(user.name(options[:format]))
+ if user.active?
+ link_to name, :controller => 'users', :action => 'show', :id => user
+ else
+ name
+ end
else
- user.to_s
+ h(user.to_s)
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 3e852aca3..e9c58bcc5 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -346,7 +346,7 @@ class AnonymousUser < User
# Overrides a few properties
def logged?; false end
def admin; false end
- def name; 'Anonymous' end
+ def name(*args); I18n.t(:label_user_anonymous) end
def mail; nil end
def time_zone; nil end
def rss_key; nil end
diff --git a/config/locales/bg.yml b/config/locales/bg.yml
index c35138a1e..56a14ad5b 100644
--- a/config/locales/bg.yml
+++ b/config/locales/bg.yml
@@ -831,3 +831,4 @@ bg:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/bs.yml b/config/locales/bs.yml
index f8bf5b13e..b23b2bbe2 100644
--- a/config/locales/bs.yml
+++ b/config/locales/bs.yml
@@ -855,3 +855,4 @@ bs:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/ca.yml b/config/locales/ca.yml
index 6a85787be..a7903ade8 100644
--- a/config/locales/ca.yml
+++ b/config/locales/ca.yml
@@ -834,3 +834,4 @@ ca:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/cs.yml b/config/locales/cs.yml
index 68cbb412c..d65895ee3 100644
--- a/config/locales/cs.yml
+++ b/config/locales/cs.yml
@@ -837,3 +837,4 @@ cs:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/da.yml b/config/locales/da.yml
index 00d430b77..bb3a14ced 100644
--- a/config/locales/da.yml
+++ b/config/locales/da.yml
@@ -857,3 +857,4 @@ da:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/de.yml b/config/locales/de.yml
index f9ffc1067..520284e9f 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -857,3 +857,4 @@ de:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/el.yml b/config/locales/el.yml
index ce4fc2647..a54952dfa 100644
--- a/config/locales/el.yml
+++ b/config/locales/el.yml
@@ -837,3 +837,4 @@ el:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/en.yml b/config/locales/en.yml
index eedf48df5..574ee9db0 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -376,6 +376,7 @@ en:
label_user: User
label_user_plural: Users
label_user_new: New user
+ label_user_anonymous: Anonymous
label_project: Project
label_project_new: New project
label_project_plural: Projects
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 864cd141d..8776faa3b 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -878,3 +878,4 @@ es:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/fi.yml b/config/locales/fi.yml
index 34214fee0..ab677f81b 100644
--- a/config/locales/fi.yml
+++ b/config/locales/fi.yml
@@ -867,3 +867,4 @@ fi:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 2c4dbf6f0..4d3972403 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -398,6 +398,7 @@ fr:
label_user: Utilisateur
label_user_plural: Utilisateurs
label_user_new: Nouvel utilisateur
+ label_user_anonymous: Anonyme
label_project: Projet
label_project_new: Nouveau projet
label_project_plural: Projets
diff --git a/config/locales/gl.yml b/config/locales/gl.yml
index b2a8d49d1..85b59e8d2 100644
--- a/config/locales/gl.yml
+++ b/config/locales/gl.yml
@@ -857,3 +857,4 @@ gl:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/he.yml b/config/locales/he.yml
index d60b94e4b..f344e81cc 100644
--- a/config/locales/he.yml
+++ b/config/locales/he.yml
@@ -841,3 +841,4 @@ he:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/hu.yml b/config/locales/hu.yml
index b7c9dff69..f8e0f130e 100644
--- a/config/locales/hu.yml
+++ b/config/locales/hu.yml
@@ -862,3 +862,4 @@
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/it.yml b/config/locales/it.yml
index 7d6ccac21..06fd50c99 100644
--- a/config/locales/it.yml
+++ b/config/locales/it.yml
@@ -844,3 +844,4 @@ it:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/ja.yml b/config/locales/ja.yml
index 9e70679e9..99f8a4ab6 100644
--- a/config/locales/ja.yml
+++ b/config/locales/ja.yml
@@ -866,3 +866,4 @@ ja:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/ko.yml b/config/locales/ko.yml
index 4441ebe60..be3b8719e 100644
--- a/config/locales/ko.yml
+++ b/config/locales/ko.yml
@@ -897,3 +897,4 @@ ko:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/lt.yml b/config/locales/lt.yml
index 3d7fcc6cb..021391620 100644
--- a/config/locales/lt.yml
+++ b/config/locales/lt.yml
@@ -867,3 +867,4 @@ lt:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/nl.yml b/config/locales/nl.yml
index 4212d445d..ae5107d55 100644
--- a/config/locales/nl.yml
+++ b/config/locales/nl.yml
@@ -819,3 +819,4 @@ nl:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/no.yml b/config/locales/no.yml
index df91bdf4f..39a9ac7f0 100644
--- a/config/locales/no.yml
+++ b/config/locales/no.yml
@@ -832,3 +832,4 @@
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/pl.yml b/config/locales/pl.yml
index fa232a296..e5690967c 100644
--- a/config/locales/pl.yml
+++ b/config/locales/pl.yml
@@ -860,3 +860,4 @@ pl:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml
index 51d5221e2..2d43e29f2 100644
--- a/config/locales/pt-BR.yml
+++ b/config/locales/pt-BR.yml
@@ -863,3 +863,4 @@ pt-BR:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/pt.yml b/config/locales/pt.yml
index e9c6423a0..3f4462794 100644
--- a/config/locales/pt.yml
+++ b/config/locales/pt.yml
@@ -849,3 +849,4 @@ pt:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/ro.yml b/config/locales/ro.yml
index b62449617..9f0cc8763 100644
--- a/config/locales/ro.yml
+++ b/config/locales/ro.yml
@@ -834,3 +834,4 @@ ro:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index 14b003341..109d55e04 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -945,3 +945,4 @@ ru:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/sk.yml b/config/locales/sk.yml
index efb0325b6..b715533fb 100644
--- a/config/locales/sk.yml
+++ b/config/locales/sk.yml
@@ -836,3 +836,4 @@ sk:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/sl.yml b/config/locales/sl.yml
index d3a6a3113..a1d142cd2 100644
--- a/config/locales/sl.yml
+++ b/config/locales/sl.yml
@@ -833,3 +833,4 @@ sl:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/sr.yml b/config/locales/sr.yml
index 90f3a2122..ff7bb9178 100644
--- a/config/locales/sr.yml
+++ b/config/locales/sr.yml
@@ -852,3 +852,4 @@
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/sv.yml b/config/locales/sv.yml
index 301debd95..3a2f82e8e 100644
--- a/config/locales/sv.yml
+++ b/config/locales/sv.yml
@@ -885,3 +885,4 @@ sv:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/th.yml b/config/locales/th.yml
index 24d16bf31..890b10e01 100644
--- a/config/locales/th.yml
+++ b/config/locales/th.yml
@@ -834,3 +834,4 @@ th:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/tr.yml b/config/locales/tr.yml
index d835ab1a8..a0f1977d9 100644
--- a/config/locales/tr.yml
+++ b/config/locales/tr.yml
@@ -864,3 +864,4 @@ tr:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/uk.yml b/config/locales/uk.yml
index 3502c52d0..4307c91a0 100644
--- a/config/locales/uk.yml
+++ b/config/locales/uk.yml
@@ -833,3 +833,4 @@ uk:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/vi.yml b/config/locales/vi.yml
index 6ae808512..cdd04a4f5 100644
--- a/config/locales/vi.yml
+++ b/config/locales/vi.yml
@@ -896,3 +896,4 @@ vi:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml
index 05b4b214c..9ad4e9841 100644
--- a/config/locales/zh-TW.yml
+++ b/config/locales/zh-TW.yml
@@ -927,3 +927,4 @@
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index bb60315b0..04c7113e9 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -859,3 +859,4 @@ zh:
version_status_locked: locked
version_status_open: open
error_can_not_reopen_issue_on_closed_version: An issue assigned to a closed version can not be reopened
+ label_user_anonymous: Anonymous
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index 29d4f1565..29fc6be04 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -83,7 +83,7 @@ users_005:
users_006:
id: 6
created_on: 2006-07-19 19:33:19 +02:00
- status: 1
+ status: 0
last_login_on:
language: ''
hashed_password: 1
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb
index 84fc3bd6b..05742150b 100644
--- a/test/unit/helpers/application_helper_test.rb
+++ b/test/unit/helpers/application_helper_test.rb
@@ -483,4 +483,24 @@ EXPECTED
Setting.gravatar_enabled = '0'
assert_nil avatar(User.find_by_mail('jsmith@somenet.foo'))
end
+
+ def test_link_to_user
+ user = User.find(2)
+ t = link_to_user(user)
+ assert_equal "<a href=\"/users/2\">#{ user.name }</a>", t
+ end
+
+ def test_link_to_user_should_not_link_to_locked_user
+ user = User.find(5)
+ assert user.locked?
+ t = link_to_user(user)
+ assert_equal user.name, t
+ end
+
+ def test_link_to_user_should_not_link_to_anonymous
+ user = User.anonymous
+ assert user.anonymous?
+ t = link_to_user(user)
+ assert_equal ::I18n.t(:label_user_anonymous), t
+ end
end