mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 07:35:46 +08:00
FIX: user and group mentions in subfolder installs
This commit is contained in:
parent
0e5c7f5da7
commit
421d47da1e
@ -440,10 +440,10 @@ module PrettyText
|
|||||||
|
|
||||||
case type
|
case type
|
||||||
when USER_TYPE
|
when USER_TYPE
|
||||||
element['href'] = "/u/#{name}"
|
element['href'] = "#{Discourse::base_uri}/u/#{name}"
|
||||||
when GROUP_TYPE
|
when GROUP_TYPE
|
||||||
element['class'] = 'mention-group'
|
element['class'] = 'mention-group'
|
||||||
element['href'] = "/groups/#{name}"
|
element['href'] = "#{Discourse::base_uri}/groups/#{name}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -265,6 +265,23 @@ describe PrettyText do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'subfolder' do
|
||||||
|
before do
|
||||||
|
GlobalSetting.stubs(:relative_url_root).returns('/forum')
|
||||||
|
Discourse.stubs(:base_uri).returns("/forum")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "handles user and group mentions correctly" do
|
||||||
|
Fabricate(:user, username: 'user1')
|
||||||
|
Fabricate(:group, name: 'groupA', mentionable_level: Group::ALIAS_LEVELS[:everyone])
|
||||||
|
|
||||||
|
input = 'hi there @user1 and @groupA'
|
||||||
|
expected = '<p>hi there <a class="mention" href="/forum/u/user1">@user1</a> and <a class="mention-group" href="/forum/groups/groupa">@groupA</a></p>'
|
||||||
|
|
||||||
|
expect(PrettyText.cook(input)).to eq(expected)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "does not create mention for a non mentionable group" do
|
it "does not create mention for a non mentionable group" do
|
||||||
group = Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:nobody])
|
group = Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:nobody])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user