]> source.dussan.org Git - redmine.git/commitdiff
Add class @user-mention@ to user classes when user is linked using @ (#36699, #13919).
authorMarius Balteanu <marius.balteanu@zitec.com>
Thu, 24 Feb 2022 21:54:30 +0000 (21:54 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Thu, 24 Feb 2022 21:54:30 +0000 (21:54 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@21440 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/helpers/application_helper_test.rb

index cbf15a873c25bbf2b6312909db92120876e12f7a..1d2b09423e9a555255660dfe97bc3d22b18ed154 100644 (file)
@@ -1265,7 +1265,7 @@ module ApplicationHelper
           elsif sep == "@"
             name = remove_double_quotes(identifier)
             u = User.visible.find_by("LOWER(login) = :s AND type = 'User'", :s => name.downcase)
-            link = link_to_user(u, :only_path => only_path) if u
+            link = link_to_user(u, :only_path => only_path, :class => 'user-mention') if u
           end
         end
         (leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}#{comment_suffix}"))
index 99727b95686d77cce0c35a7f7d811bb44aa84de8..20b854cc7552710403fd7fb99b0d5705d4365668 100644 (file)
@@ -562,12 +562,12 @@ class ApplicationHelperTest < Redmine::HelperTest
       'user:jsmith'                 => link_to_user(User.find_by_id(2)),
       '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)),
-      '@jsmith.'                    => "#{link_to_user(User.find_by_id(2))}.",
-      '@JSMITH'                     => link_to_user(User.find_by_id(2)),
-      '@abcd@example.com'           => link_to_user(User.find_by_id(u_email_id)),
+      '@jsmith'                     => link_to_user(User.find_by_id(2), class: 'user-mention'),
+      '@jsmith.'                    => "#{link_to_user(User.find_by_id(2), class: 'user-mention')}.",
+      '@JSMITH'                     => link_to_user(User.find_by_id(2), class: 'user-mention'),
+      '@abcd@example.com'           => link_to_user(User.find_by_id(u_email_id), class: 'user-mention'),
       'user:abcd@example.com'       => link_to_user(User.find_by_id(u_email_id)),
-      '@foo.bar@example.com'        => link_to_user(User.find_by_id(u_email_id_2)),
+      '@foo.bar@example.com'        => link_to_user(User.find_by_id(u_email_id_2), class: 'user-mention'),
       'user:foo.bar@example.com'    => link_to_user(User.find_by_id(u_email_id_2)),
       # invalid user
       'user:foobar'                 => 'user:foobar',
@@ -596,7 +596,7 @@ class ApplicationHelperTest < Redmine::HelperTest
       # user link format: @jsmith@somenet.foo
       raw = "@jsmith@somenet.foo should not be parsed in jsmith@somenet.foo"
       assert_match(
-        %r{<p><a class="user active".*>#{u.name}</a> should not be parsed in #{html}</p>},
+        %r{<p><a class="user active user-mention".*>#{u.name}</a> should not be parsed in #{html}</p>},
         textilizable(raw, :project => Project.find(1))
       )
       # user link format: user:jsmith@somenet.foo
@@ -616,7 +616,7 @@ class ApplicationHelperTest < Redmine::HelperTest
       # user link format: @jsmith@somenet.foo
       raw = "@jsmith@somenet.foo should not be parsed in jsmith@somenet.foo"
       assert_match(
-        %r{<p><a class=\"user active\".*>#{u.name}</a> should not be parsed in #{html}</p>},
+        %r{<p><a class=\"user active user-mention\".*>#{u.name}</a> should not be parsed in #{html}</p>},
         textilizable(raw, :project => Project.find(1))
       )
       # user link format: user:jsmith@somenet.foo