FIX: Don't show suggested messages if private messages are disabled

This commit is contained in:
Robin Ward 2018-01-23 12:05:44 -05:00
parent cb9524c365
commit 17ebfd1715
2 changed files with 9 additions and 1 deletions

View File

@ -100,7 +100,11 @@ class TopicQuery
# Return a list of suggested topics for a topic
def list_suggested_for(topic)
return if topic.private_message? && !@user
# Don't suggest messages unless we have a user, and private messages are
# enabled.
return if topic.private_message? &&
(@user.blank? || !SiteSetting.enable_private_messages?)
builder = SuggestedTopicsBuilder.new(topic)

View File

@ -695,6 +695,10 @@ describe TopicQuery do
expect(TopicQuery.new(user).list_suggested_for(pm_to_user).topics.map(&:id)).to(
eq([new_pm.id, unread_pm.id, related_by_user_pm.id])
)
SiteSetting.enable_private_messages = false
expect(TopicQuery.new(user).list_suggested_for(pm_to_group)).to be_blank
expect(TopicQuery.new(user).list_suggested_for(pm_to_user)).to be_blank
end
end