FIX: Fix mentions for mixed case group names

This commit is contained in:
David Taylor 2018-11-26 15:34:56 +00:00
parent 2e4706b787
commit afcf149c34
2 changed files with 10 additions and 7 deletions

View File

@ -464,9 +464,9 @@ module PrettyText
( (
SELECT SELECT
:group_type AS type, :group_type AS type,
name lower(name) AS name
FROM groups FROM groups
WHERE name IN (:names) AND (#{Group.mentionable_sql_clause}) WHERE lower(name) IN (:names) AND (#{Group.mentionable_sql_clause})
) )
SQL SQL

View File

@ -225,9 +225,12 @@ describe PrettyText do
Fabricate(:user, username: username) Fabricate(:user, username: username)
end end
group = Fabricate(:group, ['Group', 'group2'].each do |name|
mentionable_level: Group::ALIAS_LEVELS[:everyone] Fabricate(:group,
) name: name,
mentionable_level: Group::ALIAS_LEVELS[:everyone]
)
end
[ [
[ [
@ -235,8 +238,8 @@ describe PrettyText do
'<p>hi <a class="mention" href="/u/user">@uSer</a>! <a class="mention" href="/u/user2">@user2</a> hi</p>' '<p>hi <a class="mention" href="/u/user">@uSer</a>! <a class="mention" href="/u/user2">@user2</a> hi</p>'
], ],
[ [
"hi\n@user. @#{group.name.capitalize} @somemention", "hi\n@user. @GROUP @somemention @group2",
%Q|<p>hi<br>\n<a class="mention" href="/u/user">@user</a>. <a class="mention-group" href="/groups/#{group.name}">@#{group.name.capitalize}</a> <span class="mention">@somemention</span></p>| %Q|<p>hi<br>\n<a class="mention" href="/u/user">@user</a>. <a class="mention-group" href="/groups/group">@GROUP</a> <span class="mention">@somemention</span> <a class="mention-group" href="/groups/group2">@group2</a></p>|
] ]
].each do |input, expected| ].each do |input, expected|
expect(PrettyText.cook(input)).to eq(expected) expect(PrettyText.cook(input)).to eq(expected)