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
|
||||
when USER_TYPE
|
||||
element['href'] = "/u/#{name}"
|
||||
element['href'] = "#{Discourse::base_uri}/u/#{name}"
|
||||
when GROUP_TYPE
|
||||
element['class'] = 'mention-group'
|
||||
element['href'] = "/groups/#{name}"
|
||||
element['href'] = "#{Discourse::base_uri}/groups/#{name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -265,6 +265,23 @@ describe PrettyText do
|
|||
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
|
||||
group = Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:nobody])
|
||||
|
||||
|
|
Loading…
Reference in New Issue